| |
| package com.yvelis.mworldcraft.blocks; |
| |
| import com.yvelis.mworldcraft.common.Mmain; |
| import com.yvelis.mworldcraft.tileEntity.CraftTileEntity; |
| |
| import cpw.mods.fml.common.network.FMLNetworkHandler; |
| import net.minecraft.block.Block; |
| import net.minecraft.block.BlockContainer; |
| import net.minecraft.block.material.Material; |
| import net.minecraft.client.renderer.texture.IconRegister; |
| import net.minecraft.entity.EntityLivingBase; |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.tileentity.TileEntity; |
| import net.minecraft.tileentity.TileEntityFurnace; |
| import net.minecraft.util.Icon; |
| import net.minecraft.util.MathHelper; |
| import net.minecraft.world.World; |
| |
| public class SmeltingBlock extends BlockContainer |
| { |
| private Icon top; |
| private Icon sud; |
| private Icon other; |
| |
| public SmeltingBlock(int id) |
| { |
| super(id, Material.anvil); |
| } |
| |
| @Override |
| public TileEntity createNewTileEntity(World world) { |
| return new CraftTileEntity(); |
| } |
| |
| @Override |
| public boolean hasTileEntity(int meta) { |
| return true; |
| } |
| |
| @Override |
| public Icon getIcon(int side, int meta) |
| { |
| return side == 1 ? this.top : (side == 0 ? this.top : (side != meta ? this.other : this.sud)); |
| } |
| |
| public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) |
| { |
| int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; |
| |
| if (l == 0) |
| { |
| par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); |
| } |
| |
| if (l == 1) |
| { |
| par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); |
| } |
| |
| if (l == 2) |
| { |
| par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); |
| } |
| |
| if (l == 3) |
| { |
| par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); |
| } |
| } |
| |
| @Override |
| public void registerIcons(IconRegister register) |
| { |
| top = register.registerIcon("mworldcraft:foundryTop"); |
| sud = register.registerIcon("mworldcraft:foundrySud"); |
| other = register.registerIcon("mworldcraft:foundryOther"); |
| } |
| |
| @Override |
| public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) |
| { |
| FMLNetworkHandler.openGui(player, Mmain.m_instance, 0, world, x, y, z); |
| return true; |
| } |
| } |
| |