@Override public ItemStack getCraftingResult(IInventory inventory) { ItemStack skinStack = null; ItemStack blackStack = null; for (int slotId = 0; slotId < inventory.getSizeInventory(); slotId++) { ItemStack stack = inventory.getStackInSlot(slotId); if (stack != null) { Item item = stack.getItem(); if (item == ModItems.equipmentSkin && EquipmentNBTHelper.stackHasSkinData(stack)) { if (skinStack != null) { return null; } skinStack = stack; } else if (item == ModItems.equipmentSkinTemplate & !EquipmentNBTHelper.stackHasSkinData(stack)) { if (blackStack != null) { return null; } blackStack = stack; } else { return null; } } } if (skinStack != null && blackStack != null) { ItemStack returnStack = new ItemStack(ModItems.equipmentSkin, 1); SkinPointer skinData = EquipmentNBTHelper.getSkinPointerFromStack(skinStack); EquipmentNBTHelper.addSkinDataToStack(returnStack, skinData.skinType, skinData.skinId, false); return returnStack; } return null; }
@Override public IIcon getIcon(ItemStack stack, int pass) { if (pass == 1) { return this.loadingIcon; } if (EquipmentNBTHelper.stackHasSkinData(stack)) { SkinPointer skinData = EquipmentNBTHelper.getSkinPointerFromStack(stack); if (skinData.skinType != null) { if (skinData.skinType.getIcon() != null) { return skinData.skinType.getIcon(); } } } return this.itemIcon; }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { Block block = world.getBlock(x, y, z); SkinPointer skinPointer = EquipmentNBTHelper.getSkinPointerFromStack(stack); if (skinPointer != null && skinPointer.getSkinType() == SkinTypeRegistry.skinBlock) { ForgeDirection dir = ForgeDirection.getOrientation(side); Block replaceBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); if (replaceBlock.isReplaceable(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) { if (!world.isRemote) { int l = MathHelper.floor_double((double) (player.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15; world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.skinnable); world.setBlockMetadataWithNotify(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, l, 2); world.setTileEntity( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ((ITileEntityProvider) ModBlocks.skinnable).createNewTileEntity(world, 0)); TileEntitySkinnable te = (TileEntitySkinnable) world.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); te.setSkinPointer(skinPointer); stack.stackSize--; } return true; } } return false; }
public static void addTooltipToSkinItem( ItemStack stack, EntityPlayer player, List tooltip, boolean showAdvancedItemTooltips) { String cRed = EnumChatFormatting.RED.toString(); boolean isEquipmentSkin = stack.getItem() == ModItems.equipmentSkin; boolean isEquipmentContainer = stack.getItem() instanceof AbstractModItemArmour; if (EquipmentNBTHelper.stackHasSkinData(stack)) { SkinPointer skinData = EquipmentNBTHelper.getSkinPointerFromStack(stack); if (!isEquipmentSkin & !skinData.lockSkin & !isEquipmentContainer) { return; } if (!isEquipmentSkin) { tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.hasSkin")); } if (ClientModelCache.INSTANCE.isEquipmentInCache(skinData.skinId)) { Skin data = ClientModelCache.INSTANCE.getEquipmentItemData(skinData.skinId); if (!data.getCustomName().trim().isEmpty()) { tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinName", data.getCustomName())); } if (!data.getAuthorName().trim().isEmpty()) { tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinAuthor", data.getAuthorName())); } if (ConfigHandler.showSkinTooltipDebugInfo) { if (GuiScreen.isShiftKeyDown()) { if (skinData.skinType != null) { String localSkinName = SkinTypeRegistry.INSTANCE.getLocalizedSkinTypeName(skinData.skinType); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinType", localSkinName)); } tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinId", skinData.skinId)); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinTotalCubes", data.getTotalCubes())); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinNumCubes", data.getTotalOfCubeType(Cube.class))); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinNumCubesGlowing", data.getTotalOfCubeType(CubeGlowing.class))); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinNumCubesGlass", data.getTotalOfCubeType(CubeGlass.class))); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinNumCubesGlassGlowing", data.getTotalOfCubeType(CubeGlassGlowing.class))); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinPaintData", data.hasPaintData())); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinMarkerCount", data.getMarkerCount())); } else { tooltip.add( TranslateUtils.translate("item.armourersworkshop:rollover.skinHoldShiftForInfo")); } } if (skinData.skinId != data.lightHash()) { tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdError1")); tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdError2")); tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skinIdError3", data.requestId, data.lightHash())); } } else { tooltip.add( TranslateUtils.translate( "item.armourersworkshop:rollover.skindownloading", skinData.skinId)); } String keyName = Keyboard.getKeyName(Keybindings.openCustomArmourGui.getKeyCode()); if (isEquipmentSkin) { tooltip.add( TranslateUtils.translate("item.armourersworkshop:rollover.skinOpenWardrobe", keyName)); } } else { if (EquipmentNBTHelper.stackHasLegacySkinData(stack)) { tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinOldType")); } else { if (isEquipmentSkin) { tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinInvalidItem")); } } } }