Jump to content

[Solved] [1.12] Exception while ticking a dispenser


PegBeard

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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



×
×
  • Create New...

Important Information

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