Posted May 3, 201411 yr Hi Guys i have a techne block and issue is i can get my block to rotate in 4 directions. only in 2 directions. i'm not sure why its happen. I'm not very good at coding help would be appreciated thanks. my classes are below. Block Class package glowsblocksandlights; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class outsidelightsteel extends BlockContainer { public outsidelightsteel(int id, Material Material) { super(id, Material); setHardness(0.5F); setStepSound(Block.soundGlassFootstep); setLightOpacity(255); setLightValue(1.0F); setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 4.0F, 0.7F); // setBlockBounds(0.0f, 0.0f, 0.0f, 0.6875f, 0.9000f,0.6875f); } @Override public TileEntity createNewTileEntity(World world) { // TODO Auto-generated method stub return new TileEntityoutsidelightsteel(); } /** * Called whenever the block is added into the world. Args: world, x, y, z */ @Override public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); } /** * set a blocks direction */ private void setDefaultDirection(World par1World, int par2, int par3, int par4) { if (!par1World.isRemote) { int l = par1World.getBlockId(par2, par3, par4 - 1); int i1 = par1World.getBlockId(par2, par3, par4 + 1); int j1 = par1World.getBlockId(par2 - 1, par3, par4); int k1 = par1World.getBlockId(par2 + 1, par3, par4); byte b0 = 3; if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1]) { b0 = 3; } if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l]) { b0 = 2; } if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1]) { b0 = 5; } if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1]) { b0 = 4; } par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2); } } // public void onBlockPlacedBy(World world, int i, int j, int k, // EntityLiving entityliving){ // int rotation = MathHelper.floor_double((double)((entityliving.rotationYaw // * 4F) / 360F) + 2.5D) & 3; // } /** * Called when the block is placed in the world. */ @Override 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); } } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister IconRegister) { blockIcon = IconRegister.registerIcon(Basicinfo.ID.toLowerCase() + ":outsidelightsteel"); } @Override public boolean isOpaqueCube() { return false; } @Override public int getRenderType() { return -1; } @Override public boolean renderAsNormalBlock() { return false; } } my Entity render Class package glowsblocksandlights; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class TileEntityoutsidelightsteelRenderer extends TileEntitySpecialRenderer{ private static final ResourceLocation outsidelightsteel = new ResourceLocation(Basicinfo.ID.toLowerCase() + ":/textures/blocks/modeloutsidelightsteel.png"); private final Modeloutsidelight model = new Modeloutsidelight(); public void renderAModelAt(TileEntityoutsidelightsteel par1EntityForge, double par2, double par4, double par6, float par8){ int metadata = par1EntityForge.getBlockMetadata(); int rotationAngle = 0; if(metadata%4 == 0){ rotationAngle = 0; }if(metadata%4 == 1){ rotationAngle = 270; }if(metadata%4 == 2){ rotationAngle = 180; }if(metadata%4 == 3){ rotationAngle = 90; } GL11.glPushMatrix(); GL11.glTranslated((float)par2 + 0.5F, (float)par4 + 1.5F, (float)par6 + 0.5F); GL11.glScaled(1.0F, -1F, -1F); GL11.glRotated(rotationAngle*90, 0.0F, 1.0F, 0.0F); this.bindTexture(outsidelightsteel); this.model.renderAll(); GL11.glPopMatrix(); } @Override public void renderTileEntityAt(TileEntity par1tileentity, double par2, double par4, double par6, float par8) { this.renderAModelAt((TileEntityoutsidelightsteel)par1tileentity, par2, par4, par6, par8); } }
May 4, 201411 yr Because you multiply your rotateAngle with 90 again in your glRotatef. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
May 4, 201411 yr Author Hi SanAndreasP Thanks for that i actually fixed that out a few hours before i read your reply. Stupid mistake.
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.