diff --git a/README.md b/README.md index 2a75d6e..5147805 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,9 @@ - ✔ 移植类似高版本暴食魔符 -> 暴食指环 以及 饥饿指环(大雾/。。) - ✔ 移植了高版本的时间瓶 默认支持加速GT机器 请不要按住shift加速 具体看tooltips详细说明 - ✔ 默认修改EnderIo 谐振电容库 与能量注入仪的问题(秒充) - - ✔ 默认魔改创世神mod ExU兼容的工具 即 治愈之斧也可以当小木斧用 可以在配置文件下关闭 + - ✔ 默认魔改创世神mod ExU兼容的工具 即 治愈之斧也可以当小木斧用 可以在配置文件下关闭 + - ✔ 默认修改时间瓶子支持加速EnderIO机器 同时加速eio机器接收能量的速率 - × 等待新想法中.. - + diff --git a/src/main/java/com/xir/NHUtilities/common/api/ITileEntityTickAcceleration.java b/src/main/java/com/xir/NHUtilities/common/api/ITileEntityTickAcceleration.java index 5e7a6f0..7df2c54 100644 --- a/src/main/java/com/xir/NHUtilities/common/api/ITileEntityTickAcceleration.java +++ b/src/main/java/com/xir/NHUtilities/common/api/ITileEntityTickAcceleration.java @@ -13,4 +13,10 @@ public interface ITileEntityTickAcceleration { */ boolean tickAcceleration(int tickAcceleratedRate); + /** + * adaptation to other aspects of the tileEntity + */ + default int getTickAcceleratedRate() { + return 1; + } } diff --git a/src/main/java/com/xir/NHUtilities/config/Config.java b/src/main/java/com/xir/NHUtilities/config/Config.java index 463bc2a..df06267 100644 --- a/src/main/java/com/xir/NHUtilities/config/Config.java +++ b/src/main/java/com/xir/NHUtilities/config/Config.java @@ -41,6 +41,7 @@ public class Config { public static boolean enableEnhancedTeleporterMKII = true; public static boolean enableModifyEnderIoCapBankIO = true; public static boolean enableWEToolWithExuHealingAxe = true; + public static boolean enableAccelerateEnderIoMachine = true; public static String[] listeningMods = new String[] { "NHUtilities", "TwistSpaceTechnology", "boxplusplus", "programmablehatches" }; // endregion @@ -157,6 +158,11 @@ static File minecraftHome() { CATEGORY_MIXIN_CONFIG, enableWEToolWithExuHealingAxe, "enable WE Tool With Exu Healing Axe"); + enableAccelerateEnderIoMachine = configuration.getBoolean( + "enableAccelerateEnderIoMachine", + CATEGORY_MIXIN_CONFIG, + enableAccelerateEnderIoMachine, + "enable Accelerate EnderIO Machine"); } diff --git a/src/main/java/com/xir/NHUtilities/mixins/Mixins.java b/src/main/java/com/xir/NHUtilities/mixins/Mixins.java index 73542fa..663d968 100644 --- a/src/main/java/com/xir/NHUtilities/mixins/Mixins.java +++ b/src/main/java/com/xir/NHUtilities/mixins/Mixins.java @@ -1,5 +1,6 @@ package com.xir.NHUtilities.mixins; +import static com.xir.NHUtilities.config.Config.enableAccelerateEnderIoMachine; import static com.xir.NHUtilities.config.Config.enableAccelerateGregTechMachine; import static com.xir.NHUtilities.config.Config.enableEnhancedTeleporterMKII; import static com.xir.NHUtilities.config.Config.enableModifyEnderIoCapBankIO; @@ -30,6 +31,10 @@ public enum Mixins { "EnderIO.Modify_CapBankMaxIO_Mixin", TargetMod.EnderIO), WE_ModifyWithExuHealingAxe_Mixin(Category.WEToolWithExuHealingAxe, Side.BOTH, Phase.LATE, "WorldEditGtnh.ModifyWEWithExU", TargetMod.WorldEdit, TargetMod.ExtraUtilities), + EnderIO_AccelerateTileEntity_Mixin(Category.ToAccelerateEnderIoMachine, Side.BOTH, Phase.LATE, + "EnderIO.AccelerateTileEntity_Mixin", TargetMod.EnderIO), + EnderIO_AccelerateEnergyRecive_Mixin(Category.ToAccelerateEnderIoMachine, Side.BOTH, Phase.LATE, + "EnderIO.AccelerateEnergyRecive_Mixin", TargetMod.EnderIO), ; @@ -39,6 +44,7 @@ private enum Category { BaseMetaTileEntityAcceleration(enableAccelerateGregTechMachine), ModifyCapBankMaxIO(enableModifyEnderIoCapBankIO), WEToolWithExuHealingAxe(enableWEToolWithExuHealingAxe), + ToAccelerateEnderIoMachine(enableAccelerateEnderIoMachine), ; diff --git a/src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateEnergyRecive_Mixin.java b/src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateEnergyRecive_Mixin.java new file mode 100644 index 0000000..34b762d --- /dev/null +++ b/src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateEnergyRecive_Mixin.java @@ -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(); + } +} diff --git a/src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateTileEntity_Mixin.java b/src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateTileEntity_Mixin.java new file mode 100644 index 0000000..d17fcb8 --- /dev/null +++ b/src/main/java/com/xir/NHUtilities/mixins/late/EnderIO/AccelerateTileEntity_Mixin.java @@ -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; + } +}