Jump to content

How would I set my blocks metadata depending on the players direction?


Flenix

Recommended Posts

Sorry for two questions in a row, but my mod is nearly done and I just want to get these last bits finished.

 

An issue plaguing me since I started it, is I can't rotate the top texture of the block. I can rotate the side ones OK, but not the top. So my next approach, is to make metadata-based sub-blocks, 4 of each type, and pick which one to place depending on the direction the player is facing.

 

How would I go about doing this?

(Unless anyone knows a way to do it properly of course!)

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Sorry for two questions in a row, but my mod is nearly done and I just want to get these last bits finished.

 

An issue plaguing me since I started it, is I can't rotate the top texture of the block. I can rotate the side ones OK, but not the top. So my next approach, is to make metadata-based sub-blocks, 4 of each type, and pick which one to place depending on the direction the player is facing.

 

How would I go about doing this?

(Unless anyone knows a way to do it properly of course!)

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Put this code into your block's onBlockPlacedBy

int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(i, j, k, dir, 0);

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Link to comment
Share on other sites

Put this code into your block's onBlockPlacedBy

int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(i, j, k, dir, 0);

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Link to comment
Share on other sites

Doesn't seem to be working. Here's the entire block's class, no matter what direction I face it's placing the same block.

 

package co.uk.silvania.roads.block;

import co.uk.silvania.roads.CommonProxy;
import co.uk.silvania.roads.Roads;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block {

    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @Override
    public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
    	return 0 + 4;
    }
    
    @Override
    public String getTextureFile () {
            return CommonProxy.BLOCK_PNG;
    }
  
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)    {
    	int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(i, j, k, dir);
    }
}

 

I'm assuming I've missed something, but I have no idea what...

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Doesn't seem to be working. Here's the entire block's class, no matter what direction I face it's placing the same block.

 

package co.uk.silvania.roads.block;

import co.uk.silvania.roads.CommonProxy;
import co.uk.silvania.roads.Roads;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block {

    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @Override
    public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
    	return 0 + 4;
    }
    
    @Override
    public String getTextureFile () {
            return CommonProxy.BLOCK_PNG;
    }
  
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)    {
    	int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(i, j, k, dir);
    }
}

 

I'm assuming I've missed something, but I have no idea what...

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Doesn't seem to be working. Here's the entire block's class, no matter what direction I face it's placing the same block.

 

package co.uk.silvania.roads.block;

import co.uk.silvania.roads.CommonProxy;
import co.uk.silvania.roads.Roads;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block {

    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @Override
    public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
    	return 0 + 4;
    }
    
    @Override
    public String getTextureFile () {
            return CommonProxy.BLOCK_PNG;
    }
  
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)    {
    	int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(i, j, k, dir);
    }
}

 

I'm assuming I've missed something, but I have no idea what...

 

 

It appears you are missing the flag argument in:

world.setBlockMetadataWithNotify(i, j, k, dir);

 

It should have a flag as that allows you to tell the clients to update with the proper information

ex:

world.setBlockMetadataWithNotify(i, j, k, dir,flag);

- I advise the flag to be 3 (I think this updates the server and client) I don't remember what 4 does. Anyway, by wading through tooltips in eclipse you should eventually figure out what the different values are for the flags.

Link to comment
Share on other sites

Doesn't seem to be working. Here's the entire block's class, no matter what direction I face it's placing the same block.

 

package co.uk.silvania.roads.block;

import co.uk.silvania.roads.CommonProxy;
import co.uk.silvania.roads.Roads;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block {

    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @Override
    public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
    	return 0 + 4;
    }
    
    @Override
    public String getTextureFile () {
            return CommonProxy.BLOCK_PNG;
    }
  
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)    {
    	int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(i, j, k, dir);
    }
}

 

I'm assuming I've missed something, but I have no idea what...

 

 

It appears you are missing the flag argument in:

world.setBlockMetadataWithNotify(i, j, k, dir);

 

It should have a flag as that allows you to tell the clients to update with the proper information

ex:

world.setBlockMetadataWithNotify(i, j, k, dir,flag);

