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;
}
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();
}
}
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);
}
}
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);
}
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();
}
Aggregations