diff --git a/src/main/java/xyz/illuc/neuralgiacore/NeuralgiaCoreMod.java b/src/main/java/xyz/illuc/neuralgiacore/NeuralgiaCoreMod.java index e6c700b..9f57a07 100644 --- a/src/main/java/xyz/illuc/neuralgiacore/NeuralgiaCoreMod.java +++ b/src/main/java/xyz/illuc/neuralgiacore/NeuralgiaCoreMod.java @@ -8,6 +8,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -27,6 +28,7 @@ import org.slf4j.Logger; import xyz.illuc.neuralgiacore.entities.OfflinePlayerEntity; import xyz.illuc.neuralgiacore.entities.OfflinePlayerRenderer; import xyz.illuc.neuralgiacore.peripherals.BearingPeripheral; +//import xyz.illuc.neuralgiacore.peripherals.GunPeripheral; import xyz.illuc.neuralgiacore.registers.RegisterItems; import xyz.illuc.neuralgiacore.registers.RegisterMedicalFluids; @@ -74,12 +76,15 @@ public class NeuralgiaCoreMod { event.enqueueWork(this::registerPeripherals); } + //TODO move peripheral stuff in a different file private void registerPeripherals() { registerBearingPeripheral("mechanical_bearing"); registerBearingPeripheral("clockwork_bearing"); registerBearingPeripheral("windmill_bearing"); + + registerGunPeripheral("machine_gun"); } private void registerBearingPeripheral(String blockEntityName) { @@ -109,6 +114,30 @@ public class NeuralgiaCoreMod { } } + private void registerGunPeripheral(String blockEntityName) { + BlockEntityType type = ForgeRegistries.BLOCK_ENTITY_TYPES.getValue( + new ResourceLocation("crusty_chunks", blockEntityName) + ); + + if (type != null) { + ForgeComputerCraftAPI.registerPeripheralProvider((level, pos, direction) -> { + var blockEntity = level.getBlockEntity(pos); + if (blockEntity != null && blockEntity.getType() == type) { + try { + //TODO gun peripheral + } catch (ClassCastException e) { + LOGGER.error("Failed to create peripheral at {}", pos); + return null; + } + } + return null; + }); + LOGGER.debug("Registered peripheral for {}", blockEntityName); + } else { + LOGGER.warn("Could not find block entity type: crusty_chunks:{}", blockEntityName); + } + } + diff --git a/src/main/java/xyz/illuc/neuralgiacore/mixin/Tfc/MixinDisableHealthModifier.java b/src/main/java/xyz/illuc/neuralgiacore/mixin/Tfc/MixinDisableHealthModifier.java new file mode 100644 index 0000000..c9e9301 --- /dev/null +++ b/src/main/java/xyz/illuc/neuralgiacore/mixin/Tfc/MixinDisableHealthModifier.java @@ -0,0 +1,15 @@ +package xyz.illuc.neuralgiacore.mixin.Tfc; + +import net.dries007.tfc.common.capabilities.food.TFCFoodData; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(TFCFoodData.class) +public class MixinDisableHealthModifier { + @Inject(method = "getHealthModifier", at = @At("HEAD"), cancellable = true, remap = false) + private void disableHealthModifier(CallbackInfoReturnable cir) { + cir.setReturnValue(1f); + } +} diff --git a/src/main/resources/neuralgiacore.mixins.json b/src/main/resources/neuralgiacore.mixins.json index 7ac77f8..6ba9988 100644 --- a/src/main/resources/neuralgiacore.mixins.json +++ b/src/main/resources/neuralgiacore.mixins.json @@ -15,6 +15,7 @@ "PrototypePain.MixinSepsis", "PrototypePain.MixinSickness", "PrototypePain.MixinSicknessOverlay", + "Tfc.MixinDisableHealthModifier", "Tfc.MixinFoodData", "Tfc.MixinHealthBar", "Tfc.MixinOptimizeClimateUpdate",