- I advise the flag to be 3 (I think this updates the server and client) I don't remember what 4 does. Anyway, by wading through tooltips in eclipse you should eventually figure out what the different values are for the flags.

Link to comment
Share on other sites

Doesn't seem to be working. Here's the entire block's class, no matter what direction I face it's placing the same block.

 

package co.uk.silvania.roads.block;

import co.uk.silvania.roads.CommonProxy;
import co.uk.silvania.roads.Roads;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block {

    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @Override
    public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
    	return 0 + 4;
    }
    
    @Override
    public String getTextureFile () {
            return CommonProxy.BLOCK_PNG;
    }
  
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)    {
    	int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(i, j, k, dir);
    }
}

 

I'm assuming I've missed something, but I have no idea what...

 

 

It appears you are missing the flag argument in:

world.setBlockMetadataWithNotify(i, j, k, dir);

 

It should have a flag as that allows you to tell the clients to update with the proper information

ex:

world.setBlockMetadataWithNotify(i, j, k, dir,flag);

- I advise the flag to be 3 (I think this updates the server and client) I don't remember what 4 does. Anyway, by wading through tooltips in eclipse you should eventually figure out what the different values are for the flags.

 

Well that certainly did something.

Now, when holding my block it's showing texture at tile 4. When I place it, depending on my direction it's placing either air, stone, grass or dirt (ID's 0-3). It is placing the actual vanilla blocks, not just something textured the same (middle-clicking gives me the correct block)

 

 

m(

Show me your texture and subblocks.

 

I'm on 1.4.7 by the way (Mod is mainly for my server),

blocks.png

Edit: haha forgot the picture :P

I wanted to get this method working, then I was going to change that spritesheet to have rotations of each of the blocks which need them.

 

Do you mean the subblocks class file? From what I could see in the tutorial I followed, that was only required if you want each of the subblocks to appear in creative etc, which I don't. Maybe that's where I'm going wrong?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Doesn't seem to be working. Here's the entire block's class, no matter what direction I face it's placing the same block.

 

package co.uk.silvania.roads.block;

import co.uk.silvania.roads.CommonProxy;
import co.uk.silvania.roads.Roads;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block {

    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @Override
    public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
    	return 0 + 4;
    }
    
    @Override
    public String getTextureFile () {
            return CommonProxy.BLOCK_PNG;
    }
  
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)    {
    	int dir = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(i, j, k, dir);
    }
}

 

I'm assuming I've missed something, but I have no idea what...

 

 

It appears you are missing the flag argument in:

world.setBlockMetadataWithNotify(i, j, k, dir);

 

It should have a flag as that allows you to tell the clients to update with the proper information

ex:

world.setBlockMetadataWithNotify(i, j, k, dir,flag);

- I advise the flag to be 3 (I think this updates the server and client) I don't remember what 4 does. Anyway, by wading through tooltips in eclipse you should eventually figure out what the different values are for the flags.

 

Well that certainly did something.

