aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
authorBlood-Asp <bloodasphendrik@gmail.com>2016-10-13 22:26:10 +0200
committerTechnus <daniel112092@gmail.com>2016-10-14 11:07:12 +0200
commitc15fd5b8556c81514dbd2b3b014ca57bee0e7ba5 (patch)
treea9fb51313b65706c86cdf3c91d6d0ca681ae615b /src/main/java/gregtech/api/metatileentity
parente2b3a7dbb6631975c3898ceb8c609734c82d8a3a (diff)
downloadGT5-Unofficial-c15fd5b8556c81514dbd2b3b014ca57bee0e7ba5.tar.gz
GT5-Unofficial-c15fd5b8556c81514dbd2b3b014ca57bee0e7ba5.tar.bz2
GT5-Unofficial-c15fd5b8556c81514dbd2b3b014ca57bee0e7ba5.zip
drop items from exploding gt machines + config
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 23c72a2a03..fbfdb1a556 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -32,9 +32,11 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Random;
import static gregtech.api.enums.GT_Values.NW;
import static gregtech.api.enums.GT_Values.V;
@@ -1090,6 +1092,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public void doExplosion(long aAmount) {
+ System.out.println("doExplosion");
if (canAccessData()) {
// This is only for Electric Machines
if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) {
@@ -1101,6 +1104,33 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mReleaseEnergy = false;
// Normal Explosion Code
mMetaTileEntity.onExplosion();
+ if(GT_Mod.gregtechproxy.mExplosionItemDrop){
+ Random tRandom = new Random();
+ for (int i = 0; i < this.getSizeInventory(); i++) {
+ ItemStack tItem = this.getStackInSlot(i);
+ System.out.println("getInventory: "+i);
+ if ((tItem != null) && (tItem.stackSize > 0) && (this.isValidSlot(i))) {
+ EntityItem tItemEntity = new EntityItem(this.worldObj, this.xCoord + tRandom.nextFloat() * 0.8F + 0.1F, this.yCoord + tRandom.nextFloat() * 0.8F + 0.1F, this.zCoord + tRandom.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
+ if (tItem.hasTagCompound()) {
+ tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
+ }
+ tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D);
+ tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D);
+ tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D);
+ tItemEntity.hurtResistantTime = 999999;
+ tItemEntity.lifespan = 60000;
+ try {
+ Field tField = tItemEntity.getClass().getDeclaredField("health");
+ tField.setAccessible(true);
+ tField.setInt(tItemEntity, 99999999);
+ } catch (Exception e) {e.printStackTrace();}
+ this.worldObj.spawnEntityInWorld(tItemEntity);
+ System.out.println("spawnItem: "+tItemEntity.getEntityItem().getDisplayName());
+ tItem.stackSize = 0;
+ this.setInventorySlotContents(i, null);
+ }
+ }
+ }
mMetaTileEntity.doExplosion(aAmount);
}
}