Advertisement
Guest User

Untitled

a guest
Jul 21st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. public class KnowledgeClientProxy extends CommonProxy {
  2.  
  3. public void registerRenderInfo() {
  4.  
  5. ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThaumTank.class, new TileEntityThaumTankRenderer());
  6.  
  7. }
  8. }
  9.  
  10. MOD{
  11. public static CommonProxy proxy;
  12.  
  13. public void preInit(FMLPreInitializationEvent event) {
  14.  
  15.  
  16. TKPacketHandler.init();
  17. TKBlocks.addBlocks();
  18. TKItems.addItems();
  19. proxy.registerRenderInfo();
  20.  
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. public class TileEntityThaumTank extends TKTE {
  30.  
  31. @Override
  32. public void readCustomNBT(NBTTagCompound tags) {
  33.  
  34.  
  35. }
  36.  
  37. @Override
  38. public void writeCustomNBT(NBTTagCompound tags) {
  39.  
  40.  
  41. }
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. public class BlockThaumTank extends BlockContainer {
  51.  
  52. private String name = "thaumtank";
  53.  
  54.  
  55. @Override
  56. public int getRenderType() {
  57. return -1;
  58. }
  59.  
  60. @Override
  61. public boolean isOpaqueCube() {
  62. return false;
  63. }
  64.  
  65. public boolean renderAsNormalBlock() {
  66. return false;
  67. }
  68.  
  69. public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
  70. return false;
  71. }
  72.  
  73. public BlockThaumTank() {
  74.  
  75. super(Material.rock);
  76. this.setCreativeTab(Knowledge.tab).setBlockName(Knowledge.MODID+"_"+name);
  77. this.setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypeStone);
  78. this.setHarvestLevel("pickaxe", 0);
  79. this.setTickRandomly(true);
  80.  
  81. }
  82.  
  83.  
  84. public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entity, ItemStack item)
  85. {
  86. int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  87.  
  88.  
  89. if (l == 0)
  90. {
  91. world.setBlockMetadataWithNotify(i, j, k, 2, 2);
  92. }
  93.  
  94. if (l == 1)
  95. {
  96. world.setBlockMetadataWithNotify(i, j, k, 5, 2);
  97. }
  98.  
  99. if (l == 2)
  100. {
  101. world.setBlockMetadataWithNotify(i, j, k, 3, 2);
  102. }
  103.  
  104. if (l == 3)
  105. {
  106. world.setBlockMetadataWithNotify(i, j, k, 4, 2);
  107. }
  108. }
  109.  
  110.  
  111.  
  112. public Item getItemDropped() {
  113. return Item.getItemFromBlock(this);
  114. }
  115.  
  116. @Override
  117. public TileEntity createNewTileEntity(World world, int metadata) {
  118.  
  119. return new TileEntityThaumTank();
  120. }
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. SideOnly(Side.CLIENT)
  130. public class TileEntityThaumTankRenderer extends TileEntitySpecialRenderer {
  131.  
  132.  
  133. private static ModelThaumTank model = new ModelThaumTank();
  134. private final ResourceLocation TTANK_TEX = new ResourceLocation(Knowledge.MODID,"textures/models/ThaumTank_model.png");
  135.  
  136.  
  137.  
  138. @Override
  139. public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
  140.  
  141. GL11.glPushMatrix();
  142. //This will move our renderer so that it will be on proper place in the world
  143. GL11.glTranslatef((float)x, (float)y, (float)z);
  144. TileEntityThaumTank thaumtank = (TileEntityThaumTank)te;
  145.  
  146. GL11.glPopMatrix();
  147. }
  148. //And this method actually renders your tile entity
  149. public void renderBlockYour(TileEntityThaumTank tl, World world, int i, int j, int k, Block block) {
  150. Tessellator tessellator = Tessellator.instance;
  151. //This will make your block brightness dependent from surroundings lighting.
  152. float f = block.getLightValue(world, i, j, k);
  153. int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
  154. int l1 = l % 65536;
  155. int l2 = l / 65536;
  156. tessellator.setColorOpaque_F(f, f, f);
  157. OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);
  158.  
  159. /*This will rotate your model corresponding to player direction that was when you placed the block. If you want this to work,
  160. add these lines to onBlockPlacedBy method in your block class.
  161. int dir = MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3;
  162. world.setBlockMetadataWithNotify(x, y, z, dir, 0);*/
  163.  
  164. int dir = world.getBlockMetadata(i, j, k);
  165.  
  166. GL11.glPushMatrix();
  167. GL11.glTranslatef(0.5F, 0, 0.5F);
  168. //This line actually rotates the renderer.
  169. GL11.glRotatef(dir * (-90F), 0F, 1F, 0F);
  170. GL11.glTranslatef(-0.5F, 0, -0.5F);
  171. bindTexture(TTANK_TEX);
  172. /*
  173. Place your rendering code here.
  174. */
  175. this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  176. GL11.glPopMatrix();
  177. }
  178.  
  179.  
  180.  
  181.  
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement