ForgePatch/common/net/minecraftforge/event/ForgeEventFactory.java
2012-12-12 23:27:57 -08:00

36 lines
1.4 KiB
Java

package net.minecraftforge.event;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
public class ForgeEventFactory
{
public static boolean doPlayerHarvestCheck(EntityPlayer player, Block block, boolean success)
{
PlayerEvent.HarvestCheck event = new PlayerEvent.HarvestCheck(player, block, success);
MinecraftForge.EVENT_BUS.post(event);
return event.success;
}
public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original)
{
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, block, metadata, original);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed);
}
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face)
{
PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack)
{
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack));
}
}