Jump to content

Recommended Posts

Posted

So what I am trying to do is to get my custom fire block to break like the vanilla one, so far I have it working in survival mode, but it still breaks the block that the fire is on in creative mode.

 

This is my current working code:

 

 

public class BreakEvents

{

@SubscribeEvent

public void extinguishFire(PlayerInteractEvent event)

{

boolean flag = event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK ? true : false;

BlockPos pos = event.pos;

World theWorld = event.world;

EnumFacing side = event.face;

ItemInWorldManager theItemInWorldManager = new ItemInWorldManager(theWorld);

EntityPlayerMP thisPlayerMP = theItemInWorldManager.thisPlayerMP;

 

if (flag)

{

Block block = theWorld.getBlockState(pos).getBlock();

 

if (!block.isAir(theWorld, pos))

{

if (event.useBlock != Result.DENY)

{

block.onBlockClicked(theWorld, pos, thisPlayerMP);

this.extinguishFire((EntityPlayer) null, pos, side, event);

}

else

{

thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(theWorld, pos));

}

}

}

}

 

private boolean extinguishFire(EntityPlayer player, BlockPos pos, EnumFacing side, PlayerInteractEvent event)

{

World world = event.world;

pos = pos.offset(side);

 

if (world.getBlockState(pos).getBlock() == Blocks_and_Items.fire_block)

{

world.playAuxSFXAtEntity(player, 1004, pos, 0);

world.setBlockToAir(pos);

return true;

}

else

{

return false;

}

}

}

 

 

Posted

I think you should call block.onBlockClicked(theWorld, pos, thisPlayerMP); after extinguishFire, and do not click the block when there was no fire there.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

So I tried putting the onBlockClicked after the extinguishFire, but it still doesn't work. Also in my console I have "Model defenition for location modid:block_fire#inventory not found, how do I get rid of this?

Posted

So I tried putting the onBlockClicked after the extinguishFire, but it still doesn't work. Also in my console I have "Model defenition for location modid:block_fire#inventory not found, how do I get rid of this?

and do not click the block when there was no fire there

And that message is another problem. Do you have proper model for your fire?

 

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Yes, its just for the inventory model that I don't need, cause if you check, vanilla doesn't have an inventory model for fire

Then that is not a problem I think. (Also I dont know how to make the message disappear)

 

Anyway, Do this:

and do not click the block when there was no fire there

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.