use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project AgriCraft by AgriCraft.
the class ItemToolTipHandler method addClipperTooltip.
/**
* Adds tooltips to items that are clippers (implementing IClipper).
*
* @param event
*/
@SubscribeEvent
public void addClipperTooltip(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
if (StackHelper.isValid(stack, IAgriClipperItem.class)) {
event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.clipper1"));
event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.clipper2"));
event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.clipper3"));
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project BetterWithAddons by DaedalusGame.
the class AssortedHandler method attachRopeEvent.
@SubscribeEvent
public void attachRopeEvent(PlayerInteractEvent.RightClickBlock event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = world.getBlockState(pos);
ItemStack stack = event.getItemStack();
EnumFacing facing = event.getFace();
EntityPlayer player = event.getEntityPlayer();
if (stack.getItem() == Item.getItemFromBlock(BWMBlocks.ROPE) && state.getBlock() instanceof BlockFence && state.getBlock() != ModBlocks.ropePost) {
ModBlocks.ropePost.placeFencePost(world, pos);
state = world.getBlockState(pos);
int consumedRope = 1;
if (BlockRopeSideways.canFastenBlock(state.getBlock())) {
consumedRope += attachRope(world, pos, facing, Math.min(stack.getCount() - 1, ropeLimit));
}
if (!player.isCreative())
stack.shrink(consumedRope);
event.setCancellationResult(EnumActionResult.SUCCESS);
event.setCanceled(true);
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project BetterWithAddons by DaedalusGame.
the class AssortedHandler method onDismount.
@SubscribeEvent
public void onDismount(EntityMountEvent event) {
Entity rider = event.getEntityMounting();
Entity mount = event.getEntityBeingMounted();
/*if(!rider.isDead && !mount.isDead) {
//if (event.isDismounting() && mount instanceof EntityHorse)
// event.setCanceled(true);
if (event.isDismounting() && mount instanceof EntityKarateZombie && !((EntityKarateZombie) mount).tryDismount())
event.setCanceled(true);
}*/
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project BetterWithAddons by DaedalusGame.
the class WheatHandler method harvestBlock.
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void harvestBlock(BlockEvent.HarvestDropsEvent event) {
if (!InteractionWheat.REPLACE_WHEAT_DROPS)
return;
IBlockState state = event.getState();
if (state.getBlock() != Blocks.WHEAT)
return;
List<ItemStack> drops = event.getDrops();
if (drops instanceof ImmutableList)
// Give up immediately, there's a mod that blocks all the fun.
return;
ListIterator<ItemStack> iterator = drops.listIterator();
while (iterator.hasNext()) {
ItemStack stack = iterator.next();
if (stack.getItem() == Items.WHEAT)
iterator.set(ModItems.materialWheat.getMaterial("hay", stack.getCount()));
if (stack.getItem() == Items.WHEAT_SEEDS)
iterator.set(new ItemStack(Items.WHEAT, stack.getCount()));
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project BetterWithAddons by DaedalusGame.
the class WheatHandler method breakSpeed.
@SubscribeEvent
public static void breakSpeed(PlayerEvent.BreakSpeed event) {
if (!InteractionWheat.DIG_UP_CROPS)
return;
if (toolMaterialField == null)
toolMaterialField = ReflectionHelper.findField(ItemHoe.class, "field_77843_a", "toolMaterial");
EntityPlayer player = event.getEntityPlayer();
if (player == null)
return;
IBlockState state = event.getState();
Block block = state.getBlock();
ItemStack tool = player.getHeldItemMainhand();
if (tool.getItem() instanceof ItemHoe && "hoe".equals(block.getHarvestTool(state))) {
try {
Item.ToolMaterial material = (Item.ToolMaterial) toolMaterialField.get(tool.getItem());
if (material != null)
event.setNewSpeed(event.getNewSpeed() * material.getEfficiency());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Aggregations