Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KnowledgeClientProxy extends CommonProxy {
- public void registerRenderInfo() {
- ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThaumTank.class, new TileEntityThaumTankRenderer());
- }
- }
- MOD{
- public static CommonProxy proxy;
- public void preInit(FMLPreInitializationEvent event) {
- TKPacketHandler.init();
- TKBlocks.addBlocks();
- TKItems.addItems();
- proxy.registerRenderInfo();
- }
- public class TileEntityThaumTank extends TKTE {
- @Override
- public void readCustomNBT(NBTTagCompound tags) {
- }
- @Override
- public void writeCustomNBT(NBTTagCompound tags) {
- }
- }
- public class BlockThaumTank extends BlockContainer {
- private String name = "thaumtank";
- @Override
- public int getRenderType() {
- return -1;
- }
- @Override
- public boolean isOpaqueCube() {
- return false;
- }
- public boolean renderAsNormalBlock() {
- return false;
- }
- public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
- return false;
- }
- public BlockThaumTank() {
- super(Material.rock);
- this.setCreativeTab(Knowledge.tab).setBlockName(Knowledge.MODID+"_"+name);
- this.setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypeStone);
- this.setHarvestLevel("pickaxe", 0);
- this.setTickRandomly(true);
- }
- public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entity, ItemStack item)
- {
- int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
- if (l == 0)
- {
- world.setBlockMetadataWithNotify(i, j, k, 2, 2);
- }
- if (l == 1)
- {
- world.setBlockMetadataWithNotify(i, j, k, 5, 2);
- }
- if (l == 2)
- {
- world.setBlockMetadataWithNotify(i, j, k, 3, 2);
- }
- if (l == 3)
- {
- world.setBlockMetadataWithNotify(i, j, k, 4, 2);
- }
- }
- public Item getItemDropped() {
- return Item.getItemFromBlock(this);
- }
- @Override
- public TileEntity createNewTileEntity(World world, int metadata) {
- return new TileEntityThaumTank();
- }
- }
- SideOnly(Side.CLIENT)
- public class TileEntityThaumTankRenderer extends TileEntitySpecialRenderer {
- private static ModelThaumTank model = new ModelThaumTank();
- private final ResourceLocation TTANK_TEX = new ResourceLocation(Knowledge.MODID,"textures/models/ThaumTank_model.png");
- @Override
- public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
- GL11.glPushMatrix();
- //This will move our renderer so that it will be on proper place in the world
- GL11.glTranslatef((float)x, (float)y, (float)z);
- TileEntityThaumTank thaumtank = (TileEntityThaumTank)te;
- GL11.glPopMatrix();
- }
- //And this method actually renders your tile entity
- public void renderBlockYour(TileEntityThaumTank tl, World world, int i, int j, int k, Block block) {
- Tessellator tessellator = Tessellator.instance;
- //This will make your block brightness dependent from surroundings lighting.
- float f = block.getLightValue(world, i, j, k);
- int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
- int l1 = l % 65536;
- int l2 = l / 65536;
- tessellator.setColorOpaque_F(f, f, f);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);
- /*This will rotate your model corresponding to player direction that was when you placed the block. If you want this to work,
- add these lines to onBlockPlacedBy method in your block class.
- int dir = MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3;
- world.setBlockMetadataWithNotify(x, y, z, dir, 0);*/
- int dir = world.getBlockMetadata(i, j, k);
- GL11.glPushMatrix();
- GL11.glTranslatef(0.5F, 0, 0.5F);
- //This line actually rotates the renderer.
- GL11.glRotatef(dir * (-90F), 0F, 1F, 0F);
- GL11.glTranslatef(-0.5F, 0, -0.5F);
- bindTexture(TTANK_TEX);
- /*
- Place your rendering code here.
- */
- this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
- GL11.glPopMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement