2013-06-07 21:36:52 +00:00
|
|
|
package biomesoplenty.blocks;
|
|
|
|
|
2013-06-08 07:04:09 +00:00
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.DataOutputStream;
|
2013-06-07 23:40:48 +00:00
|
|
|
import java.util.ArrayList;
|
2013-06-07 21:36:52 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2013-06-08 07:04:09 +00:00
|
|
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
|
|
import cpw.mods.fml.common.network.Player;
|
2013-06-07 21:36:52 +00:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.ITileEntityProvider;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2013-06-08 07:04:09 +00:00
|
|
|
import net.minecraft.network.INetworkManager;
|
|
|
|
import net.minecraft.network.packet.Packet;
|
|
|
|
import net.minecraft.network.packet.Packet132TileEntityData;
|
2013-06-07 21:36:52 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.Icon;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.client.MinecraftForgeClient;
|
2013-06-07 23:40:48 +00:00
|
|
|
import net.minecraftforge.common.ForgeHooks;
|
2013-06-07 21:36:52 +00:00
|
|
|
import biomesoplenty.BiomesOPlenty;
|
|
|
|
import biomesoplenty.api.Blocks;
|
|
|
|
import biomesoplenty.api.Items;
|
|
|
|
import biomesoplenty.blocks.renderers.AltarRenderer;
|
2013-06-08 07:04:09 +00:00
|
|
|
import biomesoplenty.blocks.renderers.RenderUtils;
|
2013-06-07 21:36:52 +00:00
|
|
|
import biomesoplenty.blocks.renderers.SmallBlockRenderer;
|
|
|
|
import biomesoplenty.tileentity.TileEntityAltar;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
this.blockHardness = 0.37F;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister iconRegister)
|
|
|
|
{
|
|
|
|
altarFrame = iconRegister.registerIcon("BiomesOPlenty:altarframe");
|
|
|
|
altarFrameTop = iconRegister.registerIcon("BiomesOPlenty:altarframetop");
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
@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-07 23:22:41 +00:00
|
|
|
if (!tileentityaltar.getPresent(equippedItem.getItemName()))
|
2013-06-07 21:36:52 +00:00
|
|
|
{
|
2013-06-07 23:22:41 +00:00
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
2013-06-07 23:40:48 +00:00
|
|
|
tileentityaltar.setPresent(equippedItem.getItemName(), true);
|
2013-06-07 23:22:41 +00:00
|
|
|
--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);
|
|
|
|
|
|
|
|
dropBlockAsItem(world, x, y, z, id, meta);
|
|
|
|
}
|
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-08 08:29:24 +00:00
|
|
|
if (tileentityaltar.getPresent("ruby"))
|
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-08 08:29:24 +00:00
|
|
|
if (tileentityaltar.getPresent("peridot"))
|
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-08 08:29:24 +00:00
|
|
|
if (tileentityaltar.getPresent("topaz"))
|
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-08 08:29:24 +00:00
|
|
|
if (tileentityaltar.getPresent("tanzanite"))
|
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-08 08:29:24 +00:00
|
|
|
if (tileentityaltar.getPresent("apatite"))
|
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-08 08:29:24 +00:00
|
|
|
if (tileentityaltar.getPresent("sapphire"))
|
2013-06-08 07:04:09 +00:00
|
|
|
ret.add(new ItemStack(Items.miscItems.get(), 1, 15));
|
2013-06-08 08:29:24 +00:00
|
|
|
|
|
|
|
ret.add(new ItemStack(Blocks.altar.get().blockID, 1, 0));
|
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
|
|
|
}
|
|
|
|
}
|