From 41f484d6c59bbb14b80bd904a0c0b6195ec1f70f Mon Sep 17 00:00:00 2001 From: Jesse <133413@hondsrugcollege.nl> Date: Sun, 17 Aug 2025 15:17:16 +0200 Subject: [PATCH] Fix bug where screwdriver invalidly casts all blockentities to TFMGPipeBlockEntity --- .../tfmg/content/items/ScrewdriverItem.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/drmangotea/tfmg/content/items/ScrewdriverItem.java b/src/main/java/com/drmangotea/tfmg/content/items/ScrewdriverItem.java index 177e93fe..e2293c4d 100644 --- a/src/main/java/com/drmangotea/tfmg/content/items/ScrewdriverItem.java +++ b/src/main/java/com/drmangotea/tfmg/content/items/ScrewdriverItem.java @@ -1,7 +1,6 @@ package com.drmangotea.tfmg.content.items; import com.drmangotea.tfmg.content.decoration.pipes.TFMGPipeBlockEntity; -import com.drmangotea.tfmg.content.engines.base.AbstractEngineBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; @@ -24,17 +23,13 @@ public class ScrewdriverItem extends Item { Level level = pContext.getLevel(); - if(level.getBlockEntity(positionClicked) instanceof AbstractEngineBlockEntity){ - - - - return super.useOn(pContext); - } - if(level.getBlockEntity(positionClicked)!=null) { - ((TFMGPipeBlockEntity) level.getBlockEntity(positionClicked)).toggleLock(player); + if (level.getBlockEntity(positionClicked) != null && level.getBlockEntity(positionClicked) instanceof TFMGPipeBlockEntity pipeBlockEntity) { + pipeBlockEntity.toggleLock(player); pContext.getItemInHand().hurtAndBreak(1, pContext.getPlayer(), LivingEntity.getSlotForHand(pContext.getHand())); + return InteractionResult.SUCCESS; + } else { + return super.useOn(pContext); } - return InteractionResult.SUCCESS; } } \ No newline at end of file