Search in sources :

Example 6 with SkinProperties

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

the class SkinSerializer method readSkinTypeNameFromStream.

public static ISkinType readSkinTypeNameFromStream(DataInputStream stream) throws IOException, NewerFileVersionException {
    int fileVersion = stream.readInt();
    if (fileVersion > Skin.FILE_VERSION) {
        throw new NewerFileVersionException();
    }
    if (fileVersion > 12) {
        String header = StreamUtils.readString(stream, Charsets.US_ASCII);
        if (!header.equals(TAG_SKIN_HEADER)) {
            ModLogger.log(Level.ERROR, "Error loading skin header.");
        }
        String propsHeader = StreamUtils.readString(stream, Charsets.US_ASCII);
        if (!propsHeader.equals(TAG_SKIN_PROPS_HEADER)) {
            ModLogger.log(Level.ERROR, "Error loading skin props header.");
        }
    }
    SkinProperties properties = new SkinProperties();
    boolean loadedProps = true;
    IOException e = null;
    if (fileVersion < 12) {
        String authorName = stream.readUTF();
        String customName = stream.readUTF();
        String tags = "";
        if (!(fileVersion < 4)) {
            tags = stream.readUTF();
        } else {
            tags = "";
        }
        properties.setProperty(Skin.KEY_AUTHOR_NAME, authorName);
        properties.setProperty(Skin.KEY_CUSTOM_NAME, customName);
        if (tags != null && !tags.equalsIgnoreCase("")) {
            properties.setProperty(KEY_TAGS, tags);
        }
    } else {
        try {
            properties.readFromStream(stream, fileVersion);
        } catch (IOException propE) {
            ModLogger.log(Level.ERROR, "prop load failed");
            e = propE;
            loadedProps = false;
        }
    }
    if (fileVersion > 12) {
        String propsFooter = StreamUtils.readString(stream, Charsets.US_ASCII);
        if (!propsFooter.equals(TAG_SKIN_PROPS_FOOTER)) {
            ModLogger.log(Level.ERROR, "Error loading skin props footer.");
        }
        String typeHeader = StreamUtils.readString(stream, Charsets.US_ASCII);
        if (!typeHeader.equals(TAG_SKIN_TYPE_HEADER)) {
            ModLogger.log(Level.ERROR, "Error loading skin type header.");
        }
    }
    ISkinType equipmentSkinType = null;
    if (fileVersion < 5) {
        if (loadedProps) {
            equipmentSkinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromLegacyId(stream.readByte() - 1);
        } else {
            throw e;
        }
    } else {
        if (loadedProps) {
            String regName = stream.readUTF();
            if (regName.equals(SkinTypeRegistry.skinSkirt.getRegistryName())) {
                regName = SkinTypeRegistry.skinLegs.getRegistryName();
            }
            equipmentSkinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(regName);
        } else {
            StringBuilder sb = new StringBuilder();
            while (true) {
                sb.append(new String(new byte[] { stream.readByte() }, "UTF-8"));
                if (sb.toString().endsWith("armourers:")) {
                    break;
                }
            }
            ModLogger.log("Got armourers");
            sb = new StringBuilder();
            sb.append("armourers:");
            while (SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(sb.toString()) == null) {
                sb.append(new String(new byte[] { stream.readByte() }, "UTF-8"));
            }
            ModLogger.log(sb.toString());
            equipmentSkinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(sb.toString());
            ModLogger.log("got failed type " + equipmentSkinType);
        }
    }
    return equipmentSkinType;
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) IOException(java.io.IOException) NewerFileVersionException(riskyken.armourersWorkshop.common.exception.NewerFileVersionException) SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties)

Example 7 with SkinProperties

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

the class TileEntityArmourer method clearMarkers.

public void clearMarkers(ISkinPartType partType) {
    if (skinType != null) {
        ArmourerWorldHelper.clearMarkers(worldObj, xCoord, yCoord + getHeightOffset(), zCoord, skinType, skinProps, partType);
        SkinProperties newSkinProps = new SkinProperties();
        SkinProperties.PROP_BLOCK_MULTIBLOCK.setValue(newSkinProps, SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skinProps));
        setSkinProps(newSkinProps);
        dirtySync();
    }
}
Also used : SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties)

Example 8 with SkinProperties

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

