diff options
author | Maxim <maxim235@gmx.de> | 2022-10-22 11:38:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-22 11:38:49 +0200 |
commit | 4f72e6dd87a68fc9d93c3fe6cf6a38723e2566ed (patch) | |
tree | eb59e6beb30dc58c50398f3c598d1b9614bb5f7b /src/main | |
parent | e9ecca3f1aba7ef7ea5eaaea8b0baf8d1e7659c8 (diff) | |
download | GT5-Unofficial-4f72e6dd87a68fc9d93c3fe6cf6a38723e2566ed.tar.gz GT5-Unofficial-4f72e6dd87a68fc9d93c3fe6cf6a38723e2566ed.tar.bz2 GT5-Unofficial-4f72e6dd87a68fc9d93c3fe6cf6a38723e2566ed.zip |
Added check to API if the block should drop its inventory on break (#1479)
* Added check to API if the block should drop its inventory on break
* Apply spotless
* Changed should drop flag to take index argument
Diffstat (limited to 'src/main')
7 files changed, 38 insertions, 1 deletions
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index c9d23e1f71..29b0a56a89 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -216,6 +216,13 @@ public interface IMetaTileEntity */ boolean isValidSlot(int aIndex); + /** Check if the item at the specified index should be dropped + * + * @param index Index that will be checked + * @return True if the item at the index should be dropped, else false + */ + boolean shouldDropItemAt(int index); + /** * @return if aIndex can be set to Zero stackSize, when being removed. */ diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java index 253deae29b..ad2af44e9e 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java @@ -138,6 +138,13 @@ public interface IGregTechTileEntity ArrayList<ItemStack> getDrops(); + /** Check if the item at the specific index should be dropped or not + * + * @param index Index that will be checked + * @return True if it should drop, else false + */ + boolean shouldDropItemAt(int index); + /** * 255 = 100% */ diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 7c75bb97d4..87a865641f 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -782,6 +782,11 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity } @Override + public boolean shouldDropItemAt(int index) { + return this.mMetaTileEntity != null ? this.mMetaTileEntity.shouldDropItemAt(index) : true; + } + + @Override public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { if (isClientSide()) { // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 08ead9a946..ebf0672815 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1428,6 +1428,11 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity return new ArrayList<>(Collections.singletonList(rStack)); } + @Override + public boolean shouldDropItemAt(int index) { + return this.mMetaTileEntity != null ? this.mMetaTileEntity.shouldDropItemAt(index) : true; + } + public int getUpgradeCount() { return (mMuffler ? 1 : 0) + (mLockUpgrade ? 1 : 0) + (mSteamConverter ? 1 : 0) + mOtherUpgrades; } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 96cca4ba1d..105ec073ec 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -383,6 +383,11 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override + public boolean shouldDropItemAt(int index) { + return true; + } + + @Override public boolean setStackToZeroInsteadOfNull(int aIndex) { return false; } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 1e77057be9..5c8f1c33bb 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -482,6 +482,11 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override + public boolean shouldDropItemAt(int index) { + return true; + } + + @Override public boolean setStackToZeroInsteadOfNull(int aIndex) { return false; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index 7a1ae279c1..3aeb2f0a5e 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -414,7 +414,10 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo if (!(tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { final ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); - if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) { + if ((tItem != null) + && (tItem.stackSize > 0) + && (tGregTechTileEntity.isValidSlot(i)) + && tGregTechTileEntity.shouldDropItemAt(i)) { final EntityItem tItemEntity = new EntityItem( aWorld, aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, |