mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 15:03:07 +00:00
1 parent
583121f2be
commit
b1efc0d8fe
5 files changed
+19
-82
No files matched your search
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -70,11 +72,6 @@ public abstract class BlockEio extends Block {
|
||||
blockIcon = iIconRegister.registerIcon("enderio:" + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return doNormalDrops(world, x, y, z) ? super.getDrops(world, x, y, z, metadata, fortune) : new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
/* Subclass Helpers */
|
||||
|
||||
@Override
|
||||
@@ -114,34 +111,32 @@ public abstract class BlockEio extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean doHarvest) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEntityEio && ((TileEntityEio) te).shouldDrop()) {
|
||||
if(!world.isRemote && !player.capabilities.isCreativeMode && !doNormalDrops(world, x, y, z)) {
|
||||
dropAsItem(world, x, y, z, (TileEntityEio) te);
|
||||
((TileEntityEio) te).preventDrops();
|
||||
} else if(player.capabilities.isCreativeMode) {
|
||||
((TileEntityEio) te).preventDrops();
|
||||
}
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
if(willHarvest) {
|
||||
return true;
|
||||
}
|
||||
return super.removedByPlayer(world, player, x, y, z, false);
|
||||
return super.removedByPlayer(world, player, x, y, z, willHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
|
||||
super.harvestBlock(world, player, x, y, z, meta);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
@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 TileEntityEio && ((TileEntityEio) te).shouldDrop() && !doNormalDrops(world, x, y, z)) {
|
||||
dropAsItem(world, x, y, z, (TileEntityEio) te);
|
||||
((TileEntityEio)te).preventDrops();
|
||||
public final ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
if(doNormalDrops(world, x, y, z)) {
|
||||
return super.getDrops(world, x, y, z, metadata, fortune);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
return Lists.newArrayList(getNBTDrop(world, x, y, z, (TileEntityEio) world.getTileEntity(x, y, z)));
|
||||
}
|
||||
|
||||
public void dropAsItem(World world, int x, int y, int z, TileEntityEio te) {
|
||||
|
||||
public ItemStack getNBTDrop(World world, int x, int y, int z, TileEntityEio te) {
|
||||
int meta = damageDropped(te.getBlockMetadata());
|
||||
ItemStack itemStack = new ItemStack(this, 1, meta);
|
||||
processDrop(world, x, y, z, te, itemStack);
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
protected void processDrop(World world, int x, int y, int z, @Nullable TileEntityEio te, ItemStack drop) {
|
||||
|
||||
Reference in new issue
Block a user