mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
#1585 Fix blocks not dropping in explosions
This commit is contained in:
1 parent
a2d1ff36e0
commit
0b3000cdec
3 files changed
+48
-42
No files matched your search
@@ -9,7 +9,6 @@ import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -224,24 +223,30 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
if(!world.isRemote && (!player.capabilities.isCreativeMode)) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity && shouldDropDefaultItem(world, player, x, y, z)) {
|
||||
AbstractMachineEntity machineEntity = (AbstractMachineEntity) te;
|
||||
int meta = damageDropped(world.getBlockMetadata(x, y, z));
|
||||
ItemStack itemStack = new ItemStack(this, 1, meta);
|
||||
machineEntity.writeToItemStack(itemStack);
|
||||
|
||||
float f = 0.7F;
|
||||
double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
dropAsItem(world, x, y, z, (AbstractMachineEntity) te);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
}
|
||||
return super.removedByPlayer(world, player, x, y, z, doHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
dropAsItem(world, x, y, z, (AbstractMachineEntity) te);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
private void dropAsItem(World world, int x, int y, int z, AbstractMachineEntity te) {
|
||||
AbstractMachineEntity machineEntity = (AbstractMachineEntity) te;
|
||||
int meta = damageDropped(world.getBlockMetadata(x, y, z));
|
||||
ItemStack itemStack = new ItemStack(this, 1, meta);
|
||||
machineEntity.writeToItemStack(itemStack);
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
|
||||
@@ -17,6 +17,7 @@ import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.api.tool.ITool;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
@@ -93,30 +94,36 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harvested) {
|
||||
if(!world.isRemote) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEnchanter) {
|
||||
TileEnchanter enchanter = (TileEnchanter) te;
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
float f = 0.7F;
|
||||
double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
|
||||
if(enchanter.getStackInSlot(0) != null) {
|
||||
Util.dropItems(world, enchanter.getStackInSlot(0), x, y, z, true);
|
||||
}
|
||||
if(enchanter.getStackInSlot(1) != null) {
|
||||
Util.dropItems(world, enchanter.getStackInSlot(1), x, y, z, true);
|
||||
}
|
||||
}
|
||||
if(te instanceof TileEnchanter && !player.capabilities.isCreativeMode) {
|
||||
dropAsItem(world, x, y, z, (TileEnchanter) te);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
}
|
||||
return super.removedByPlayer(world, player, x, y, z, harvested);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEnchanter) {
|
||||
dropAsItem(world, x, y, z, (TileEnchanter) te);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
private void dropAsItem(World world, int x, int y, int z, TileEnchanter te) {
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
|
||||
if(te.getStackInSlot(0) != null) {
|
||||
Util.dropItems(world, te.getStackInSlot(0), x, y, z, true);
|
||||
}
|
||||
if(te.getStackInSlot(1) != null) {
|
||||
Util.dropItems(world, te.getStackInSlot(1), x, y, z, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random p_149745_1_) {
|
||||
return 0;
|
||||
@@ -154,13 +161,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
|
||||
return getUnlocalizedName();
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ItemUtil {
|
||||
ItemStack contents = sidedInv.getStackInSlot(slot);
|
||||
ItemStack toInsert = item.copy();
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, sidedInv.getInventoryStackLimit());
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, toInsert.getMaxStackSize()); // some inventories like filing cap
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, toInsert.getMaxStackSize()); // some inventories like using itemstacks with invalid stack sizes
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, numToInsert);
|
||||
int inserted = 0;
|
||||
if(contents == null) {
|
||||
@@ -127,7 +127,7 @@ public class ItemUtil {
|
||||
if(!isStackFull(contents)) {
|
||||
ItemStack toInsert = item.copy();
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, inv.getInventoryStackLimit());
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, toInsert.getMaxDamage()); // some inventories like filing cap
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, toInsert.getMaxDamage()); // some inventories like using itemstacks with invalid stack sizes
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, numToInsert);
|
||||
int inserted = 0;
|
||||
if(contents == null) {
|
||||
|
||||
Reference in new issue
Block a user