-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateEnergyRecive_Mixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.xir.NHUtilities.mixins.late.EnderIO; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import com.xir.NHUtilities.common.api.ITileEntityTickAcceleration; | ||
|
||
import crazypants.enderio.machine.AbstractPoweredMachineEntity; | ||
import crazypants.enderio.power.ICapacitor; | ||
|
||
@Mixin(value = AbstractPoweredMachineEntity.class, remap = false) | ||
public class AccelerateEnergyRecive_Mixin { | ||
|
||
@Redirect( | ||
method = "getMaxEnergyRecieved", | ||
at = @At(value = "INVOKE", target = "Lcrazypants/enderio/power/ICapacitor;getMaxEnergyReceived()I")) | ||
private int NHUtilities$modifyMaxEnergyReceivedValue(ICapacitor instance) { | ||
if (this instanceof ITileEntityTickAcceleration tileEntityITEA) { | ||
int tickAcceleratedRate = tileEntityITEA.getTickAcceleratedRate(); | ||
return instance.getMaxEnergyReceived() * tickAcceleratedRate; | ||
} | ||
return instance.getMaxEnergyReceived(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateTileEntity_Mixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.xir.NHUtilities.mixins.late.EnderIO; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
import com.enderio.core.common.TileEntityEnder; | ||
import com.xir.NHUtilities.common.api.ITileEntityTickAcceleration; | ||
|
||
@Mixin(value = TileEntityEnder.class, remap = false) | ||
public abstract class AccelerateTileEntity_Mixin implements ITileEntityTickAcceleration { | ||
|
||
@Shadow | ||
private long lastUpdate; | ||
|
||
@Shadow | ||
public abstract void updateEntity(); | ||
|
||
@Unique | ||
private int NHUtilities$tickAcceleratedRate = 1; | ||
|
||
@Override | ||
public int getTickAcceleratedRate() { | ||
return this.NHUtilities$tickAcceleratedRate; | ||
} | ||
|
||
@Override | ||
public boolean tickAcceleration(int tickAcceleratedRate) { | ||
this.NHUtilities$tickAcceleratedRate = tickAcceleratedRate; | ||
for (int i = 0; i < tickAcceleratedRate; i++) { | ||
this.lastUpdate = -1L; // make sure updateEntity() be called | ||
this.updateEntity(); | ||
} | ||
return true; | ||
} | ||
} |