From ba03c4b52423ec5794714b69f0d19b1d2714267d Mon Sep 17 00:00:00 2001 From: BluSunrize Date: Tue, 3 Oct 2023 16:59:46 +0200 Subject: [PATCH] Fix potential crashes when supplying power to arc furnace or excavator with other mod's cables, closes #5716 --- changelog.md | 1 + .../common/blocks/multiblocks/logic/ExcavatorLogic.java | 3 ++- .../common/blocks/multiblocks/logic/LightningRodLogic.java | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 51c31a22fd..e2a43e5efc 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ ##### Version 1.19.4-9.4.1-pre - All features from 9.2.3 - Fix localization of perks on revolver parts (BluSunrize) +- Fix potential crashes when supplying power to arc furnace or excavator with other mod's cables (BluSunrize) ##### Version 1.19.2-9.2.3-167 - Change "Superior Weaponry" advancement to hint at its potential to spawn new illagers in raids (BluSunrize) diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/ExcavatorLogic.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/ExcavatorLogic.java index e44737ea74..d280f519b8 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/ExcavatorLogic.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/ExcavatorLogic.java @@ -56,6 +56,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; @@ -313,7 +314,7 @@ private boolean fillBucket( @Override public LazyOptional getCapability(IMultiblockContext ctx, CapabilityPosition position, Capability cap) { - if(position.side()==null||ENERGY_INPUTS.contains(position)) + if(cap==ForgeCapabilities.ENERGY&&(position.side()==null||ENERGY_INPUTS.contains(position))) return ctx.getState().energyCap.cast(ctx); return LazyOptional.empty(); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/LightningRodLogic.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/LightningRodLogic.java index 367a855b44..4a09ff3ffe 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/LightningRodLogic.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/LightningRodLogic.java @@ -145,7 +145,7 @@ public LazyOptional getCapability( { final State state = ctx.getState(); final BlockPos posInMultiblock = position.posInMultiblock(); - if(position.side()==null||(posInMultiblock.getY()==1&&(posInMultiblock.getX()+posInMultiblock.getZ())%2==1)) + if(cap==ForgeCapabilities.ENERGY&&(position.side()==null||(posInMultiblock.getY()==1&&(posInMultiblock.getX()+posInMultiblock.getZ())%2==1))) return ForgeCapabilities.ENERGY.orEmpty(cap, state.energyCap.get(ctx)); else return LazyOptional.empty();