Flenix Posted April 18, 2013 Posted April 18, 2013 Hey guys, I want to rotate the top face of a block. I can rotate the side faces OK, but the top doesn't turn... Anyone able to point me in the right direction? I can't think of any vanilla blocks to use a reference (I learnt side rotation from Pumpkin) so just that would be enough if you can think of one. Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
Flenix Posted April 18, 2013 Author Posted April 18, 2013 Hey guys, I want to rotate the top face of a block. I can rotate the side faces OK, but the top doesn't turn... Anyone able to point me in the right direction? I can't think of any vanilla blocks to use a reference (I learnt side rotation from Pumpkin) so just that would be enough if you can think of one. Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
thebest108 Posted April 19, 2013 Posted April 19, 2013 piston Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
thebest108 Posted April 19, 2013 Posted April 19, 2013 piston Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Flenix Posted April 19, 2013 Author Posted April 19, 2013 Thank you for your infinite wisdom and help. Anyone else able to actually help me? sorry but just saying "piston" really doesn't help at all due to all it's extra mechanics it has to check through. Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
Flenix Posted April 19, 2013 Author Posted April 19, 2013 Thank you for your infinite wisdom and help. Anyone else able to actually help me? sorry but just saying "piston" really doesn't help at all due to all it's extra mechanics it has to check through. Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
Flenix Posted April 19, 2013 Author Posted April 19, 2013 Alright, I'm close, I can rotate the top texture of the block now. Issue is, the top texture is copied around the block, and I can't quite work out why. I want the sides to be a different texture. Screenshot: The top is fine, but I want the side to be the same as the front. Code: package co.uk.silvania.roads.block; import co.uk.silvania.roads.CommonProxy; import co.uk.silvania.roads.Roads; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntitySnowman; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.Facing; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class RBSideWhiteStripe extends BlockDirectional { public RBSideWhiteStripe(int par1, int par2) { super(par1, Material.pumpkin); this.blockIndexInTexture = par2; this.setTickRandomly(true); this.setCreativeTab(Roads.tabRoads); } @Override public String getTextureFile () { return CommonProxy.BLOCK_PNG; } @SideOnly(Side.CLIENT) public int getBlockTextureFromSideAndMetadata(int par1, int par2) { int var3 = getOrientation(par2); return var3 > 5 ? this.blockIndexInTexture : (par1 == var3 ? (this.blockIndexInTexture + 1 * 1) : (par1 == Facing.faceToSide[var3] ? 1 : 14)); } public int getRenderType() { return 16; } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = determineOrientation(par1World, par2, par3, par4, (EntityPlayer)par5EntityLiving); par1World.setBlockMetadataWithNotify(par2, par3, par4, var6); } public static int getOrientation(int par0) { return par0 & 7; } public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityPlayer par4EntityPlayer) { int var7 = MathHelper.floor_double((double)(par4EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; return var7 == 0 ? 2 : (var7 == 1 ? 5 : (var7 == 2 ? 3 : (var7 == 3 ? 4 : 0))); } } Anyone able to assist? This is the last thing until I release my first beta Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
Flenix Posted April 19, 2013 Author Posted April 19, 2013 Alright, I'm close, I can rotate the top texture of the block now. Issue is, the top texture is copied around the block, and I can't quite work out why. I want the sides to be a different texture. Screenshot: The top is fine, but I want the side to be the same as the front. Code: package co.uk.silvania.roads.block; import co.uk.silvania.roads.CommonProxy; import co.uk.silvania.roads.Roads; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntitySnowman; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.Facing; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class RBSideWhiteStripe extends BlockDirectional { public RBSideWhiteStripe(int par1, int par2) { super(par1, Material.pumpkin); this.blockIndexInTexture = par2; this.setTickRandomly(true); this.setCreativeTab(Roads.tabRoads); } @Override public String getTextureFile () { return CommonProxy.BLOCK_PNG; } @SideOnly(Side.CLIENT) public int getBlockTextureFromSideAndMetadata(int par1, int par2) { int var3 = getOrientation(par2); return var3 > 5 ? this.blockIndexInTexture : (par1 == var3 ? (this.blockIndexInTexture + 1 * 1) : (par1 == Facing.faceToSide[var3] ? 1 : 14)); } public int getRenderType() { return 16; } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = determineOrientation(par1World, par2, par3, par4, (EntityPlayer)par5EntityLiving); par1World.setBlockMetadataWithNotify(par2, par3, par4, var6); } public static int getOrientation(int par0) { return par0 & 7; } public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityPlayer par4EntityPlayer) { int var7 = MathHelper.floor_double((double)(par4EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; return var7 == 0 ? 2 : (var7 == 1 ? 5 : (var7 == 2 ? 3 : (var7 == 3 ? 4 : 0))); } } Anyone able to assist? This is the last thing until I release my first beta Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
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.