aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBlood-Asp <bloodasphendrik@gmail.com>2016-10-17 12:37:13 +0200
committerBlood-Asp <bloodasphendrik@gmail.com>2016-10-17 12:37:13 +0200
commita6301759b11c9b8b59f470f97ac5921490358bdd (patch)
tree509dd7257ac7931475580864cd39c086844b0240 /src/main
parent637f704235a1b278509df5aee095834679ded003 (diff)
downloadGT5-Unofficial-a6301759b11c9b8b59f470f97ac5921490358bdd.tar.gz
GT5-Unofficial-a6301759b11c9b8b59f470f97ac5921490358bdd.tar.bz2
GT5-Unofficial-a6301759b11c9b8b59f470f97ac5921490358bdd.zip
Exploding GT machines now drop randomly some of their crafting components.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java52
-rw-r--r--src/main/java/gregtech/loaders/misc/GT_Achievements.java2
2 files changed, 31 insertions, 23 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 1272eb8fd8..e94abc0050 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -1091,7 +1091,6 @@ 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()) {
@@ -1104,35 +1103,44 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
// 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);
+ dropItems(tItem);
+ this.setInventorySlotContents(i, null); }
+ }
+ }
+ if (mRecipeStuff != null) {
+ for (int i = 0; i < 9; i++) {
+ if (this.getRandomNumber(100) < 50) {
+ dropItems(GT_Utility.loadItem(mRecipeStuff, "Ingredient." + i));
}
- }
+ }
}
mMetaTileEntity.doExplosion(aAmount);
}
}
+
+ public void dropItems(ItemStack tItem){
+ if(tItem==null)return;
+ Random tRandom = new Random();
+ 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);
+ tItem.stackSize = 0;
+ }
@Override
public ArrayList<ItemStack> getDrops() {
diff --git a/src/main/java/gregtech/loaders/misc/GT_Achievements.java b/src/main/java/gregtech/loaders/misc/GT_Achievements.java
index 56cb0736a3..627b01d9a9 100644
--- a/src/main/java/gregtech/loaders/misc/GT_Achievements.java
+++ b/src/main/java/gregtech/loaders/misc/GT_Achievements.java
@@ -488,7 +488,7 @@ public class GT_Achievements {
return;
}
ItemData data = GT_OreDictUnificator.getItemData(stack);
- if (data != null) {
+ if (data != null && data.mPrefix!=null) {
if (data.mPrefix == OrePrefixes.dust) {
if (data.mMaterial.mMaterial == Materials.Lutetium) {
issueAchievement(player, "newmetal");