2013-06-07 21:36:52 +00:00
|
|
|
package biomesoplenty.blocks;
|
|
|
|
|
2013-06-07 23:40:48 +00:00
|
|
|
import java.util.ArrayList;
|
2013-06-07 21:36:52 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2013-06-15 08:46:50 +00:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2013-06-07 21:36:52 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
2013-06-15 08:46:50 +00:00
|
|
|
import net.minecraft.item.ItemPickaxe;
|
2013-06-07 21:36:52 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.Icon;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import biomesoplenty.BiomesOPlenty;
|
|
|
|
import biomesoplenty.api.Blocks;
|
|
|
|
import biomesoplenty.api.Items;
|
2013-06-08 07:04:09 +00:00
|
|
|
import biomesoplenty.blocks.renderers.RenderUtils;
|
2013-07-03 07:51:39 +00:00
|
|
|
import biomesoplenty.tileentities.TileEntityAltar;
|
2013-06-07 21:36:52 +00:00
|
|
|
|
|
|
|
public class BlockAltar extends Block
|
|
|
|
{
|
|
|
|
private static final String[] altarTypes = new String[] {"altarframe"};
|
|
|
|
|
|
|
|
public static Icon altarFrame;
|
|
|
|
public static Icon altarFrameTop;
|
|
|
|
|
|
|
|
public static Icon frameApatite;
|
|
|
|
public static Icon framePeridot;
|
|
|
|
public static Icon frameRuby;
|
|
|
|
public static Icon frameSapphire;
|
|
|
|
public static Icon frameTanzanite;
|
|
|
|
public static Icon frameTopaz;
|
|
|
|
|
|
|
|
public BlockAltar(int blockID)
|
|
|
|
{
|
2013-06-08 08:29:24 +00:00
|
|
|
super(blockID, Material.rock);
|
2013-06-07 21:36:52 +00:00
|
|
|
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
|
|
|
|
2013-06-08 09:14:17 +00:00
|
|
|
this.setHardness(3.0F);
|
|
|
|
this.setResistance(5.0F);
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister iconRegister)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
altarFrame = iconRegister.registerIcon("biomesoplenty:altarframe");
|
|
|
|
altarFrameTop = iconRegister.registerIcon("biomesoplenty:altarframetop");
|
2013-06-07 21:36:52 +00:00
|
|
|
|
2013-07-03 06:01:28 +00:00
|
|
|
frameApatite = iconRegister.registerIcon("biomesoplenty:frameapatite");
|
|
|
|
framePeridot = iconRegister.registerIcon("biomesoplenty:frameperidot");
|
|
|
|
frameRuby = iconRegister.registerIcon("biomesoplenty:frameruby");
|
|
|
|
frameSapphire = iconRegister.registerIcon("biomesoplenty:framesapphire");
|
|
|
|
frameTanzanite = iconRegister.registerIcon("biomesoplenty:frametanzanite");
|
|
|
|
frameTopaz = iconRegister.registerIcon("biomesoplenty:frametopaz");
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Icon getIcon(int side, int meta)
|
|
|
|
{
|
|
|
|
if (side == 1 || side == 0)
|
|
|
|
{
|
|
|
|
return altarFrameTop;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return altarFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasTileEntity(int metadata)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity createTileEntity(World world, int metadata)
|
|
|
|
{
|
|
|
|
return new TileEntityAltar();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
|
|
|
{
|
|
|
|
boolean returnStatement = false;
|
|
|
|
|
|
|
|
ItemStack equippedItem = player.getCurrentEquippedItem();
|
2013-06-08 08:29:24 +00:00
|
|
|
TileEntityAltar tileentityaltar = (TileEntityAltar) world.getBlockTileEntity(x, y, z);
|
2013-06-07 21:36:52 +00:00
|
|
|
|
|
|
|
if (equippedItem != null)
|
|
|
|
{
|
|
|
|
if (equippedItem.itemID == Items.miscItems.get().itemID && (equippedItem.getItemDamage() > 9 && equippedItem.getItemDamage() < 16))
|
|
|
|
{
|
|
|
|
if (tileentityaltar != null)
|
2013-06-08 08:29:24 +00:00
|
|
|
{
|
2013-06-09 22:45:23 +00:00
|
|
|
if (!tileentityaltar.getPresent(equippedItem.getItemDamage()))
|
2013-06-07 21:36:52 +00:00
|
|
|
{
|
2013-06-07 23:22:41 +00:00
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
2013-06-09 22:45:23 +00:00
|
|
|
tileentityaltar.setPresent(equippedItem.getItemDamage(), true);
|
2013-06-15 11:19:57 +00:00
|
|
|
|
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
--equippedItem.stackSize;
|
|
|
|
}
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
2013-06-08 07:04:09 +00:00
|
|
|
|
2013-06-07 23:22:41 +00:00
|
|
|
world.markBlockForUpdate(x, y, z);
|
2013-06-07 21:36:52 +00:00
|
|
|
|
2013-06-07 23:22:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 23:22:41 +00:00
|
|
|
return false;
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
|
|
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
|
|
|
|
for (int i = 0; i < altarTypes.length; ++i) {
|
|
|
|
list.add(new ItemStack(blockID, 1, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderAsNormalBlock()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
2013-06-08 07:04:09 +00:00
|
|
|
return RenderUtils.altarModel;
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
2013-06-08 08:29:24 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBlockHarvested(World world, int x, int y, int z, int id, EntityPlayer par6EntityPlayer)
|
|
|
|
{
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
|
2013-06-15 11:19:57 +00:00
|
|
|
if (par6EntityPlayer.getCurrentEquippedItem() != null)
|
|
|
|
{
|
|
|
|
Item item = Item.itemsList[par6EntityPlayer.getCurrentEquippedItem().itemID];
|
|
|
|
|
|
|
|
if (item instanceof ItemPickaxe)
|
|
|
|
{
|
|
|
|
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops"))
|
|
|
|
{
|
|
|
|
float f = 0.7F;
|
|
|
|
double d0 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
|
|
|
double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
|
|
|
double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
|
|
|
EntityItem entityitem = new EntityItem(world, (double)x + d0, (double)y + d1, (double)z + d2, new ItemStack(Blocks.altar.get(), 1));
|
|
|
|
entityitem.delayBeforeCanPickup = 10;
|
|
|
|
world.spawnEntityInWorld(entityitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dropBlockAsItem(world, x, y, z, id, meta);
|
2013-06-08 08:29:24 +00:00
|
|
|
}
|
2013-06-07 21:36:52 +00:00
|
|
|
|
|
|
|
@Override
|
2013-06-07 23:40:48 +00:00
|
|
|
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int meta, int fortune)
|
2013-06-07 21:36:52 +00:00
|
|
|
{
|
2013-06-07 23:40:48 +00:00
|
|
|
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
2013-06-08 08:29:24 +00:00
|
|
|
TileEntityAltar tileentityaltar = (TileEntityAltar) world.getBlockTileEntity(x, y, z);
|
|
|
|
|
2013-06-07 23:40:48 +00:00
|
|
|
if (tileentityaltar != null)
|
|
|
|
{
|
2013-06-09 22:45:23 +00:00
|
|
|
if (tileentityaltar.getPresent(10))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 10));
|
2013-06-08 02:50:47 +00:00
|
|
|
|
2013-06-09 22:45:23 +00:00
|
|
|
if (tileentityaltar.getPresent(11))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 11));
|
2013-06-08 02:50:47 +00:00
|
|
|
|
2013-06-09 22:45:23 +00:00
|
|
|
if (tileentityaltar.getPresent(12))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 12));
|
2013-06-08 02:50:47 +00:00
|
|
|
|
2013-06-09 22:45:23 +00:00
|
|
|
if (tileentityaltar.getPresent(13))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 13));
|
2013-06-08 02:50:47 +00:00
|
|
|
|
2013-06-09 22:45:23 +00:00
|
|
|
if (tileentityaltar.getPresent(14))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 14));
|
2013-06-08 02:50:47 +00:00
|
|
|
|
2013-06-09 22:45:23 +00:00
|
|
|
if (tileentityaltar.getPresent(15))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 15));
|
2013-06-07 23:40:48 +00:00
|
|
|
}
|
2013-06-08 07:04:09 +00:00
|
|
|
|
2013-06-07 23:40:48 +00:00
|
|
|
return ret;
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
}
|