Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.lavapower.harmonia.common.blocks;
- import fr.lavapower.harmonia.common.entity.TileEntityStatue;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.ChatComponentTranslation;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- public class StatueBlock extends Block
- {
- private String pseudo;
- public StatueBlock(Material rock, String pseudod)
- {
- super(rock);
- setCreativeTab(CreativeTabs.tabDecorations);
- pseudo = pseudod;
- }
- @Override
- public TileEntity createTileEntity(World world, int metadata)
- {
- TileEntityStatue tile = new TileEntityStatue();
- tile.setPseudo(pseudo);
- return tile;
- }
- @Override
- public boolean hasTileEntity(int metadata)
- {
- return true;
- }
- public boolean isOpaqueCube()
- {
- return false;
- }
- public boolean renderAsNormalBlock()
- {
- return false;
- }
- public int getRenderType()
- {
- return -1;
- }
- public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
- {
- this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
- }
- public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
- {
- TileEntity tile = world.getTileEntity(x, y, z);
- if(tile instanceof TileEntityStatue)
- {
- int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
- ((TileEntityStatue)tile).setDirection(direction);
- }
- }
- public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
- {
- if(!world.isRemote)
- {
- TileEntity tile = world.getTileEntity(x, y, z);
- if(tile instanceof TileEntityStatue)
- {
- player.addChatMessage(new ChatComponentTranslation("tile.statue.msg." + ((TileEntityStatue)tile).getPseudo()));
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment