Skip to content

Commit

Permalink
adapting to eio machine
Browse files Browse the repository at this point in the history
  • Loading branch information
Keriils committed Sep 3, 2024
1 parent 7886bfd commit bdd3a0e
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
- ✔ 移植类似高版本暴食魔符 -> 暴食指环 以及 饥饿指环(大雾/。。)
- ✔ 移植了高版本的时间瓶 默认支持加速GT机器 请不要按住shift加速 具体看tooltips详细说明
- ✔ 默认修改EnderIo 谐振电容库 与能量注入仪的问题(秒充)
- ✔ 默认魔改创世神mod ExU兼容的工具 即 治愈之斧也可以当小木斧用 可以在配置文件下关闭
- ✔ 默认魔改创世神mod ExU兼容的工具 即 治愈之斧也可以当小木斧用 可以在配置文件下关闭
- ✔ 默认修改时间瓶子支持加速EnderIO机器 同时加速eio机器接收能量的速率
- × 等待新想法中..



Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ public interface ITileEntityTickAcceleration {
*/
boolean tickAcceleration(int tickAcceleratedRate);

/**
* adaptation to other aspects of the tileEntity
*/
default int getTickAcceleratedRate() {
return 1;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/xir/NHUtilities/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");

}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/xir/NHUtilities/mixins/Mixins.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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),

;

Expand All @@ -39,6 +44,7 @@ private enum Category {
BaseMetaTileEntityAcceleration(enableAccelerateGregTechMachine),
ModifyCapBankMaxIO(enableModifyEnderIoCapBankIO),
WEToolWithExuHealingAxe(enableWEToolWithExuHealingAxe),
ToAccelerateEnderIoMachine(enableAccelerateEnderIoMachine),

;

Expand Down
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();
}
}
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;
}
}

0 comments on commit bdd3a0e

Please sign in to comment.