Guest User

Block

a guest
Mar 8th, 2018
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.hugoland.rpmod.common.blocks;
  2.  
  3. import fr.hugoland.rpmod.common.RPMod;
  4. import fr.hugoland.rpmod.common.tileentity.TileEntityPancarte;
  5. import net.minecraft.block.BlockContainer;
  6. import net.minecraft.block.BlockSign;
  7. import net.minecraft.block.material.Material;
  8. import net.minecraft.client.Minecraft;
  9. import net.minecraft.client.gui.inventory.GuiEditSign;
  10. import net.minecraft.creativetab.CreativeTabs;
  11. import net.minecraft.entity.EntityLivingBase;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.tileentity.TileEntity;
  15. import net.minecraft.tileentity.TileEntitySign;
  16. import net.minecraft.util.MathHelper;
  17. import net.minecraft.world.IBlockAccess;
  18. import net.minecraft.world.World;
  19.  
  20. public class Pancarte extends BlockContainer
  21. {
  22.  
  23. public Pancarte(Material mat)
  24. {
  25. super(mat);
  26. this.setCreativeTab(CreativeTabs.tabDecorations);
  27. }
  28.  
  29. public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
  30. {
  31. TileEntity tile = world.getTileEntity(x, y, z);
  32. if(tile instanceof TileEntityPancarte)
  33. {
  34. TileEntityPancarte tileTuto = (TileEntityPancarte)tile;
  35. switch(tileTuto.getDirection())
  36. {
  37. case 0:
  38. this.setBlockBounds(0.0F, 0.2F, 0.1F, 1.0F, 0.8F, 0.3F); //valeur pour la direction 0
  39. break;
  40. case 1:
  41. this.setBlockBounds(0.7F, 0.2F, 0.0F, 0.9F, 0.8F, 1.0F); //valeur pour la direction 1
  42. break;
  43. case 2:
  44. this.setBlockBounds(0.0F, 0.2F, 0.7F, 1.0F, 0.8F, 0.9F); //valeur pour la direction 2
  45. break;
  46. case 3:
  47. this.setBlockBounds(0.1F, 0.2F, 0.0F, 0.3F, 0.8F, 1.0F); //valeur pour la direction 3
  48. break;
  49. }
  50. }
  51. }
  52.  
  53. public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
  54. {
  55. TileEntity tile = world.getTileEntity(x, y, z);
  56. if(tile instanceof TileEntityPancarte)
  57. {
  58. TileEntityPancarte tile2 = ((TileEntityPancarte)tile);
  59. int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
  60. tile2.setDirection((byte)direction);
  61. if(living instanceof EntityPlayer)
  62. {
  63. EntityPlayer player = ((EntityPlayer)living);
  64. Minecraft.getMinecraft().displayGuiScreen(new GuiEditSign((TileEntitySign)tile));
  65. }
  66. }
  67. }
  68.  
  69.  
  70. @Override
  71. public boolean hasTileEntity(int metadata)
  72. {
  73. return true;
  74. }
  75.  
  76. public boolean isOpaqueCube()
  77. {
  78. return false;
  79. }
  80.  
  81. public boolean renderAsNormalBlock()
  82. {
  83. return false;
  84. }
  85.  
  86. public int getRenderType()
  87. {
  88. return -1;
  89. }
  90.  
  91. @Override
  92. public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
  93. {
  94. return new TileEntityPancarte();
  95. }
  96.  
  97. }
RAW Paste Data