You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
5.2 KiB
Java
179 lines
5.2 KiB
Java
package net.minecraft.block;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import java.util.Random;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.inventory.InventoryEnderChest;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.tileentity.TileEntityEnderChest;
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockEnderChest extends BlockContainer
|
|
{
|
|
private static final String __OBFID = "CL_00000238";
|
|
|
|
protected BlockEnderChest()
|
|
{
|
|
super(Material.rock);
|
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
|
}
|
|
|
|
/**
|
|
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
|
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
|
*/
|
|
public boolean isOpaqueCube()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
|
*/
|
|
public boolean renderAsNormalBlock()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* The type of render function that is called for this block
|
|
*/
|
|
public int getRenderType()
|
|
{
|
|
return 22;
|
|
}
|
|
|
|
public Item getItemDropped(int meta, Random random, int fortune)
|
|
{
|
|
return Item.getItemFromBlock(Blocks.obsidian);
|
|
}
|
|
|
|
/**
|
|
* Returns the quantity of items to drop on block destruction.
|
|
*/
|
|
public int quantityDropped(Random random)
|
|
{
|
|
return 8;
|
|
}
|
|
|
|
/**
|
|
* Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
|
|
*/
|
|
protected boolean canSilkHarvest()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Called when the block is placed in the world.
|
|
*/
|
|
public void onBlockPlacedBy(World worldIn, int x, int y, int z, EntityLivingBase placer, ItemStack itemIn)
|
|
{
|
|
byte b0 = 0;
|
|
int l = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
|
|
|
if (l == 0)
|
|
{
|
|
b0 = 2;
|
|
}
|
|
|
|
if (l == 1)
|
|
{
|
|
b0 = 5;
|
|
}
|
|
|
|
if (l == 2)
|
|
{
|
|
b0 = 3;
|
|
}
|
|
|
|
if (l == 3)
|
|
{
|
|
b0 = 4;
|
|
}
|
|
|
|
worldIn.setBlockMetadataWithNotify(x, y, z, b0, 2);
|
|
}
|
|
|
|
/**
|
|
* Called upon block activation (right click on the block.)
|
|
*/
|
|
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ)
|
|
{
|
|
InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest();
|
|
TileEntityEnderChest tileentityenderchest = (TileEntityEnderChest)worldIn.getTileEntity(x, y, z);
|
|
|
|
if (inventoryenderchest != null && tileentityenderchest != null)
|
|
{
|
|
if (worldIn.getBlock(x, y + 1, z).isNormalCube())
|
|
{
|
|
return true;
|
|
}
|
|
else if (worldIn.isRemote)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
inventoryenderchest.func_146031_a(tileentityenderchest);
|
|
player.displayGUIChest(inventoryenderchest);
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
|
*/
|
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
|
{
|
|
return new TileEntityEnderChest();
|
|
}
|
|
|
|
/**
|
|
* A randomly called display update to be able to add particles or other items for display
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public void randomDisplayTick(World worldIn, int x, int y, int z, Random random)
|
|
{
|
|
for (int l = 0; l < 3; ++l)
|
|
{
|
|
double d6 = (double)((float)x + random.nextFloat());
|
|
double d1 = (double)((float)y + random.nextFloat());
|
|
d6 = (double)((float)z + random.nextFloat());
|
|
double d3 = 0.0D;
|
|
double d4 = 0.0D;
|
|
double d5 = 0.0D;
|
|
int i1 = random.nextInt(2) * 2 - 1;
|
|
int j1 = random.nextInt(2) * 2 - 1;
|
|
d3 = ((double)random.nextFloat() - 0.5D) * 0.125D;
|
|
d4 = ((double)random.nextFloat() - 0.5D) * 0.125D;
|
|
d5 = ((double)random.nextFloat() - 0.5D) * 0.125D;
|
|
double d2 = (double)z + 0.5D + 0.25D * (double)j1;
|
|
d5 = (double)(random.nextFloat() * 1.0F * (float)j1);
|
|
double d0 = (double)x + 0.5D + 0.25D * (double)i1;
|
|
d3 = (double)(random.nextFloat() * 1.0F * (float)i1);
|
|
worldIn.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
|
|
}
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister reg)
|
|
{
|
|
this.blockIcon = reg.registerIcon("obsidian");
|
|
}
|
|
} |