void changeFocus(ISceptreFocus focus, ItemStack stack) { ISceptreFocus oldFocus = getFocus(stack); if (oldFocus != null) oldFocus.onDeactivated(stack); if (focus != null) { stack.stackTagCompound.setString("focus", focus.getFocusIdentifier()); focus.onActivated(stack); } else stack.stackTagCompound.removeTag("focus"); }
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { ISceptreFocus focus = getFocus(stack); if (focus != null) focus.onClickBegin(player, stack, world); if (world.isRemote) { gestureManager = new GestureTrackMap(); lastOffset = new float[] {player.getRotationYawHead(), player.rotationPitch}; } player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); return stack; }
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { ISceptreFocus focus = getFocus(stack); return focus != null && focus.onBlockClick(stack, player, world, x, y, z, side, hitX, hitY, hitZ); }
public void onUpdate(ItemStack item, World world, Entity heldEnt, int meta, boolean held) { ItemUtils.checkCompound(item); if (!item.stackTagCompound.hasKey("colourData")) { NBTTagCompound colours = new NBTTagCompound(); colours.setFloat("r", 0.8F); colours.setFloat("g", 0.0F); colours.setFloat("b", 0.8F); } float rgb[] = null; NBTTagCompound colours = item.stackTagCompound.getCompoundTag("colourData"); if (item.stackTagCompound.hasKey("focus")) { ISceptreFocus focus = getFocus(item); if (focus != null) { focus.onItemTick(item); rgb = focus.getRGB(); } else item.stackTagCompound.removeTag("focus"); } if (rgb == null) rgb = new float[] {0.8F, 0F, 0.8F}; float oR = colours.getFloat("r"); float oG = colours.getFloat("g"); float oB = colours.getFloat("b"); if (oR > rgb[0] + step) oR -= step; else if (oR < rgb[0] - step) oR += step; if (oG > rgb[1] + step) oG -= step; else if (oG < rgb[1] - step) oG += step; if (oB > rgb[2] + step) oB -= step; else if (oB < rgb[2] - step) oB += step; colours.setFloat("r", oR); colours.setFloat("g", oG); colours.setFloat("b", oB); item.stackTagCompound.setTag("colourData", colours); }
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) { ISceptreFocus focus = getFocus(stack); if (focus != null && world.isRemote) { focus.onClickEnd(player, stack, world, count); } }