Now, when holding my block it's showing texture at tile 4. When I place it, depending on my direction it's placing either air, stone, grass or dirt (ID's 0-3). It is placing the actual vanilla blocks, not just something textured the same (middle-clicking gives me the correct block)

 

 

m(

Show me your texture and subblocks.

 

I'm on 1.4.7 by the way (Mod is mainly for my server),

blocks.png

Edit: haha forgot the picture :P

I wanted to get this method working, then I was going to change that spritesheet to have rotations of each of the blocks which need them.

 

Do you mean the subblocks class file? From what I could see in the tutorial I followed, that was only required if you want each of the subblocks to appear in creative etc, which I don't. Maybe that's where I'm going wrong?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

Well, I haven't started programming for 1.4.7 yet, so I can only say what I have seen while modding for 1.5.1. But I would start by looking at the log placement code and copy that for the time being to be sure that your block can be oriented correctly first, then I would move over to looking that the players facing direction afterwards. The important thing is to be sure that you are handling the metadata correctly first then handle the more complicated things in terms of setting the metadata.

 

Anyway, good luck!

Link to comment
Share on other sites

Well, I haven't started programming for 1.4.7 yet, so I can only say what I have seen while modding for 1.5.1. But I would start by looking at the log placement code and copy that for the time being to be sure that your block can be oriented correctly first, then I would move over to looking that the players facing direction afterwards. The important thing is to be sure that you are handling the metadata correctly first then handle the more complicated things in terms of setting the metadata.

 

Anyway, good luck!

Link to comment
Share on other sites

I took that approach before.

 

My first attempt was the log code. However, when a log is on it's side, it only has TWO metadata positions, not 4; for north-south and east-west. Whether your facing north or south, it'll place the same texture. I couldn't quite work out why though.

 

My next approach was to try a piston, and that actually worked, but it was quite buggy. I managed to edit the code enough so I could place in the four directions and it would rotate, and it wouldn't rotate for up and down (which was good). However, the top texture mirrored around the left/right/bottom too, and I couldn't figure out why it did that. Also, the held item looked wrong, because technically the top of the block was actually it's side.

 

I can't understand why it's so complicated though. There must just be a simple method to rotate the top texture, surely? Even in Java itself, something to just rotate the image would be enough.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

I took that approach before.

 

My first attempt was the log code. However, when a log is on it's side, it only has TWO metadata positions, not 4; for north-south and east-west. Whether your facing north or south, it'll place the same texture. I couldn't quite work out why though.

 

My next approach was to try a piston, and that actually worked, but it was quite buggy. I managed to edit the code enough so I could place in the four directions and it would rotate, and it wouldn't rotate for up and down (which was good). However, the top texture mirrored around the left/right/bottom too, and I couldn't figure out why it did that. Also, the held item looked wrong, because technically the top of the block was actually it's side.

 

I can't understand why it's so complicated though. There must just be a simple method to rotate the top texture, surely? Even in Java itself, something to just rotate the image would be enough.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

I took that approach before.

 

My first attempt was the log code. However, when a log is on it's side, it only has TWO metadata positions, not 4; for north-south and east-west. Whether your facing north or south, it'll place the same texture. I couldn't quite work out why though.

 

My next approach was to try a piston, and that actually worked, but it was quite buggy. I managed to edit the code enough so I could place in the four directions and it would rotate, and it wouldn't rotate for up and down (which was good). However, the top texture mirrored around the left/right/bottom too, and I couldn't figure out why it did that. Also, the held item looked wrong, because technically the top of the block was actually it's side.

 

I can't understand why it's so complicated though. There must just be a simple method to rotate the top texture, surely? Even in Java itself, something to just rotate the image would be enough.

 

I do not wish to offend, but you don't seem to understand the switch statement that the log code has within. It checks for all possible cases 0-5, each is specified to a face, and in doing so sets metadata according to the case. 0 and 1 are up and down, 2 and 3 are north and south, 4 and 5 are east and west. (once again, I would like to mention that the version of code I am using is 1.5.1 and the log code could have very well changed in the transition)

 

Now, the log only needs to orient itself along 3 different axes where your block cares about the 4 or 6 potential directions. You can set the metadata according to the face that the player clicks on to place the block, that is what the log code is doing.

 

like I said, you should handle how you want your block to handle the metadata before the placement mechanism, that way you can iron out the bugs better.

 

edit:

I feel that I need to establish my last statement more.

I feel that you should test how your textures react to block metadata by setting the same metadata for each block as it is placed, this proves to you that the texture rendering code will handle proper metadata first. Setting the metadata with a placement handling code would be after you know that your metadata handling is correct (for example, if you want your block to face north, set 2 for the metadata, and have your texture rendering code handle facing the block north when metadata = 2 and so on.

Link to comment
Share on other sites

I took that approach before.

 

My first attempt was the log code. However, when a log is on it's side, it only has TWO metadata positions, not 4; for north-south and east-west. Whether your facing north or south, it'll place the same texture. I couldn't quite work out why though.

 

My next approach was to try a piston, and that actually worked, but it was quite buggy. I managed to edit the code enough so I could place in the four directions and it would rotate, and it wouldn't rotate for up and down (which was good). However, the top texture mirrored around the left/right/bottom too, and I couldn't figure out why it did that. Also, the held item looked wrong, because technically the top of the block was actually it's side.

 

I can't understand why it's so complicated though. There must just be a simple method to rotate the top texture, surely? Even in Java itself, something to just rotate the image would be enough.

 

I do not wish to offend, but you don't seem to understand the switch statement that the log code has within. It checks for all possible cases 0-5, each is specified to a face, and in doing so sets metadata according to the case. 0 and 1 are up and down, 2 and 3 are north and south, 4 and 5 are east and west. (once again, I would like to mention that the version of code I am using is 1.5.1 and the log code could have very well changed in the transition)

 

Now, the log only needs to orient itself along 3 different axes where your block cares about the 4 or 6 potential directions. You can set the metadata according to the face that the player clicks on to place the block, that is what the log code is doing.

 

like I said, you should handle how you want your block to handle the metadata before the placement mechanism, that way you can iron out the bugs better.

 

edit:

I feel that I need to establish my last statement more.

I feel that you should test how your textures react to block metadata by setting the same metadata for each block as it is placed, this proves to you that the texture rendering code will handle proper metadata first. Setting the metadata with a placement handling code would be after you know that your metadata handling is correct (for example, if you want your block to face north, set 2 for the metadata, and have your texture rendering code handle facing the block north when metadata = 2 and so on.

Link to comment
Share on other sites

No offence taken. I admit my Java knowledge is rather limited, but I'm a very hands-on learner and the best way for me to learn is simply trial and error. If I tried to read a book on Java, I'd get bored and give up after about 3 pages of trying to make Hello World, so things like what you just said are exactly what I need to help me learn.

 

However, I do know that when it boils down to it, that solution would be no different to my Piston one, because it's still just a block hacked to be on it's side. I know there must be something with that I can do, it's just a case of working it out. The metadata thing was just a totally different approach at it really :P

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

No offence taken. I admit my Java knowledge is rather limited, but I'm a very hands-on learner and the best way for me to learn is simply trial and error. If I tried to read a book on Java, I'd get bored and give up after about 3 pages of trying to make Hello World, so things like what you just said are exactly what I need to help me learn.

 

However, I do know that when it boils down to it, that solution would be no different to my Piston one, because it's still just a block hacked to be on it's side. I know there must be something with that I can do, it's just a case of working it out. The metadata thing was just a totally different approach at it really :P

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

How are you storing the data that controls the orientation of your block then?

 

Do you have the texture rendering code handling each possible wanted orientation of the block? If not, then this would be a good first step.

 

If you do not mind sharing it, I would like to see how you are handling block orientation.

Link to comment
Share on other sites

How are you storing the data that controls the orientation of your block then?

 

Do you have the texture rendering code handling each possible wanted orientation of the block? If not, then this would be a good first step.

 

If you do not mind sharing it, I would like to see how you are handling block orientation.

Link to comment
Share on other sites

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.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block
{
    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @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 : 0));
    }

    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)));
    }
}

 

