mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Add use context and simulate flag to getToolModifiedState, enabled HOE_TILL action. (#8557)
This commit is contained in:
1 parent
94ce098056
commit
7d79f0d581
12 files changed
+268
-74
No files matched your search
@@ -9,7 +9,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent.BlockToolInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.BlockToolModificationEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod("tool_interact_test")
|
||||
@@ -17,16 +17,16 @@ public class ToolInteractTest
|
||||
{
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
|
||||
public ToolInteractTest()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onToolInteraction);
|
||||
}
|
||||
|
||||
private void onToolInteraction(final BlockToolInteractEvent event)
|
||||
|
||||
private void onToolInteraction(final BlockToolModificationEvent event)
|
||||
{
|
||||
//Test 1: No Changes, just test if event is called. State and Final State should be the same
|
||||
LOGGER.info("BlockState {} is modified to {} at position {} by {} with {}", event.getState(), event.getFinalState(), event.getPos(), event.getPlayer(), event.getHeldItemStack());
|
||||
LOGGER.info("BlockState {} is modified to {} at position {} by {} with {} simulated={}", event.getState(), event.getFinalState(), event.getPos(), event.getPlayer(), event.getHeldItemStack(), event.isSimulated());
|
||||
|
||||
//Test 2: Canceling, nothing in game should change
|
||||
/*event.setCanceled(true);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CustomShieldTest
|
||||
@Override
|
||||
public boolean canPerformAction(ItemStack stack, ToolAction toolAction)
|
||||
{
|
||||
return toolAction.equals(ToolActions.SHIELD_BLOCK);
|
||||
return toolAction == ToolActions.SHIELD_BLOCK;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user