Guest User

Classe du Bloc

a guest
Aug 3rd, 2017
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.lavapower.harmonia.common.blocks;
  2.  
  3. import fr.lavapower.harmonia.common.entity.TileEntityStatue;
  4. import net.minecraft.block.Block;
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.creativetab.CreativeTabs;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.tileentity.TileEntity;
  11. import net.minecraft.util.ChatComponentTranslation;
  12. import net.minecraft.util.MathHelper;
  13. import net.minecraft.world.IBlockAccess;
  14. import net.minecraft.world.World;
  15.  
  16. public class StatueBlock extends Block
  17. {
  18. private String pseudo;
  19.  
  20. public StatueBlock(Material rock, String pseudod)
  21. {
  22. super(rock);
  23. setCreativeTab(CreativeTabs.tabDecorations);
  24. pseudo = pseudod;
  25. }
  26.  
  27. @Override
  28. public TileEntity createTileEntity(World world, int metadata)
  29. {
  30. TileEntityStatue tile = new TileEntityStatue();
  31. tile.setPseudo(pseudo);
  32. return tile;
  33. }
  34.  
  35. @Override
  36. public boolean hasTileEntity(int metadata)
  37. {
  38. return true;
  39. }
  40.  
  41. public boolean isOpaqueCube()
  42. {
  43. return false;
  44. }
  45.  
  46. public boolean renderAsNormalBlock()
  47. {
  48. return false;
  49. }
  50.  
  51. public int getRenderType()
  52. {
  53. return -1;
  54. }
  55.  
  56. public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
  57. {
  58. this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
  59. }
  60.  
  61. public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
  62. {
  63. TileEntity tile = world.getTileEntity(x, y, z);
  64. if(tile instanceof TileEntityStatue)
  65. {
  66. int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
  67. ((TileEntityStatue)tile).setDirection(direction);
  68. }
  69. }
  70.  
  71. public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
  72. {
  73. if(!world.isRemote)
  74. {
  75. TileEntity tile = world.getTileEntity(x, y, z);
  76. if(tile instanceof TileEntityStatue)
  77. {
  78. player.addChatMessage(new ChatComponentTranslation("tile.statue.msg." + ((TileEntityStatue)tile).getPseudo()));
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84.  
  85. }
RAW Paste Data