the class TileEntityArmourer method readCommonFromNBT.

@Override
public void readCommonFromNBT(NBTTagCompound compound) {
    super.readCommonFromNBT(compound);
    direction = ForgeDirection.getOrientation(compound.getByte(TAG_DIRECTION));
    skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(compound.getString(TAG_TYPE));
    // Update code for old saves
    if (skinType == null && compound.hasKey(TAG_TYPE_OLD)) {
        skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromLegacyId(compound.getInteger(TAG_TYPE_OLD) - 1);
    }
    if (compound.hasKey(TAG_OWNER_OLD, NBT.TAG_COMPOUND)) {
        GameProfile gameProfile = NBTUtil.func_152459_a(compound.getCompoundTag(TAG_OWNER_OLD));
        texture = new PlayerTexture(gameProfile.getName(), TextureType.USER);
    }
    showGuides = compound.getBoolean(TAG_SHOW_GUIDES);
    showOverlay = compound.getBoolean(TAG_SHOW_OVERLAY);
    if (compound.hasKey(TAG_SHOW_HELPER)) {
        showHelper = compound.getBoolean(TAG_SHOW_HELPER);
    }
    skinProps = new SkinProperties();
    skinProps.readFromNBT(compound);
    if (compound.hasKey(TAG_TEXTURE, NBT.TAG_COMPOUND)) {
        texture = PlayerTexture.fromNBT(compound.getCompoundTag(TAG_TEXTURE));
    }
    if (compound.hasKey(TAG_PAINT_DATA)) {
        paintData = compound.getIntArray(TAG_PAINT_DATA);
    }
}
Also used : PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) GameProfile(com.mojang.authlib.GameProfile) SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties)

Example 9 with SkinProperties

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

the class TileEntitySkinnable method setSkinPointer.

public void setSkinPointer(Skin skin, SkinPointer skinPointer) {
    this.skinPointer = skinPointer;
    if (skin != null & isParent()) {
        SkinProperties skinProps = skin.getProperties();
        if (SkinProperties.PROP_BLOCK_INVENTORY.getValue(skin.getProperties())) {
            blockInventory = true;
            int size = SkinProperties.PROP_BLOCK_INVENTORY_WIDTH.getValue(skin.getProperties()) * SkinProperties.PROP_BLOCK_INVENTORY_HEIGHT.getValue(skin.getProperties());
            inventory = new ModInventory(LibBlockNames.SKINNABLE, size, this);
        }
    }
    markDirty();
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : ModInventory(riskyken.armourersWorkshop.common.inventory.ModInventory) SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties)

Example 10 with SkinProperties

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

the class TileEntityArmourer method setSkinType.

public void setSkinType(ISkinType skinType) {
    if (this.skinType == skinType) {
        return;
    }
    removeBoundingBoxes();
    this.skinType = skinType;
    skinProps = new SkinProperties();
    clearPaintData(true);
    createBoundingBoxes();
    dirtySync();
}
Also used : SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties)

Aggregations

SkinProperties (riskyken.armourersWorkshop.common.skin.data.SkinProperties)16 MessageClientGuiSetArmourerSkinProps (riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiSetArmourerSkinProps)4 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)3 IOException (java.io.IOException)2 ItemStack (net.minecraft.item.ItemStack)2 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)2 NewerFileVersionException (riskyken.armourersWorkshop.common.exception.NewerFileVersionException)2 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)2 GameProfile (com.mojang.authlib.GameProfile)1 ArrayList (java.util.ArrayList)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 GuiCheckBox (riskyken.armourersWorkshop.client.gui.controls.GuiCheckBox)1 GuiCustomSlider (riskyken.armourersWorkshop.client.gui.controls.GuiCustomSlider)1 GuiDropDownList (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList)1 GuiInventorySize (riskyken.armourersWorkshop.client.gui.controls.GuiInventorySize)1 PlayerTexture (riskyken.armourersWorkshop.client.texture.PlayerTexture)1 InvalidCubeTypeException (riskyken.armourersWorkshop.common.exception.InvalidCubeTypeException)1 SkinSaveException (riskyken.armourersWorkshop.common.exception.SkinSaveException)1 ModInventory (riskyken.armourersWorkshop.common.inventory.ModInventory)1