Merge pull request #229 from ceceayo/screw-drivers
Fix bug where screwdriver invalidly casts all blockentities to TFMGPipeBlockEntity
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.drmangotea.tfmg.content.items;
|
package com.drmangotea.tfmg.content.items;
|
||||||
|
|
||||||
import com.drmangotea.tfmg.content.decoration.pipes.TFMGPipeBlockEntity;
|
import com.drmangotea.tfmg.content.decoration.pipes.TFMGPipeBlockEntity;
|
||||||
import com.drmangotea.tfmg.content.engines.base.AbstractEngineBlockEntity;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
@@ -24,17 +23,13 @@ public class ScrewdriverItem extends Item {
|
|||||||
|
|
||||||
Level level = pContext.getLevel();
|
Level level = pContext.getLevel();
|
||||||
|
|
||||||
if(level.getBlockEntity(positionClicked) instanceof AbstractEngineBlockEntity){
|
if (level.getBlockEntity(positionClicked) != null && level.getBlockEntity(positionClicked) instanceof TFMGPipeBlockEntity pipeBlockEntity) {
|
||||||
|
pipeBlockEntity.toggleLock(player);
|
||||||
|
|
||||||
|
|
||||||
return super.useOn(pContext);
|
|
||||||
}
|
|
||||||
if(level.getBlockEntity(positionClicked)!=null) {
|
|
||||||
((TFMGPipeBlockEntity) level.getBlockEntity(positionClicked)).toggleLock(player);
|
|
||||||
pContext.getItemInHand().hurtAndBreak(1, pContext.getPlayer(),
|
pContext.getItemInHand().hurtAndBreak(1, pContext.getPlayer(),
|
||||||
LivingEntity.getSlotForHand(pContext.getHand()));
|
LivingEntity.getSlotForHand(pContext.getHand()));
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
} else {
|
||||||
|
return super.useOn(pContext);
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user