Exploding GT machines now drop randomly some of their crafting components.
This commit is contained in:
parent
2abfaa0fc6
commit
14304fceb8
2 changed files with 31 additions and 23 deletions
|
@ -1092,7 +1092,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doExplosion(long aAmount) {
|
public void doExplosion(long aAmount) {
|
||||||
System.out.println("doExplosion");
|
|
||||||
if (canAccessData()) {
|
if (canAccessData()) {
|
||||||
// This is only for Electric Machines
|
// This is only for Electric Machines
|
||||||
if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) {
|
if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) {
|
||||||
|
@ -1105,36 +1104,45 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
||||||
// Normal Explosion Code
|
// Normal Explosion Code
|
||||||
mMetaTileEntity.onExplosion();
|
mMetaTileEntity.onExplosion();
|
||||||
if(GT_Mod.gregtechproxy.mExplosionItemDrop){
|
if(GT_Mod.gregtechproxy.mExplosionItemDrop){
|
||||||
Random tRandom = new Random();
|
|
||||||
for (int i = 0; i < this.getSizeInventory(); i++) {
|
for (int i = 0; i < this.getSizeInventory(); i++) {
|
||||||
ItemStack tItem = this.getStackInSlot(i);
|
ItemStack tItem = this.getStackInSlot(i);
|
||||||
System.out.println("getInventory: "+i);
|
|
||||||
if ((tItem != null) && (tItem.stackSize > 0) && (this.isValidSlot(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()));
|
dropItems(tItem);
|
||||||
if (tItem.hasTagCompound()) {
|
this.setInventorySlotContents(i, null); }
|
||||||
tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
|
}
|
||||||
}
|
}
|
||||||
tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D);
|
if (mRecipeStuff != null) {
|
||||||
tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D);
|
for (int i = 0; i < 9; i++) {
|
||||||
tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D);
|
if (this.getRandomNumber(100) < 50) {
|
||||||
tItemEntity.hurtResistantTime = 999999;
|
dropItems(GT_Utility.loadItem(mRecipeStuff, "Ingredient." + i));
|
||||||
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);
|
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
|
@Override
|
||||||
public ArrayList<ItemStack> getDrops() {
|
public ArrayList<ItemStack> getDrops() {
|
||||||
ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID);
|
ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID);
|
||||||
|
|
|
@ -486,7 +486,7 @@ public class GT_Achievements {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemData data = GT_OreDictUnificator.getItemData(stack);
|
ItemData data = GT_OreDictUnificator.getItemData(stack);
|
||||||
if (data != null) {
|
if (data != null && data.mPrefix!=null) {
|
||||||
if (data.mPrefix == OrePrefixes.dust) {
|
if (data.mPrefix == OrePrefixes.dust) {
|
||||||
if (data.mMaterial.mMaterial == Materials.Lutetium) {
|
if (data.mMaterial.mMaterial == Materials.Lutetium) {
|
||||||
issueAchievement(player, "newmetal");
|
issueAchievement(player, "newmetal");
|
||||||
|
|
Loading…
Reference in a new issue