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 was messing around with dispenser behaviour and found that if the dispenser is replaced/destroyed/otherwise removed while dispensing, the game crashes with this in the log:

Spoiler

PM
Description: Exception while ticking a block

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[down, up, north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204)
    at net.minecraft.dispenser.BehaviorDefaultDispenseItem.dispense(BehaviorDefaultDispenseItem.java:18)
    at net.minecraft.block.BlockDispenser.dispense(BlockDispenser.java:153)
    at net.minecraft.block.BlockDispenser.updateTick(BlockDispenser.java:189)
    at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:774)
    at net.minecraft.world.WorldServer.tick(WorldServer.java:231)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:825)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:740)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:589)
    at java.lang.Thread.run(Thread.java:748)


What happened to cause this is pretty simple - I made the dispensed stack cause an explosion, however, I get the same result if I set the dispenser to a different block (air, for example).
I have tried removing the tile entity before setting the block to air and/or causing the explosion, but the result is the same.

Is there any way I can prevent this crash, other than delaying the explosion?

Edited by PegBeard

  • Author

I have a dispenser behaviour class, which is registered in the postInit:

 

Spoiler

public class DTDispensePowderKeg extends BehaviorDefaultDispenseItem
{
    @Override
	protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
    {
        World world = source.getWorld();
        BlockPos pos = source.getBlockPos();
        world.playSound((EntityPlayer)null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
        stack.shrink(1);
        world.removeTileEntity(pos);
        world.isAirBlock(pos);
        world.newExplosion((EntityPlayer)null, pos.getX()+0.5D, pos.getY()+0.5D, pos.getZ()+0.5D, 4.0F, true, true);
        return stack;
    }
}

 

Is this correct? I looked it up back in 1.8, and assumed this was still relevant, as my other dispenser behaviours still work.

  • Author

Oh. Is that something that changed since 1.8, or was the tutorial I followed back then wrong?

edit: the removeTileEntity was just testing for this issue, didn't intend to keep it.

Edited by PegBeard

11 minutes ago, PegBeard said:

Oh. Is that something that changed since 1.8, or was the tutorial I followed back then wrong?

Probably the latter.

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.