That's the whole class file of a block which has the buggy rotation on.

The code I got, I managed to work out from piston. What I did was copied the whole piston code, and commented things out line by line to see what was important, and what wasn't. The code there is what was left at the end, everything "important"

(Personally, I see why it's all required except getRenderType. I don't know why it's needed, but if I comment it out it doesn't rotate, so obviously it is :P)

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

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.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class RBDoubleYellowStripe extends Block
{
    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setCreativeTab(Roads.tabRoads);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
    }
    
    @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 : 0));
    }

    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)));
    }
}

 

That's the whole class file of a block which has the buggy rotation on.

The code I got, I managed to work out from piston. What I did was copied the whole piston code, and commented things out line by line to see what was important, and what wasn't. The code there is what was left at the end, everything "important"

(Personally, I see why it's all required except getRenderType. I don't know why it's needed, but if I comment it out it doesn't rotate, so obviously it is :P)

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Use Temu coupon code $100 off [acq783769] for Australia and new zealand. Also get special 30% discount Plus get free shipping Temu has always been a shopper's paradise, offering a vast collection of trending items at unbeatable prices. With fast delivery and free shipping to 67 countries, it's no wonder Temu has become a go-to platform for savvy shoppers. Now, with these exclusive Temu coupon codes, you can enjoy even more savings: act581784: Temu coupon code 40% off for existing users act581784: $100 off Temu coupon for new customers act581784: $100 off Temu coupon for existing customers act581784: 40% discount for new users act581784: Temu coupon code 40 off for existing and new users Why You Shouldn't Miss Out on the Temu Coupon Code 40% Off The Temu coupon code 40% off is a game-changer for both new and existing customers. Whether you're a first-time user or a loyal Temu shopper, these codes offer substantial savings on your purchases. With a flat 40% extra off, you can stretch your budget further and indulge in more of your favorite items. Maximizing Your Savings with Temu 40 Off Coupon Code To make the most of your Temu shopping experience, it's crucial to understand how to apply these coupon codes effectively. When you use the Temu coupon code 40 off, you're not just saving money – you're unlocking a world of possibilities. From fashion to home decor, electronics to beauty products, your 40% discount applies across a wide range of categories. How to Apply Your Temu Coupon Code 40% Off Using your Temu coupon code 40% off is a breeze. Here's a step-by-step guide to ensure you don't miss out on these incredible savings: Browse through Temu's extensive collection and add your desired items to your cart. Proceed to checkout when you're ready to make your purchase. Look for the "Promo Code" or "Coupon Code" field. Enter your Temu coupon code 40 off [act581784]. Watch as your total amount gets reduced by a whopping 40%! The Power of Temu Coupon Code 40 Off First Order For those new to Temu, the Temu coupon code 40% off first order is an excellent opportunity to experience the platform's offerings at a discounted price. This introductory offer allows you to explore Temu's vast catalog while enjoying significant savings on your inaugural purchase.Be sure to use it before it expires!
    • Use Temu Coupon Code $100 Off [act965193] if you are living in California USA. Temu doesn't let you use many coupons at once, but you can still save more. New users get an extra 10% off the 30% discount. Also, text alerts give you 20% off. Using these with Temu's 90% off Daily Deals helps you save a lot. How to use Temu Coupon Code $100 Off [act965193] Both new and existing users at Temu can save a lot by using coupon codes and bundles. New users get a $200 discount with the code aci384098 on their first buy. This is a big welcome bonus that helps them save right away. Follow below steps to apply Temu Coupon Code $100 Off [act965193] Choose Your Items: Pick the products you want to buy from TEMU. Go to Checkout: When you are ready to pay, go to the checkout page. Enter the Code: Type (act847220) into the coupon code box. Enjoy Your Savings: Your total will be reduced, and you'll save money on your purchase. Keep an eye on new deals to save more. Check the Temu app, sign up for newsletters, and follow Temu on social media. Sites like RetailMeNot or Coupons.com also list Temu coupon codes, so you won't miss out.   Using these tips, shopping on Temu can be a smart way to save money. Plan your buys with sale cycles in mind, stack coupons wisely, and watch for new deals. This will make your shopping trips more rewarding.   Temu Coupon Codes & Bundles: New Installs and Existing Users For existing customers, the code aci384098 also gives $200 off. The Temu $200 Coupon Bundle is great for both new and current users. It includes $120 worth of coupons. Plus, Temu offers a 40% discount with certain codes for everyone.   Temu also has special app discounts. By signing up with the code aci384098 and spending $200 or more, customers can save $200 plus get 30% off on their purchase. The code aci384098 also gives a $200 discount and an extra 50% off on the next buy. This is a great way to thank users for their engagement.   Shopping at Temu can lead to big savings. The average discount is an impressive 59%, with 84% of orders getting free shipping or gifts. About 48% of discounts have a time limit, encouraging shoppers to act fast. With deals like a $100 coupon bundle for new users and savings from the code aci384098, Temu offers many ways to save.   Existing customers also have many ways to save, like app alerts, website coupons, and referral programs. There are also games, seasonal sales, and discounts on certain items. This means both new and current users have lots of options to save, showing Temu's dedication to rewarding users.   Comparing Temu Coupon Codes with Other Retailers   Looking at the world of online shopping, comparing Temu coupon codes with others shows Temu's big competitive advantages.   Advantages of Temu Coupons   Temu's coupons offer big discounts, often more than other stores. This means customers save a lot of money. Temu also throws in freebies, making their coupons even more valuable.   Temu's coupons work on many products, not just a few. This makes it easy for customers to save on what they buy.   How Temu Stands Out in the Market   When we look at Temu vs. other retailers, Temu's deals are made with the customer in mind. They focus on what shoppers want and need. This makes Temu's coupons not just competitive but also very attractive to many buyers.   Our benchmarking deals show Temu leading in coupon offers. They offer big discounts and special perks. This makes Temu stand out in the online shopping world.   Conclusion Using Temu coupon codes and bundles helps save money and make shopping better. For new and returning customers, codes like "acr880792" and "aci384098" offer big discounts. New users get £20 off their first order and up to 50% off on various deals. Temu offers many coupons for smart shoppers to save more. Whether it's standalone discounts, special deals, or loyalty rewards, using these codes can cut down costs. This way, shoppers get quality products at great prices, from $1 phone cases to discounted electronics. It's important to keep up with new discounts and promotions. By watching daily deals and signing up for alerts, shoppers won't miss out on great offers. Temu connects manufacturers directly with consumers, leading to lower costs. This unique approach, along with big savings from coupons, makes Temu a top choice for budget-friendly shopping. Start your Temu shopping today for unmatched savings and satisfaction.  
    • Obtén hasta 90% de descuento en Temu utilizando el código [act892435]. Además, disfruta de $100 de descuento (aproximadamente 1,750 MXN) en tu primer pedido. Disponible para nuevos y clientes existentes en México. En Temu encontrarás una amplia gama de productos, desde ropa hasta tecnología, todos a precios increíbles. Aprovecha este código hoy mismo y comienza a ahorrar en tus compras. Temu hace que tus compras sean fáciles y accesibles, asegurando que obtengas la mejor calidad al mejor precio. Looking for the best deals and discounts? The Temu coupon code [act892435] or [acq943609] offers fantastic savings for both new and existing customers. Whether you're placing your first order or restocking your favorites, these coupon codes unlock discounts of up to 90% and an additional $100 off on selected items. Plus, enjoy the added benefit of free shipping on select orders. This guide will show you how to make the most of these deals and maximize your savings on Temu. How to Use the Temu Coupon Code [act892435] or [acq943609] Applying the Temu coupon code is quick and easy. Here’s how to redeem it for maximum savings: 1. Visit the Temu Website: Explore Temu’s wide range of products, including fashion, electronics, and home goods. 2. Add Items to Your Cart: Choose the products you want and add them to your shopping cart. 3. Proceed to Checkout: Click on your cart and proceed to checkout when you're ready. 4. Enter the Coupon Code: In the "Coupon Code" field at checkout, enter [act892435] or [acq943609] and click "Apply." 5. Enjoy Your Savings: You’ll instantly see the $100 discount along with additional savings of up to 90%, depending on the items selected. Benefits of Temu Coupon Codes [act892435] or [acq943609] for First-Time Users and Existing Customers Whether you're a new customer or a regular shopper, the Temu coupon code offers unbeatable discounts. Here's how both new and existing users can benefit: • First-Time Users: New customers using the Temu coupon code [act892435] or [acq943609] on their first order get $100 off, along with discounts ranging from 30% to 90% on selected products. It’s the perfect opportunity to try out Temu’s product range without overspending. • Existing Customers: Loyal shoppers can continue to enjoy significant savings by applying the same coupon code on subsequent orders. Restock your favorites or discover new items at discounted prices. • Free Shipping: Using the Temu coupon code [act892435] or [acq943609] can also qualify you for free shipping on selected items, further increasing your overall savings. Breakdown of Discounts with Temu Coupon Code [act892435] or [acq943609] With the Temu coupon code [act892435] or [acq943609], you’re not limited to just $100 off. You can also enjoy varying levels of discounts on a wide range of products. Here’s how it works: • 30% Discount: Perfect for budget-friendly products and everyday essentials. Shop clothing, beauty products, and home goods at 30% off. • 40% Discount: Ideal for mid-range purchases such as electronics, gadgets, and household items. • 50% Discount: Save big on high-end gadgets, designer apparel, and premium beauty products with 50% off. • 70% Discount: Excellent for those looking for luxury items like branded accessories and upscale electronics. • 90% Discount: The ultimate deal for savvy shoppers. Enjoy top-tier products like tech and home goods at a fraction of the price. Maximize Your Savings on First Orders, Free Shipping, and More with Temu Coupon Code [act892435] or [acq943609] Here are some top tips to get the most value from the Temu coupon code [act892435] or [acq943609]: 1. First Order Savings: For first-time users, using the code [act892435] or [acq943609] on your first order guarantees $100 off, making it the perfect way to kickstart your shopping experience at Temu. 2. Look for Free Shipping: Check if your items qualify for free shipping by applying the coupon code at checkout. It’s a great way to save even more on your total purchase. 3. Shop During Major Sales: Combine the coupon code with major sales events like Black Friday or Cyber Monday for even greater savings. 4. Buy in Bulk: Bulk purchases allow you to maximize the value of the $100 discount, especially if you’re buying items across various categories. 5. Check Product Eligibility: Make sure the products you’re adding to your cart qualify for higher percentage discounts. Some items may only offer 30%-50% off, while others can go up to 90%. FAQs About Temu Coupon Code [act892435] or [acq943609] 1. Is the Temu coupon code verified and working?  Yes, the Temu coupon codes [act892435] and [acq943609] are verified and currently active. Both codes offer up to $100 off, along with percentage discounts of up to 90%. 2. How much can I save with the Temu coupon code?  Using the coupon codes [act892435] or [acq943609], you can get $100 off plus additional percentage-based discounts ranging from 30% to 90%, depending on the products you choose. 3. Can both first-time users and existing customers use these coupon codes?  Absolutely! Both new and existing customers can take advantage of the Temu coupon codes [act892435] or [acq943609]. First-time users can apply the code for their first order, while loyal customers can continue saving on subsequent purchases. 4. Does the coupon code apply to free shipping?  In many cases, using the Temu coupon code [act892435] or [acq943609] may qualify you for free shipping, depending on the items and promotions available at the time of purchase. Conclusion: Don’t Miss Out on These Massive Savings with Temu Coupon Code [act892435] or [acq943609] The Temu coupon code [act892435] or [acq943609] provides an excellent opportunity to save big on a wide variety of products. Whether you're a first-time user placing your first order or an existing customer looking to restock, these coupon codes guarantee substantial savings. Take advantage of discounts up to 90%, free shipping on select orders, and $100 off when you shop at Temu. Don’t wait—start shopping today and use the coupon codes [act892435] or [acq943609] to unlock the best possible deals! Happy shopping!
    • Get up to 90% off at Temu using coupon code [act892435]. Receive $100 off (5,650 PHP) on your first order. Available for both new and existing customers in the Philippines. Get up to 90% off at Temu using the coupon code [act892435]. Receive $100 off on your first order, available for both new and existing customers in all country. Temu offers a diverse range of products from clothing to gadgets, all at unbeatable prices. Start saving today and enjoy a seamless shopping experience. Whether you're a first-time buyer or a regular customer, Temu helps you get more for less. Use the code now and turn your shopping into a rewarding experience filled with savings. Looking for the best deals and discounts? The Temu coupon code [act892435] or [acq943609] offers fantastic savings for both new and existing customers. Whether you're placing your first order or restocking your favorites, these coupon codes unlock discounts of up to 90% and an additional $100 off on selected items. Plus, enjoy the added benefit of free shipping on select orders. This guide will show you how to make the most of these deals and maximize your savings on Temu. How to Use the Temu Coupon Code [act892435] or [acq943609] Applying the Temu coupon code is quick and easy. Here’s how to redeem it for maximum savings: 1. Visit the Temu Website: Explore Temu’s wide range of products, including fashion, electronics, and home goods. 2. Add Items to Your Cart: Choose the products you want and add them to your shopping cart. 3. Proceed to Checkout: Click on your cart and proceed to checkout when you're ready. 4. Enter the Coupon Code: In the "Coupon Code" field at checkout, enter [act892435] or [acq943609] and click "Apply." 5. Enjoy Your Savings: You’ll instantly see the $100 discount along with additional savings of up to 90%, depending on the items selected. Benefits of Temu Coupon Codes [act892435] or [acq943609] for First-Time Users and Existing Customers Whether you're a new customer or a regular shopper, the Temu coupon code offers unbeatable discounts. Here's how both new and existing users can benefit: • First-Time Users: New customers using the Temu coupon code [act892435] or [acq943609] on their first order get $100 off, along with discounts ranging from 30% to 90% on selected products. It’s the perfect opportunity to try out Temu’s product range without overspending. • Existing Customers: Loyal shoppers can continue to enjoy significant savings by applying the same coupon code on subsequent orders. Restock your favorites or discover new items at discounted prices. • Free Shipping: Using the Temu coupon code [act892435] or [acq943609] can also qualify you for free shipping on selected items, further increasing your overall savings. Breakdown of Discounts with Temu Coupon Code [act892435] or [acq943609] With the Temu coupon code [act892435] or [acq943609], you’re not limited to just $100 off. You can also enjoy varying levels of discounts on a wide range of products. Here’s how it works: • 30% Discount: Perfect for budget-friendly products and everyday essentials. Shop clothing, beauty products, and home goods at 30% off. • 40% Discount: Ideal for mid-range purchases such as electronics, gadgets, and household items. • 50% Discount: Save big on high-end gadgets, designer apparel, and premium beauty products with 50% off. • 70% Discount: Excellent for those looking for luxury items like branded accessories and upscale electronics. • 90% Discount: The ultimate deal for savvy shoppers. Enjoy top-tier products like tech and home goods at a fraction of the price. Maximize Your Savings on First Orders, Free Shipping, and More with Temu Coupon Code [act892435] or [acq943609] Here are some top tips to get the most value from the Temu coupon code [act892435] or [acq943609]: 1. First Order Savings: For first-time users, using the code [act892435] or [acq943609] on your first order guarantees $100 off, making it the perfect way to kickstart your shopping experience at Temu. 2. Look for Free Shipping: Check if your items qualify for free shipping by applying the coupon code at checkout. It’s a great way to save even more on your total purchase. 3. Shop During Major Sales: Combine the coupon code with major sales events like Black Friday or Cyber Monday for even greater savings. 4. Buy in Bulk: Bulk purchases allow you to maximize the value of the $100 discount, especially if you’re buying items across various categories. 5. Check Product Eligibility: Make sure the products you’re adding to your cart qualify for higher percentage discounts. Some items may only offer 30%-50% off, while others can go up to 90%. FAQs About Temu Coupon Code [act892435] or [acq943609] 1. Is the Temu coupon code verified and working? Yes, the Temu coupon codes [act892435] and [acq943609] are verified and currently active. Both codes offer up to $100 off, along with percentage discounts of up to 90%. 2. How much can I save with the Temu coupon code? Using the coupon codes [act892435] or [acq943609], you can get $100 off plus additional percentage-based discounts ranging from 30% to 90%, depending on the products you choose. 3. Can both first-time users and existing customers use these coupon codes? Absolutely! Both new and existing customers can take advantage of the Temu coupon codes [act892435] or [acq943609]. First-time users can apply the code for their first order, while loyal customers can continue saving on subsequent purchases. 4. Does the coupon code apply to free shipping? In many cases, using the Temu coupon code [act892435] or [acq943609] may qualify you for free shipping, depending on the items and promotions available at the time of purchase. 5. Are there any exclusions with these coupon codes? While these coupon codes offer excellent discounts, some high-percentage offers may not apply to every item. Be sure to check product eligibility before completing your purchase. Conclusion: Don’t Miss Out on These Massive Savings with Temu Coupon Code [act892435] or [acq943609] The Temu coupon code [act892435] or [acq943609] provides an excellent opportunity to save big on a wide variety of products. Whether you're a first-time user placing your first order or an existing customer looking to restock, these coupon codes guarantee substantial savings. Take advantage of discounts up to 90%, free shipping on select orders, and $100 off when you shop at Temu. Don’t wait—start shopping today and use the coupon codes [act892435] or [acq943609] to unlock the best possible deals! Happy shopping!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.