Open main menu
Home
Random
Log in
Settings
About Forge Community Wiki
Disclaimers
Forge Community Wiki
Search
Changes
← Older edit
Events/BlockEvent
(view source)
Revision as of 18:46, 20 April 2021
692 bytes added
,
18:46, 20 April 2021
no edit summary
Line 166:
Line 166:
{
{
event.setResult(Event.Result.DENY); // make bamboo grow less often
event.setResult(Event.Result.DENY); // make bamboo grow less often
+
}
+
}
+
}
+
+
public void onCropsGrowPost(final BlockEvent.CropGrowEvent.Post event)
+
{
+
IWorld world = event.getWorld();
+
if (!world.isClientSide() && event.getState().is(Blocks.WHEAT)) // check wheat
+
{
+
BlockState newState = event.getState();
+
if (newState.is(Blocks.WHEAT)) // defensive check to make sure we can do this
+
{
+
world.setBlock(event.getPos(), newState.setValue(CropsBlock.AGE, 7), 3); // set max growth wheat
}
}
}
}
Line 201:
Line 214:
This is mostly used for preventing portal spawning in certain dimensions (even the overworld).
This is mostly used for preventing portal spawning in certain dimensions (even the overworld).
+
+
Example usage:
+
<syntaxhighlight lang="java">
+
public void onPortalLight(final BlockEvent.PortalSpawnEvent event)
+
{
+
event.setCanceled(true);
+
}
+
</syntaxhighlight>
== BlockToolInteractEvent ==
== BlockToolInteractEvent ==
EERussianguy
16
edits