Search in sources :

Example 46 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class SkinItemRenderHelper method renderSkinAsItem.

public static void renderSkinAsItem(ItemStack stack, boolean showSkinPaint, int targetWidth, int targetHeight) {
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
        renderSkinAsItem(skinPointer, showSkinPaint, false, targetWidth, targetHeight);
    }
}
Also used : ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

Example 47 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class SkinModelRenderer method renderEquipmentPartFromStack.

public boolean renderEquipmentPartFromStack(ItemStack stack, ModelBiped modelBiped, byte[] extraColours, double distance, boolean doLodLoading) {
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
    if (skinPointer == null) {
        return false;
    }
    Skin data = getCustomArmourItemData(skinPointer);
    return renderEquipmentPart(null, modelBiped, data, skinPointer.getSkinDye(), extraColours, distance, doLodLoading);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) AbstractModelSkin(riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)

Example 48 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class SkinPreviewHandler method onDrawScreenPre.

@SubscribeEvent
public void onDrawScreenPre(DrawScreenEvent.Post event) {
    if (!ConfigHandlerClient.skinPreEnabled) {
        return;
    }
    if (!ConfigHandlerClient.skinPreLocFollowMouse) {
        return;
    }
    SkinPointer skinPointer = lastSkinPointer;
    List<String> list = lastList;
    lastSkinPointer = null;
    lastList = null;
    if (skinPointer != null & list != null) {
        Minecraft mc = Minecraft.getMinecraft();
        float skinPreSize = ConfigHandlerClient.skinPreSize;
        int[] toolTipSize = getTooltipSize(list, mc.currentScreen.width, mc.currentScreen.height, event.mouseX + 8, event.mouseY, mc.fontRenderer);
        int x = (int) (toolTipSize[0] - skinPreSize - 28);
        int y = (int) (toolTipSize[1] - 4);
        if (tooltipOnLeft(list, mc.currentScreen.width, mc.currentScreen.height, event.mouseX + 8, event.mouseY, mc.fontRenderer)) {
            x = (int) (toolTipSize[0] + toolTipSize[2] + 15);
        }
        if (y < 0) {
            y = 0;
        }
        if (y + skinPreSize > mc.currentScreen.height) {
            y = mc.currentScreen.height - (int) skinPreSize;
        }
        drawSkinBox(mc, x, y, skinPreSize, skinPointer);
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 49 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class ItemSkin method addTooltipToSkinItem.

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 (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(stack);
        SkinIdentifier identifier = skinData.getIdentifier();
        if (!isEquipmentSkin & !skinData.lockSkin & !isEquipmentContainer) {
            return;
        }
        if (!isEquipmentSkin) {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.hasSkin"));
        }
        if (ClientSkinCache.INSTANCE.isSkinInCache(skinData)) {
            Skin data = ClientSkinCache.INSTANCE.getSkin(skinData);
            if (stack.getItem() != ModItems.equipmentSkin & !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 (skinData.getIdentifier().getSkinType() != null) {
                String localSkinName = SkinTypeRegistry.INSTANCE.getLocalizedSkinTypeName(skinData.getIdentifier().getSkinType());
                tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinType", localSkinName));
            }
            if (ConfigHandlerClient.showSkinTooltipDebugInfo) {
                if (GuiScreen.isShiftKeyDown()) {
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdentifier"));
                    if (identifier.hasLocalId()) {
                        tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinId", identifier.getSkinLocalId()));
                    }
                    if (identifier.hasLibraryFile()) {
                        tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinLibraryFile", identifier.getSkinLibraryFile().getFullName()));
                    }
                    if (identifier.hasGlobalId()) {
                        tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinGlobalId", identifier.getSkinGlobalId()));
                    }
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinTotalCubes", data.getTotalCubes()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubes", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 0))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubesGlowing", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 1))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubesGlass", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 2))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubesGlassGlowing", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 3))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinPaintData", data.hasPaintData()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinMarkerCount", data.getMarkerCount()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinDyeCount", skinData.getSkinDye().getNumberOfDyes()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinProperties"));
                    ArrayList<String> props = data.getProperties().getPropertiesList();
                    for (int i = 0; i < props.size(); i++) {
                        tooltip.add("  " + props.get(i));
                    }
                } else {
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinHoldShiftForInfo"));
                }
            }
            if (identifier.hasLocalId()) {
                if (identifier.getSkinLocalId() != 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", identifier.toString()));
            if (identifier.hasLocalId()) {
                tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinId", identifier.getSkinLocalId()));
            }
            if (identifier.hasLibraryFile()) {
                tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinLibraryFile", identifier.getSkinLibraryFile().getFullName()));
            }
            if (identifier.hasGlobalId()) {
                tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinGlobalId", identifier.getSkinGlobalId()));
            }
        }
        String keyName = Keyboard.getKeyName(Keybindings.openCustomArmourGui.getKeyCode());
        if (isEquipmentSkin) {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinOpenWardrobe", keyName));
        }
    } else {
        if (SkinNBTHelper.stackHasLegacySkinData(stack)) {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinOldType"));
        } else {
            if (isEquipmentSkin) {
                tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinInvalidItem"));
            }
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 50 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class ItemSkin method onItemUse.

@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 = SkinNBTHelper.getSkinPointerFromStack(stack);
    if (skinPointer != null && skinPointer.getIdentifier().getSkinType() == SkinTypeRegistry.skinBlock) {
        Skin skin = SkinUtils.getSkinDetectSide(skinPointer, false, true);
        if (skin != null) {
            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)) {
                placeSkinAtLocation(world, player, side, stack, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, skinPointer);
                return true;
            }
        }
    }
    return false;
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Aggregations

SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)64 ItemStack (net.minecraft.item.ItemStack)28 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)19 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)15 Item (net.minecraft.item.Item)13 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)7 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)7 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)6 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)4 Minecraft (net.minecraft.client.Minecraft)3 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 ItemBlock (net.minecraft.item.ItemBlock)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)3 MessageServerLibrarySendSkin (riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin)3 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2