Posted December 29, 201410 yr I want to store the side my block is placed on by the player in a TileEntity, but it seems the TileEntity isnt generated yet the moment onBlockPlaced is called. Is there a way to save my orientation to my TileEntity? My code @Override public int onBlockPlaced(final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, final int metadata) { if (metadata == 0) { // This checkpoint gets passed MagicCookie.log.warn("We have side: "+side); final TileVoidCrystalStorage crystalstorage = (TileVoidCrystalStorage)world.getTileEntity(x, y, z); // This checkpoint fails horribly the code in this IF doesnt get executed. if (crystalstorage != null) { MagicCookie.log.warn("Do we have a orientation" + side); crystalstorage.orientation = (short)side; MagicCookie.log.warn("Do we have a orientation" + crystalstorage.orientation); world.markBlockForUpdate(x, y, x); } } return super.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, metadata); } How much wood could a woodchuck chuck if a wood chuck could chuck wood - Guybrush Treepwood I wrote my own mod ish... still a few bugs to fix. http://thaumcraft.duckdns.org/downloads/MagicCookies-1.0.6.4.jar
December 29, 201410 yr Author Eventually I fixed it by the BlockItem route. For those wanting to do the same: public class ItemBlockVoidManipulator extends ItemBlock { public ItemBlockVoidManipulator(Block block) { super(block); setHasSubtypes(true); // TODO Auto-generated constructor stub } @Override public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + itemstack.getItemDamage(); } @Override public int getMetadata (int damageValue) { return damageValue; } public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, final int metadata) { final boolean ret = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); if (metadata == 0) { final TileVoidCrystalStorage crystalstorage = (TileVoidCrystalStorage)world.getTileEntity(x, y, z); if (crystalstorage != null/* && crystalstorage instanceof TileVoidCrystalStorage*/) { crystalstorage.orientation = (short)side; world.markBlockForUpdate(x, y, x); } } return ret; } } How much wood could a woodchuck chuck if a wood chuck could chuck wood - Guybrush Treepwood I wrote my own mod ish... still a few bugs to fix. http://thaumcraft.duckdns.org/downloads/MagicCookies-1.0.6.4.jar
December 29, 201410 yr It's amazing what calling super can do. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.