Hi I was wondering if someone could show me how to make my multitextured block face the direction im standing when I place it like a pumpkin or a jackolantern
You have to set the metadata based on the rotation of the player. I use this:
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
{
int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
switch (l)
{
case 0:
world.setBlockMetadataWithNotify(i, j, k, 2);
break;
case 1:
world.setBlockMetadataWithNotify(i, j, k, 5);
break;
case 2:
world.setBlockMetadataWithNotify(i, j, k, 3);
break;
case 3:
world.setBlockMetadataWithNotify(i, j, k, 4);
break;
}
}
If your face side of the block isn't where you want it to be then just change the side it renders on in the getBlockTextureFromSideAndMetadata method.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Basically I think he has run into the same thing I have onBlockPlacedBy wont initialize, so there is somewhere it needs to go, such as in the event handler in the main class.
It wont work when just "pasted" in there. On careful re-reading of what you are saying I think I understand, but not entirely. Nor do I understand how to use the cases (or if statements in the BlockFurnace file, which are essentially the same thing) to modify the metadata, but thats probably because of the first problem, not being able to activate it in the first place. If I'm commenting on a dead thread please let me know.
Also a link to your code would be nice, if it is available.
Basically I think he has run into the same thing I have onBlockPlacedBy wont initialize, so there is somewhere it needs to go, such as in the event handler in the main class.
It wont work when just "pasted" in there. On careful re-reading of what you are saying I think I understand, but not entirely. Nor do I understand how to use the cases (or if statements in the BlockFurnace file, which are essentially the same thing) to modify the metadata, but thats probably because of the first problem, not being able to activate it in the first place. If I'm commenting on a dead thread please let me know.
Also a link to your code would be nice, if it is available.
Here is my Block file:
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
public class ghostfaceBlock extends Block {
public ghostfaceBlock (int id, int texture, Material material) {
super(id, texture, material);
}
@Override
public String getTextureFile () {
return CommonProxy.BLOCK_PNG;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if (i == 0)
return 7;
if (i == 1)
return 7;
if (i == 2)
return 7;
if (i == 3)
return 7;
if (i == 4)
return 6; <-- this one is the face
if (i == 5)
return 7;
if (j ==1)
{
return 166;
}
return j != 2 ? 20 : 177;
}
}
If your face side of the block isn't where you want it to be then just change the side it renders on in the getBlockTextureFromSideAndMetadata method.
together they are powerful beyond imagination."
It didnt work do i have to edit that code?
together they are powerful beyond imagination."
Basically I think he has run into the same thing I have onBlockPlacedBy wont initialize, so there is somewhere it needs to go, such as in the event handler in the main class.
This is my code
https://github.com/Oscareli98/particular/blob/master/particular_common/particular/block/BlockHypersonicPiston.java
It wont work when just "pasted" in there.
On careful re-reading of what you are saying I think I understand, but not entirely. Nor do I understand how to use the cases (or if statements in the BlockFurnace file, which are essentially the same thing) to modify the metadata, but thats probably because of the first problem, not being able to activate it in the first place.
If I'm commenting on a dead thread please let me know.
Also a link to your code would be nice, if it is available.
Thanks!
-Hunterthe100
That really helped, thank you.