@SideOnly(Side.CLIENT) @SubscribeEvent public void rightClickItem(RightClickItem event) { if (event.getSide().isClient() && event.getHand().equals(EnumHand.MAIN_HAND)) { if (rcicanactive == true) { System.out.println("RightClickItem,HandType=" + event.getHand()); ActiveTripod(Minecraft.getMinecraft().thePlayer.getName(), ((EntityTripod) event.getWorld() .getEntityByID(event.getEntityPlayer().getEntityData().getInteger("renderViewCamera"))) .getDelay()); event.setCanceled(true); } if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera")) { rcicanactive = true; } } }
@SubscribeEvent public void interact(RightClickItem event) { ItemStack stack = event.getItemStack(); Item item = stack.getItem(); if(item instanceof IItemSpell) { IItemSpell spell = (IItemSpell)item; EntityPlayer player = event.getEntityPlayer(); if(player.getCooldownTracker().hasCooldown(item)) return; // Cast item spell spell.cast(player, stack); if(spell.getType() == SpellType.CLICK) { player.getCooldownTracker().setCooldown(item, spell.getCooldown()); } else if(spell.getType() == SpellType.HOLD) { IPlayerData data = player.getCapability(CapabilityProvider.PLAYER_DATA, null); data.setHoldItem(item); data.setHoldTicks(0); System.out.println("RENEW"); } } }
@SubscribeEvent public void onRightclickNonedible(RightClickItem event) { ItemStack emblem = BaublesApi.getBaublesHandler(event.getEntityPlayer()).getStackInSlot(6); if (emblem == null || (emblem != null && emblem.getItem() != this)) return; ItemStack stack = event.getItemStack(); if (!event.getWorld().isRemote) tryConvertToFood(stack, event.getEntityPlayer(), event.getHand()); }
@SubscribeEvent public void readBook(RightClickItem event) { if (event.getWorld().isRemote) { return; } ItemStack item = event.getItemStack(); if (!DiscoveryUtil.isDiscoveryBook(item)) { return; } event.setCanceled(true); if (!NemesisConfig.DISCOVERY_ENABLED) { return; } NemesisDiscovery discovery = DiscoveryUtil.readBook(event.getWorld(), item); if (discovery == null) { event.getEntityPlayer().sendMessage(new TextComponentString("Nemesis no longer exists")); return; } DiscoveryUtil.newDiscovery(event.getEntityPlayer(), discovery); NemesisEntry nemesis = NemesisRegistryProvider.get(event.getWorld()).getById(discovery.nemesisId); if (nemesis == null) { event.getEntityPlayer().sendMessage(new TextComponentString("Nemesis no longer exists")); return; } NemesisKnowledge knowledge = DiscoveryUtil.getGetPlayerKnowledgeOfNemesis(event.getEntityPlayer(), nemesis.getId()); if (knowledge == null) { knowledge = new NemesisKnowledge(); } MinecraftForge.EVENT_BUS.post(new DiscoveryEvent(nemesis, discovery, event.getEntityPlayer())); NemesisSystem.NETWORK.sendTo(new MessageOpenNemesisDetailsGui(nemesis, knowledge), (EntityPlayerMP) event.getEntityPlayer()); }