diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2023-03-24 18:37:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-24 11:37:58 +0100 |
commit | 2ab22537fcb12a30858bdaf825d2a396211b34d5 (patch) | |
tree | e66b85dd0d4daf6b0cfbc41e7258ed912cfdf567 | |
parent | 0f9bb4c7e7de592e960dcc68544b7f881d6190ba (diff) | |
download | GT5-Unofficial-2ab22537fcb12a30858bdaf825d2a396211b34d5.tar.gz GT5-Unofficial-2ab22537fcb12a30858bdaf825d2a396211b34d5.tar.bz2 GT5-Unofficial-2ab22537fcb12a30858bdaf825d2a396211b34d5.zip |
clean up hand pump code (#577)
* clean up hand pump code
* spotlessApply (#578)
Co-authored-by: GitHub GTNH Actions <>
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
-rw-r--r-- | src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java | 6 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java | 107 |
2 files changed, 5 insertions, 108 deletions
diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index eed1fe42a3..9fb570d86c 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -42,6 +42,7 @@ import gregtech.api.interfaces.IItemContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; import gregtech.api.objects.ItemData; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; @@ -1067,6 +1068,8 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri PlayerUtils.messagePlayer( aPlayer, "Drained " + mAmountInserted + "L of " + aStored.getLocalizedName() + "."); + } else { + drain(aStack, mAmountInserted); } return b; } @@ -1214,7 +1217,8 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return null; } final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();; - if (aMetaTileEntity == null) { + if (aMetaTileEntity == null || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MultiInput) { + // blacklist multiinput hatch as it's too complex return null; } if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java deleted file mode 100644 index 1504b45d8e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java +++ /dev/null @@ -1,107 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.items.types; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; - -public class ToolType_Pump extends ToolType_Base { - - private final int mCosts; - private final String mTooltip = GT_LanguageManager - .addStringLocalization("gt.behaviour.pump", "Sucks in Machine Input Fluid tank contents on Rightclick"); - - public ToolType_Pump(final int aCosts) { - this.mCosts = aCosts; - } - - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, - final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, - final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); - final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - /* - * try { if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { if (((IWrenchable) - * aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { if ((aPlayer.capabilities.isCreativeMode) || - * (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { ((IWrenchable) - * aTileEntity).setFacing(aTargetSide); GT_Utility.sendSoundToPlayers(aWorld, - * GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); } return true; } if - * (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { final int tDamage = ((IWrenchable) - * aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; if ((aPlayer.capabilities.isCreativeMode) || - * (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { ItemStack tOutput = - * ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, - * aY, aZ, aMeta, 0)) { if (tOutput == null) { aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + - * 0.5D, aZ + 0.5D, tStack)); } else { aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ - * + 0.5D, tOutput)); tOutput = null; } } aWorld.setBlockToAir(aX, aY, aZ); - * GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, - * aZ); } return true; } return true; } } catch (final Throwable e) { } if ((aBlock == Blocks.log) || (aBlock == - * Blocks.log2) || (aBlock == Blocks.hay_block)) { if ((aPlayer.capabilities.isCreativeMode) || - * (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { aWorld.setBlockMetadataWithNotify(aX, aY, - * aZ, (aMeta + 4) % 12, 3); GT_Utility.sendSoundToPlayers(aWorld, - * GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); } return true; } if ((aBlock == - * Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { if - * ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - * aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - * GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, - * aZ); } return true; } if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { - * if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) - * { aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - * GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, - * aZ); } return true; } if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { if - * ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - * aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, - * aMeta))); aWorld.setBlockToAir(aX, aY, aZ); GT_Utility.sendSoundToPlayers(aWorld, - * GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); } return true; } if (aMeta == - * aTargetSide) { if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) - * || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock - * == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == - * Blocks.trapped_chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.hopper)) { if - * ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - * aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, - * 0))); aWorld.setBlockToAir(aX, aY, aZ); GT_Utility.sendSoundToPlayers(aWorld, - * GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); } return true; } } else { if - * ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == - * Blocks.dropper)) { if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) - * aItem).doDamage(aStack, this.mCosts)))) { aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - * GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, - * aZ); } return true; } if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == - * Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == - * Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { if ((aTargetSide > 1) && - * ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - * aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); GT_Utility.sendSoundToPlayers(aWorld, - * GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); } return true; } if (aBlock == - * Blocks.hopper) { if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) || - * (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { aWorld.setBlockMetadataWithNotify(aX, aY, - * aZ, aTargetSide, 3); GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), - * 1.0F, -1.0F, aX, aY, aZ); } return true; } } if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, - * aZ)).contains(ForgeDirection.getOrientation(aTargetSide))) && ((aPlayer.capabilities.isCreativeMode) || - * (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) && - * (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { if - * (!aPlayer.capabilities.isCreativeMode) { ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); } - * GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, - * aZ); } - */ - return false; - } - - public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, - final ItemStack aStack) { - aList.add(this.mTooltip); - return aList; - } -} |