majesticmadman98 Posted June 1, 2014 Posted June 1, 2014 ok my custom block can only be placed in one direction, which is defined in the render class, I want the block to face the opposite way the player is, so firstly the code for this would it go in the block class (as this is where the "block properties" are declared and that the functions of the block are declared) or the render class(as this is where the other block appearance parts go). I think it goes in the render class but don't know. Secondly is the code It's self. I know you guys like to go along don't give code cause it doesn't help. Well could you input the code missing but don't fill it in. so for example GL11.glScaled(x, y, z); block: package dma.block; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import dma.main.main; import dma.tileentity.*; public class DalekConsole2 extends BlockContainer{ public DalekConsole2(Material material) { super(material); setHardness(2.0F); setResistance(5.0F); setLightLevel(0.5F); setCreativeTab(CreativeTabs.tabBlock); setBlockBounds(1F/16F*-6F, 0F, 1F/16F*-4F, 1F-1F/16F*-6F, 1F-1F/16F*-10F, 1F-1F/16F*-3F); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock(){ return false; } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityDalekConsole2(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(main.MODID + ":" + "DalekConsole2"); } } render: package renderer; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import dma.main.main; import dma.models.DalekConsole2; public class RenderDalekConsole2 extends TileEntitySpecialRenderer{ private static final ResourceLocation texture = new ResourceLocation(main.MODID + ":" + "textures/models/DalekConsole2.png"); private DalekConsole2 model; public RenderDalekConsole2() { this.model = new DalekConsole2(); } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float)z + 0.5f); GL11.glRotatef(180, 180F, 0F, 1F); GL11.glScaled(0.7, 0.7, 0.7); GL11.glTranslated(-0.5, 0.6, 0); this.bindTexture(texture); GL11.glPushMatrix(); this.model.renderModel(0.0625f); GL11.glPopMatrix(); GL11.glPopMatrix(); } } Quote
Abastro Posted June 1, 2014 Posted June 1, 2014 You can override the onBlockPlacedBy method, and make it save the direction in the metadata similat to the following: /** * Called when the block is placed in the world. */ public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (l == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (l == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); } if (par6ItemStack.hasDisplayName()) { ((TileHeatFurnace)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); } }' (The code is just for furnace, so you should change it) And you can render with the metadata value. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.