DeathChests/src/main/java/lostcave/deathchests/block/BlockDeathChest.java

116 lines
3.4 KiB
Java

package lostcave.deathchests.block;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEnderChest;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.InventoryEnderChest;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEnderChest;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
public class BlockDeathChest extends BlockEnderChest {
private static final BlockDeathChest instance = new BlockDeathChest();
public static BlockDeathChest getInstance() {
return instance;
}
private BlockDeathChest() {
super();
this.setBlockName("death_chest");
this.disableStats();
this.setBlockUnbreakable();
// same value as bedrock
this.setResistance(6000000.0F);
}
@Override
protected boolean canSilkHarvest() {
return false;
}
@Override
public boolean canDropFromExplosion(Explosion p_149659_1_) {
return false;
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return null;
}
/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
if (world.isRemote) return true;
TileDeathChest tiledeathchest = (TileDeathChest) world.getTileEntity(x, y, z);
if (tiledeathchest != null) {
//TODO: check if appropriate player
//TODO: drop items
return true;
} else return true;
}
/**
* Called when a player hits the block. Args: world, x, y, z, player
*/
@Override
public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {
//TODO
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the
* block.
*/
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileDeathChest();
}
/**
* A randomly called display update to be able to add particles or other items
* for display
* <br />
* <br/>
* This is here to disable the particles that would otherwise be emitted
*/
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_) {
this.blockIcon = p_149651_1_.registerIcon("cobblestone");
}
public static class TileDeathChest extends TileEntity {
//TODO
}
//TODO: Custom texture? (optional)
//TODO: add chest inventory
//TODO: drop chest contents
//TODO: Remove chest when empty
//TODO: make unable to break by explosion (configurable?)
//TODO: Make it so items can only be taken out of the chest?
// Custom GUI? Maybe remove GUI altogether and have it drop the items when broken?
}