Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package neg2013.acsension.machine;
- import cofh.api.energy.EnergyStorage;
- import cofh.api.energy.IEnergyHandler;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import neg2013.acsension.Acsension;
- import neg2013.acsension.reference.GuiID;
- import neg2013.acsension.tile_entity.TECrusher;
- import neg2013.acsension.tile_entity.TEDecomp;
- import net.minecraft.block.Block;
- import net.minecraft.block.ITileEntityProvider;
- import net.minecraft.block.material.Material;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.entity.item.EntityItem;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.IIcon;
- import net.minecraft.world.World;
- import net.minecraftforge.common.util.ForgeDirection;
- public class BlockDecomposer extends Block implements ITileEntityProvider, IEnergyHandler{
- public BlockDecomposer(Material material) {
- super(material);
- // TODO Auto-generated constructor stub
- }
- @SideOnly(Side.CLIENT)
- private IIcon field_150035_a;
- @SideOnly(Side.CLIENT)
- private IIcon field_150034_b;
- @SideOnly(Side.CLIENT)
- private IIcon field_150034_c;
- protected EnergyStorage energyStorage = new EnergyStorage(512);
- //protected List<ForgeDirection> recieveSides = new ArrayList<ForgeDirection>();
- // protected List<ForgeDirection> extractSides = new ArrayList<Object>();
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int side, int met)
- {
- return side == 1 ? this.field_150035_a : (side == 0 ? field_150034_c : (side != 2 && side != 4 ? this.blockIcon : this.field_150034_b));
- }
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister p_149651_1_)
- {
- this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_decomposer_side");
- this.field_150035_a = p_149651_1_.registerIcon(this.getTextureName() + "_top");
- this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_decomposer_side");
- this.field_150034_c = p_149651_1_.registerIcon(this.getTextureName() + "_bottum");
- // this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_crusher_front");
- }
- @Override
- public TileEntity createNewTileEntity(World world, int i) {
- return new TEDecomp();
- }
- @Override
- public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float subx, float suby, float subz) {
- if(world.isRemote){
- if(player.isSneaking()){
- return false;
- }
- else{
- player.openGui(Acsension.instance, GuiID.DECOMP_BASED_ID, world, x, y, z);
- return true;
- }
- }
- return true;
- }
- @Override
- public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
- TileEntity entity = world.getTileEntity(x, y, z);
- if(entity != null && entity instanceof IInventory){
- IInventory inventory = (IInventory) entity;
- for(int i = 0; i > inventory.getSizeInventory(); i++){
- ItemStack itemstack = inventory.getStackInSlotOnClosing(i);
- if(itemstack != null){
- float spawnX = x + world.rand.nextFloat();
- float spawnY = y + world.rand.nextFloat();
- float spawnZ = z + world.rand.nextFloat();
- EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, itemstack);
- float multi = 0.05f;
- droppedItem.motionX = -0.5f + world.rand.nextFloat() * multi;
- droppedItem.motionY = -0.5f + world.rand.nextFloat() * multi;
- droppedItem.motionZ = -0.5f + world.rand.nextFloat() * multi;
- world.spawnEntityInWorld(droppedItem);
- }
- }
- }
- super.breakBlock(world, x, y, z, block, meta);
- }
- @Override
- public boolean canConnectEnergy(ForgeDirection from) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
- // TODO Auto-generated method stub
- return 0;
- }
- @Override
- public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
- // TODO Auto-generated method stub
- return 0;
- }
- @Override
- public int getEnergyStored(ForgeDirection from) {
- // TODO Auto-generated method stub
- return 0;
- }
- @Override
- public int getMaxEnergyStored(ForgeDirection from) {
- // TODO Auto-generated method stub
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment