Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • 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

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.