cleanup, change dye colors

This commit is contained in:
Sen 2025-06-30 20:48:53 +02:00
parent a73901a584
commit 1fe5003028
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
77 changed files with 409 additions and 1004 deletions

View file

@ -22,7 +22,7 @@ public class LayerWolfCollar implements LayerRenderer<EntityWolf>
if (entitylivingbaseIn.isTamed()) // && !entitylivingbaseIn.isInvisible())
{
this.wolfRenderer.bindTexture(WOLF_COLLAR);
DyeColor enumdyecolor = DyeColor.byMetadata(entitylivingbaseIn.getCollarColor().getMetadata());
DyeColor enumdyecolor = entitylivingbaseIn.getCollarColor();
float[] afloat = EntitySheep.getDyeRgb(enumdyecolor);
GlState.color(afloat[0], afloat[1], afloat[2], 1.0F);
this.wolfRenderer.getMainModel().render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale);

View file

@ -3,9 +3,9 @@ package client.renderer.particle;
import client.Client;
import client.renderer.RenderBuffer;
import client.world.WorldClient;
import common.color.DyeColor;
import common.entity.Entity;
import common.init.SoundEvent;
import common.item.material.ItemDye;
import common.tags.TagObject;
import java.util.List;
import common.util.BoundingBox;
@ -277,7 +277,7 @@ public class EntityFirework
if (aint.length == 0)
{
aint = new int[] {ItemDye.FIREWORK_COLORS[0]};
aint = new int[] {DyeColor.WHITE.getColor()};
}
if (l == 1)

View file

@ -181,7 +181,7 @@ public class EntityAIControlledByPlayer extends EntityAIBase
if (itemstack.size == 0)
{
ItemStack itemstack1 = new ItemStack(Items.fishing_rod);
itemstack1.setTagCompound(itemstack.getTagCompound());
itemstack1.setTag(itemstack.getTag());
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = itemstack1;
}
}

View file

@ -20,7 +20,7 @@ public class BlockCarpet extends Block
private final DyeColor color;
public static BlockCarpet getByColor(DyeColor color) {
return CARPETS[color.getMetadata()];
return CARPETS[color.ordinal()];
}
public BlockCarpet(DyeColor color)

View file

@ -12,7 +12,7 @@ public class BlockStainedGlass extends BlockGlass {
private final DyeColor color;
public static BlockStainedGlass getByColor(DyeColor color) {
return GLASS[color.getMetadata()];
return GLASS[color.ordinal()];
}
public BlockStainedGlass(DyeColor color) {

View file

@ -16,7 +16,7 @@ public class BlockStainedGlassPane extends BlockPane
private final DyeColor color;
public static BlockStainedGlassPane getByColor(DyeColor color) {
return PANES[color.getMetadata()];
return PANES[color.ordinal()];
}
public BlockStainedGlassPane(DyeColor color)

View file

@ -14,7 +14,7 @@ public class BlockWool extends Block {
private final DyeColor color;
public static BlockWool getByColor(DyeColor color) {
return WOOLS[color.getMetadata()];
return WOOLS[color.ordinal()];
}
public BlockWool(DyeColor color) {

View file

@ -14,7 +14,7 @@ public class BlockColoredClay extends Block {
private final DyeColor color;
public static BlockColoredClay getByColor(DyeColor color) {
return CLAY[color.getMetadata()];
return CLAY[color.ordinal()];
}
public BlockColoredClay(DyeColor color) {

View file

@ -3,151 +3,95 @@ package common.color;
import java.util.Map;
import common.collect.Maps;
import common.util.Displayable;
import common.util.Identifyable;
public enum DyeColor implements Identifyable
{
WHITE(0, 15, "white", "Weiß", "Weißes", "Weißer", "Weiße", "bonemeal", "Knochenmehl", 16777215, TextColor.WHITE),
ORANGE(1, 14, "orange", "Orange", "Oranges", "Oranger", "Orange", null, "Oranger Farbstoff", 14188339, TextColor.ORANGE),
MAGENTA(2, 13, "magenta", "Magenta", "Magenta", "Magenta", "Magenta", null, "Magenta Farbstoff", 11685080, TextColor.NEON),
LIGHT_BLUE(3, 12, "light_blue", "Hellblau", "Hellblaues", "Hellblauer", "Hellblaue", null, "Hellblauer Farbstoff", 6724056, TextColor.BLUE),
YELLOW(4, 11, "yellow", "Gelb", "Gelbes", "Gelber", "Gelbe", null, "Gelber Farbstoff", 15066419, TextColor.YELLOW),
LIME(5, 10, "lime", "Hellgrün", "Hellgrünes", "Hellgrüner", "Hellgrüne", null, "Hellgrüner Farbstoff", 8375321, TextColor.GREEN),
PINK(6, 9, "pink", "Rosa", "Rosa", "Rosa", "Rosa", null, "Rosa Farbstoff", 15892389, TextColor.MAGENTA),
GRAY(7, 8, "gray", "Grau", "Graues", "Grauer", "Graue", null, "Grauer Farbstoff", 5000268, TextColor.GRAY),
SILVER(8, 7, "silver", "Hellgrau", "Hellgraues", "Hellgrauer", "Hellgraue", null, "Hellgrauer Farbstoff", 10066329, TextColor.LGRAY),
CYAN(9, 6, "cyan", "Türkis", "Türkises", "Türkiser", "Türkise", null, "Türkiser Farbstoff", 5013401, TextColor.CYAN),
PURPLE(10, 5, "purple", "Violett", "Violettes", "Violetter", "Violette", null, "Violetter Farbstoff", 8339378, TextColor.DMAGENTA),
BLUE(11, 4, "blue", "Blau", "Blaues", "Blauer", "Blaue", "lapis_lazuli", "Lapislazuli", 3361970, TextColor.MIDNIGHT),
BROWN(12, 3, "brown", "Braun", "Braunes", "Brauner", "Braune", "cocoa", "Kakaobohnen", 6704179, TextColor.ORANGE),
GREEN(13, 2, "green", "Grün", "Grünes", "Grüner", "Grüne", "cactus_green", "Kaktusgrün", 6717235, TextColor.DGREEN),
RED(14, 1, "red", "Rot", "Rotes", "Roter", "Rote", null, "Roter Farbstoff", 10040115, TextColor.DRED),
BLACK(15, 0, "black", "Schwarz", "Schwarzes", "Schwarzer", "Schwarze", "ink_sack", "Tintenbeutel", 1644825, TextColor.BLACK);
public enum DyeColor implements Identifyable, Displayable {
WHITE("white", "Weiß", "Weißes", "Weißer", "Weiße", "bonemeal", "Knochenmehl", 16777215, TextColor.WHITE),
ORANGE("orange", "Orange", "Oranges", "Oranger", "Orange", null, "Oranger Farbstoff", 14188339, TextColor.ORANGE),
MAGENTA("magenta", "Magenta", "Magenta", "Magenta", "Magenta", null, "Magenta Farbstoff", 11685080, TextColor.VIOLET),
LIGHT_BLUE("light_blue", "Hellblau", "Hellblaues", "Hellblauer", "Hellblaue", null, "Hellblauer Farbstoff", 6724056, TextColor.BLUE),
YELLOW("yellow", "Gelb", "Gelbes", "Gelber", "Gelbe", null, "Gelber Farbstoff", 15066419, TextColor.YELLOW),
LIME("lime", "Hellgrün", "Hellgrünes", "Hellgrüner", "Hellgrüne", null, "Hellgrüner Farbstoff", 8375321, TextColor.GREEN),
PINK("pink", "Rosa", "Rosa", "Rosa", "Rosa", null, "Rosa Farbstoff", 15892389, TextColor.MAGENTA),
GRAY("gray", "Grau", "Graues", "Grauer", "Graue", null, "Grauer Farbstoff", 5000268, TextColor.GRAY),
SILVER("silver", "Hellgrau", "Hellgraues", "Hellgrauer", "Hellgraue", null, "Hellgrauer Farbstoff", 10066329, TextColor.LGRAY),
CYAN("cyan", "Türkis", "Türkises", "Türkiser", "Türkise", null, "Türkiser Farbstoff", 5013401, TextColor.CYAN),
PURPLE("purple", "Violett", "Violettes", "Violetter", "Violette", null, "Violetter Farbstoff", 8339378, TextColor.DMAGENTA),
BLUE("blue", "Blau", "Blaues", "Blauer", "Blaue", "lapis_lazuli", "Lapislazuli", 3361970, TextColor.MIDNIGHT),
BROWN("brown", "Braun", "Braunes", "Brauner", "Braune", "cocoa", "Kakaobohnen", 6704179, TextColor.BROWN),
GREEN("green", "Grün", "Grünes", "Grüner", "Grüne", "cactus_green", "Kaktusgrün", 6717235, TextColor.DGREEN),
RED("red", "Rot", "Rotes", "Roter", "Rote", null, "Roter Farbstoff", 10040115, TextColor.DRED),
BLACK("black", "Schwarz", "Schwarzes", "Schwarzer", "Schwarze", "ink_sack", "Tintenbeutel", 1644825, TextColor.BLACK);
private static final Map<String, DyeColor> LOOKUP = Maps.newHashMap();
private static final DyeColor[] META_LOOKUP = new DyeColor[values().length];
private static final DyeColor[] DYE_DMG_LOOKUP = new DyeColor[values().length];
private final int meta;
private final int dyeDamage;
private final String name;
private final String display;
private final String subject;
private final String msubject;
private final String fsubject;
private final String dye;
private final String dyeName;
private final int color;
private final TextColor chatColor;
private DyeColor(int meta, int dyeDamage, String name, String display, String subject, String msubject,
String fsubject, String dye, String dyeName, int colorIn, TextColor chatColor)
{
this.meta = meta;
this.dyeDamage = dyeDamage;
this.name = name;
this.display = display;
this.subject = subject;
this.msubject = msubject;
this.fsubject = fsubject;
this.dye = dye == null ? name + "_dye" : dye;
this.dyeName = dyeName;
this.color = colorIn;
this.chatColor = chatColor;
}
private final String name;
private final String display;
private final String subject;
private final String msubject;
private final String fsubject;
private final String dye;
private final String dyeName;
private final int color;
private final TextColor textColor;
public int getMetadata()
{
return this.meta;
}
static {
for(DyeColor color : values()) {
LOOKUP.put(color.name, color);
}
}
public int getDyeDamage()
{
return this.dyeDamage;
}
public int getColor()
{
return this.color;
}
public static DyeColor byDyeDamage(int damage)
{
if (damage < 0 || damage >= DYE_DMG_LOOKUP.length)
{
damage = 0;
}
return DYE_DMG_LOOKUP[damage];
}
public static DyeColor byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public static DyeColor getByName(String name) {
public static DyeColor byName(String name) {
DyeColor type = LOOKUP.get(name.toLowerCase());
return type == null ? WHITE : type;
}
public static DyeColor getByString(String name) {
DyeColor type = LOOKUP.get(name.toLowerCase());
if(type != null)
return type;
int meta;
try {
meta = Integer.parseInt(name);
}
catch(NumberFormatException e) {
return null;
}
if(meta < 0 || meta >= META_LOOKUP.length)
return null;
return META_LOOKUP[meta];
public static DyeColor getExact(String name) {
return LOOKUP.get(name.toLowerCase());
}
public String toString()
{
return this.name;
}
private DyeColor(String name, String display, String subject, String msubject, String fsubject, String dye, String dyeName, int color, TextColor textColor) {
this.name = name;
this.display = display;
this.subject = subject;
this.msubject = msubject;
this.fsubject = fsubject;
this.dye = dye == null ? name + "_dye" : dye;
this.dyeName = dyeName;
this.color = color;
this.textColor = textColor;
}
public String getName()
{
return this.name;
}
public String toString() {
return this.name;
}
public String getDisplay()
{
return this.display;
}
public String getName() {
return this.name;
}
public String getSubject(Integer type)
{
return type == null ? this.display : (type < 0 ? this.fsubject : (type > 0 ? this.msubject : this.subject));
}
public String getDisplay() {
return this.display;
}
public String getDye()
{
return this.dye;
}
public String getSubject(Integer type) {
return type == null ? this.display : (type < 0 ? this.fsubject : (type > 0 ? this.msubject : this.subject));
}
public String getDyeName()
{
return this.dyeName;
}
public String getDye() {
return this.dye;
}
static {
for (DyeColor color : values())
{
LOOKUP.put(color.name, color);
META_LOOKUP[color.getMetadata()] = color;
DYE_DMG_LOOKUP[color.getDyeDamage()] = color;
}
}
public String getDyeName() {
return this.dyeName;
}
public int getColor() {
return this.color;
}
public TextColor getTextColor() {
return this.textColor;
}
}

View file

@ -103,9 +103,9 @@ public class EnchantmentHelper
stack.setTagInfo("ench", list);
}
}
else if (stack.hasTagCompound())
else if (stack.hasTag())
{
stack.getTagCompound().remove("ench");
stack.getTag().remove("ench");
}
}

View file

@ -281,10 +281,10 @@ public class EntityTrackerEntry {
.sendPacket(new SPacketEntityMetadata(this.trackedEntity.getId(), this.trackedEntity.getDataWatcher(), true));
}
TagObject nbttagcompound = this.trackedEntity.getTag();
TagObject tag = this.trackedEntity.getTag();
if(nbttagcompound != null) {
playerMP.connection.sendPacket(new SPacketUpdateEntityTags(this.trackedEntity.getId(), nbttagcompound));
if(tag != null) {
playerMP.connection.sendPacket(new SPacketUpdateEntityTags(this.trackedEntity.getId(), tag));
}
this.lastTrackedEntityMotionX = this.trackedEntity.motionX;

View file

@ -245,18 +245,12 @@ public class EntityBat extends EntityLiving
// }
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.dataWatcher.updateObject(16, Byte.valueOf(tagCompund.getByte("BatFlags")));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);

View file

@ -24,16 +24,10 @@ public class EntityDragonPart extends Entity
{
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
}

View file

@ -1386,9 +1386,6 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
@ -1405,22 +1402,22 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (this.isChested())
{
List<TagObject> nbttaglist = Lists.newArrayList();
List<TagObject> list = Lists.newArrayList();
for (int i = 2; i < this.horseChest.getSizeInventory(); ++i)
{
ItemStack itemstack = this.horseChest.getStackInSlot(i);
ItemStack stack = this.horseChest.getStackInSlot(i);
if (itemstack != null)
if (stack != null)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeTags(nbttagcompound);
nbttaglist.add(nbttagcompound);
TagObject tag = new TagObject();
tag.setByte("Slot", (byte)i);
stack.writeTags(tag);
list.add(tag);
}
}
tagCompound.setList("Items", nbttaglist);
tagCompound.setList("Items", list);
}
if (this.horseChest.getStackInSlot(1) != null)
@ -1434,9 +1431,6 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
@ -1470,17 +1464,17 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (this.isChested())
{
List<TagObject> nbttaglist = tagCompund.getList("Items");
List<TagObject> list = tagCompund.getList("Items");
this.initHorseChest();
for (int i = 0; i < nbttaglist.size(); ++i)
for (int i = 0; i < list.size(); ++i)
{
TagObject nbttagcompound = nbttaglist.get(i);
int j = nbttagcompound.getByte("Slot") & 255;
TagObject tag = list.get(i);
int j = tag.getByte("Slot") & 255;
if (j >= 2 && j < this.horseChest.getSizeInventory())
{
this.horseChest.setInventorySlotContents(j, ItemStack.readFromTag(nbttagcompound));
this.horseChest.setInventorySlotContents(j, ItemStack.readFromTag(tag));
}
}
}
@ -1605,10 +1599,6 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
return entityhorse1;
}
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
public Object onInitialSpawn(Object livingdata)
{
livingdata = super.onInitialSpawn(livingdata);

View file

@ -120,18 +120,12 @@ public class EntityOcelot extends EntityTameable
{
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setInt("CatType", this.getTameSkin());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
@ -383,10 +377,6 @@ public class EntityOcelot extends EntityTameable
}
}
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
public Object onInitialSpawn(Object livingdata)
{
livingdata = super.onInitialSpawn(livingdata);

View file

@ -65,18 +65,12 @@ public class EntityPig extends EntityAnimal
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setBool("Saddle", this.getSaddled());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -109,6 +109,7 @@ public class EntitySheep extends EntityAnimal
{
super.entityInit();
this.dataWatcher.addObject(16, (byte)0);
this.dataWatcher.addObject(17, (byte)(DyeColor.WHITE.ordinal() & 255));
}
/**
@ -205,24 +206,18 @@ public class EntitySheep extends EntityAnimal
return super.interact(player);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setBool("Sheared", this.getSheared());
tagCompound.setByte("Color", (byte)this.getFleeceColor().getMetadata());
tagCompound.setString("Color", this.getFleeceColor().getName());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.setSheared(tagCompund.getBool("Sheared"));
this.setFleeceColor(DyeColor.byMetadata(tagCompund.getByte("Color")));
this.setFleeceColor(DyeColor.byName(tagCompund.getString("Color")));
}
/**
@ -259,7 +254,7 @@ public class EntitySheep extends EntityAnimal
*/
public DyeColor getFleeceColor()
{
return DyeColor.byMetadata(this.dataWatcher.getWatchableObjectByte(16) & 15);
return DyeColor.values()[(this.dataWatcher.getWatchableObjectByte(17) & 255) % DyeColor.values().length];
}
/**
@ -267,8 +262,7 @@ public class EntitySheep extends EntityAnimal
*/
public void setFleeceColor(DyeColor color)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & 240 | color.getMetadata() & 15)));
this.dataWatcher.updateObject(17, (byte)(color.ordinal() & 255));
}
/**
@ -276,7 +270,7 @@ public class EntitySheep extends EntityAnimal
*/
public boolean getSheared()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 16) != 0;
return this.dataWatcher.getWatchableObjectByte(16) != 0;
}
/**
@ -284,16 +278,7 @@ public class EntitySheep extends EntityAnimal
*/
public void setSheared(boolean sheared)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (sheared)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 16)));
}
else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -17)));
}
this.dataWatcher.updateObject(16, (byte)(sheared ? 1 : 0));
}
private static final DyeColor[] RARE_COLORS = {
@ -338,10 +323,6 @@ public class EntitySheep extends EntityAnimal
}
}
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
public Object onInitialSpawn(Object livingdata)
{
livingdata = super.onInitialSpawn(livingdata);

View file

@ -117,7 +117,7 @@ public class EntityWolf extends EntityTameable
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
this.dataWatcher.addObject(19, (byte)0);
this.dataWatcher.addObject(20, (byte)DyeColor.RED.getMetadata());
this.dataWatcher.addObject(20, (byte)(DyeColor.RED.ordinal() & 255));
}
// protected void playStepSound(BlockPos pos, Block blockIn)
@ -125,24 +125,18 @@ public class EntityWolf extends EntityTameable
// this.playSound("mob.wolf.step", 0.15F, 1.0F);
// }
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setBool("Angry", this.isAngry());
tagCompound.setByte("CollarColor", (byte)this.getCollarColor().getDyeDamage());
tagCompound.setString("CollarColor", this.getCollarColor().getName());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.setAngry(tagCompund.getBool("Angry"));
this.setCollarColor(DyeColor.byDyeDamage(tagCompund.getByte("CollarColor")));
this.setCollarColor(DyeColor.byName(tagCompund.getString("CollarColor")));
}
/**
@ -508,12 +502,12 @@ public class EntityWolf extends EntityTameable
public DyeColor getCollarColor()
{
return DyeColor.byDyeDamage(this.dataWatcher.getWatchableObjectByte(20) & 15);
return DyeColor.values()[(this.dataWatcher.getWatchableObjectByte(20) & 255) % DyeColor.values().length];
}
public void setCollarColor(DyeColor collarcolor)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte)(collarcolor.getDyeDamage() & 15)));
this.dataWatcher.updateObject(20, (byte)(collarcolor.ordinal() & 255));
}
public EntityWolf createChild(EntityLiving ageable)
@ -608,7 +602,7 @@ public class EntityWolf extends EntityTameable
public int getLeashColor() {
if(this.isTamed()) {
DyeColor color = DyeColor.byMetadata(this.getCollarColor().getMetadata());
DyeColor color = this.getCollarColor();
float[] rgb = EntitySheep.getDyeRgb(color);
return (((int)(rgb[0] * 255.0f)) << 16) | (((int)(rgb[1] * 255.0f)) << 8) | ((int)(rgb[2] * 255.0f));
}

View file

@ -497,16 +497,10 @@ public class EntityBoat extends Entity
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
}

View file

@ -745,9 +745,6 @@ public abstract class EntityCart extends Entity implements IWorldNameable
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0)
@ -756,9 +753,6 @@ public abstract class EntityCart extends Entity implements IWorldNameable
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
if (this.entityName != null && this.entityName.length() > 0)

View file

@ -186,9 +186,6 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
super.setDead();
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
@ -208,9 +205,6 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
tagCompound.setList("Items", nbttaglist);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -60,16 +60,10 @@ public class EntityCrystal extends Entity
// }
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
}

View file

@ -198,9 +198,6 @@ public class EntityFalling extends Entity implements IObjectData
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
tagCompound.setString("Block", BlockRegistry.getName((this.fallTile != null ? this.fallTile : Blocks.air.getState())));
@ -211,9 +208,6 @@ public class EntityFalling extends Entity implements IObjectData
tagCompound.setInt("FallHurtMax", this.fallHurtMax);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
if (tagCompund.hasString("Block"))

View file

@ -48,10 +48,10 @@ public class EntityFireworks extends Entity
this.setPosition(x, y, z);
int i = 1;
if (givenItem != null && givenItem.hasTagCompound())
if (givenItem != null && givenItem.hasTag())
{
this.dataWatcher.updateObject(8, givenItem);
TagObject nbttagcompound = givenItem.getTagCompound();
TagObject nbttagcompound = givenItem.getTag();
TagObject nbttagcompound1 = nbttagcompound.getObject("Fireworks");
if (nbttagcompound1 != null)
@ -153,9 +153,9 @@ public class EntityFireworks extends Entity
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
TagObject nbttagcompound = null;
if (itemstack != null && itemstack.hasTagCompound())
if (itemstack != null && itemstack.hasTag())
{
nbttagcompound = itemstack.getTagCompound().getObject("Fireworks");
nbttagcompound = itemstack.getTag().getObject("Fireworks");
}
((AWorldClient)this.worldObj).makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
@ -164,9 +164,6 @@ public class EntityFireworks extends Entity
super.handleStatusUpdate(id);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setInt("Life", this.fireworkAge);
@ -181,9 +178,6 @@ public class EntityFireworks extends Entity
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.fireworkAge = tagCompund.getInt("Life");

View file

@ -198,18 +198,12 @@ public class EntityHopperCart extends EntityCartContainer implements IHopper
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setInt("TransferCooldown", this.transferTicker);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -223,11 +223,11 @@ public class EntityItem extends Entity
{
return false;
}
else if (itemstack1.hasTagCompound() ^ itemstack.hasTagCompound())
else if (itemstack1.hasTag() ^ itemstack.hasTag())
{
return false;
}
else if (itemstack1.hasTagCompound() && !itemstack1.getTagCompound().equals(itemstack.getTagCompound()))
else if (itemstack1.hasTag() && !itemstack1.getTag().equals(itemstack.getTag()))
{
return false;
}
@ -337,9 +337,6 @@ public class EntityItem extends Entity
// }
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setShort("Health", (short)((byte)this.health));
@ -362,9 +359,6 @@ public class EntityItem extends Entity
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.health = tagCompund.getShort("Health") & 255;
@ -382,8 +376,8 @@ public class EntityItem extends Entity
// this.thrower = tagCompund.getString("Thrower");
// }
TagObject nbttagcompound = tagCompund.getObject("Item");
this.setEntityItemStack(ItemStack.readFromTag(nbttagcompound));
TagObject tag = tagCompund.getObject("Item");
this.setEntityItemStack(ItemStack.readFromTag(tag));
if (this.getEntityItem() == null)
{

View file

@ -242,51 +242,6 @@ public class EntityLeashKnot extends Entity
}
}
// /**
// * (abstract) Protected helper method to write subclass entity data to NBT.
// */
// public void writeEntityToNBT(NBTTagCompound tagCompound)
// {
// tagCompound.setByte("Facing", (byte)this.facingDirection.getHorizontalIndex());
// tagCompound.setInteger("TileX", this.getHangingPosition().getX());
// tagCompound.setInteger("TileY", this.getHangingPosition().getY());
// tagCompound.setInteger("TileZ", this.getHangingPosition().getZ());
// }
//
// /**
// * (abstract) Protected helper method to read subclass entity data from NBT.
// */
// public void readEntityFromNBT(NBTTagCompound tagCompund)
// {
// this.hangingPosition = new BlockPos(tagCompund.getInteger("TileX"), tagCompund.getInteger("TileY"), tagCompund.getInteger("TileZ"));
// Facing enumfacing;
//
// if (tagCompund.hasKey("Direction", 99))
// {
// enumfacing = Facing.getHorizontal(tagCompund.getByte("Direction"));
// this.hangingPosition = this.hangingPosition.offset(enumfacing);
// }
// else if (tagCompund.hasKey("Facing", 99))
// {
// enumfacing = Facing.getHorizontal(tagCompund.getByte("Facing"));
// }
// else
// {
// enumfacing = Facing.getHorizontal(tagCompund.getByte("Dir"));
// }
//
// this.updateFacingWithBoundingBox(enumfacing);
// }
// public abstract int getWidthPixels();
//
// public abstract int getHeightPixels();
// /**
// * Called when this entity is broken. Entity parameter may be null.
// */
// public abstract void onBroken(Entity brokenEntity);
protected boolean shouldSetPosAfterLoading()
{
return false;
@ -363,33 +318,15 @@ public class EntityLeashKnot extends Entity
return distance < 1024.0D;
}
// /**
// * Called when this entity is broken. Entity parameter may be null.
// */
// public void onBroken(Entity brokenEntity)
// {
// }
/**
* Either write this entity to the NBT tag given and return true, or return false without doing anything. If this
* returns false the entity is not saved on disk. Ridden entities return false here as they are saved with their
* rider.
*/
public boolean writeOptional(TagObject tagCompund)
{
return false;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
}

View file

@ -106,18 +106,12 @@ public class EntityTnt extends Entity implements IObjectData
this.worldObj.createExplosion(this, this.posX, this.posY + (double)(this.height / 16.0F), this.posZ, f, true);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
tagCompound.setByte("Fuse", (byte)this.fuse);
tagCompound.setByte("Power", (byte)this.explosionSize);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
this.fuse = tagCompund.getByte("Fuse");

View file

@ -204,18 +204,12 @@ public class EntityTntCart extends EntityCart
return !this.isIgnited() || !BlockRailBase.isRailBlock(blockStateIn) && !BlockRailBase.isRailBlock(worldIn, pos.up()) ? super.verifyExplosion(explosionIn, worldIn, pos, blockStateIn, p_174816_5_) : false;
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.minecartTNTFuse = tagCompund.getInt("TNTFuse");
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);

View file

@ -291,9 +291,6 @@ public class EntityXp extends Entity implements IObjectData
// }
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setShort("Health", (short)((byte)this.xpOrbHealth));
@ -301,9 +298,6 @@ public class EntityXp extends Entity implements IObjectData
tagCompound.setShort("Value", (short)this.xpValue);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.xpOrbHealth = tagCompund.getShort("Health") & 255;

View file

@ -54,9 +54,6 @@ public class EntityHaunter extends EntityNPC {
this.dataWatcher.addObject(24, Byte.valueOf((byte)0));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
@ -70,9 +67,6 @@ public class EntityHaunter extends EntityNPC {
tagCompound.setBool("ignited", this.hasIgnited());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -97,9 +97,6 @@ public abstract class EntityMobNPC extends EntityNPC
// return this.worldObj.getDifficulty() != Difficulty.PEACEFUL;
// }
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
@ -115,9 +112,6 @@ public abstract class EntityMobNPC extends EntityNPC
// }
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
@ -250,17 +244,6 @@ public abstract class EntityMobNPC extends EntityNPC
// {
// this.setItem(0, new ItemStack(Items.golden_sword));
// }
//
// /**
// * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
// * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
// */
// public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
// {
// super.onInitialSpawn(difficulty, livingdata);
//// this.setVillager(false);
// return livingdata;
// }
// public int getColor() {
// return 0xff9494;

View file

@ -812,33 +812,6 @@ public abstract class EntityNPC extends EntityLiving
}
}
// protected void entityInit()
// {
// }
// public void writeEntityToNBT(NBTTagCompound tagCompound)
// {
// }
// public void readEntityFromNBT(NBTTagCompound tagCompund)
// {
// }
// protected boolean canDespawn()
// {
// return false;
// }
// protected String getHurtSound()
// {
// return "mob.npc.hit";
// }
//
// protected String getDeathSound()
// {
// return "mob.npc.death";
// }
public void setChar(String character)
{
this.dataWatcher.updateObject(9, character);
@ -1395,11 +1368,11 @@ public abstract class EntityNPC extends EntityLiving
flag = itemsword.getDamageVsEntity() > itemsword1.getDamageVsEntity();
}
else {
flag = stack.getItemDamage() > old.getItemDamage() || stack.hasTagCompound() && !old.hasTagCompound();
flag = stack.getItemDamage() > old.getItemDamage() || stack.hasTag() && !old.hasTag();
}
}
else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) {
flag = stack.hasTagCompound() && !old.hasTagCompound();
flag = stack.hasTag() && !old.hasTag();
}
else if(stack.getItem() instanceof ItemGunBase && !(old.getItem() instanceof ItemBow)) {
flag = true;
@ -1422,7 +1395,7 @@ public abstract class EntityNPC extends EntityLiving
flag = itemarmor.damageReduceAmount > itemarmor1.damageReduceAmount;
}
else {
flag = stack.getItemDamage() > old.getItemDamage() || stack.hasTagCompound() && !old.hasTagCompound();
flag = stack.getItemDamage() > old.getItemDamage() || stack.hasTag() && !old.hasTag();
}
}
else {
@ -3363,12 +3336,8 @@ public abstract class EntityNPC extends EntityLiving
this.attackDamageBase = value;
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
// super.readEntityFromNBT(tagCompund);
super.readEntity(tagCompund);
// if(tagCompund.hasBoolean("CanPickUpLoot")) {
@ -3437,7 +3406,7 @@ public abstract class EntityNPC extends EntityLiving
if(this.isPlayer()) {
// this.entityUniqueID = getOfflineUUID(this.user);
List<TagObject> nbttaglist0 = tagCompund.getList("Inventory");
this.inventory.readFromNBT(nbttaglist0);
this.inventory.fromTag(nbttaglist0);
this.inventory.currentItem = tagCompund.getInt("SelectedItemSlot");
// this.sleeping = tagCompund.getBoolean("Sleeping");
// this.sleepTimer = tagCompund.getShort("SleepTimer");
@ -3475,8 +3444,6 @@ public abstract class EntityNPC extends EntityLiving
tagCompund.getInt("OriginZ"), dim);
}
// this.foodStats.readNBT(tagCompund);
// this.readCapabilitiesFromNBT(tagCompund);
this.flying = tagCompund.getBool("flying") && (this.hasEffect(Potion.FLYING) || this.canNaturallyFly());
// if(tagCompund.hasKey("speed", 99))
// this.speed = tagCompund.getFloat("speed");
@ -3507,12 +3474,8 @@ public abstract class EntityNPC extends EntityLiving
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
// super.writeEntityToNBT(tagCompound);
super.writeEntity(tagCompound);
// tagCompound.setBoolean("CanPickUpLoot", this.canPickUpLoot());
@ -3563,7 +3526,7 @@ public abstract class EntityNPC extends EntityLiving
tagCompound.setByteArray("Skin", this.skin);
if(this.isPlayer()) {
tagCompound.setList("Inventory", this.inventory.writeToNBT(Lists.newArrayList()));
tagCompound.setList("Inventory", this.inventory.toTag(Lists.newArrayList()));
tagCompound.setInt("SelectedItemSlot", this.inventory.currentItem);
// tagCompound.setBoolean("Sleeping", this.sleeping);
// tagCompound.setShort("SleepTimer", (short)this.sleepTimer);
@ -3597,8 +3560,6 @@ public abstract class EntityNPC extends EntityLiving
}
}
// this.foodStats.writeNBT(tagCompound);
// this.writeCapabilitiesToNBT(tagCompound);
tagCompound.setBool("flying", this.flying);
// tagCompound.setFloat("speed", this.speed);
// tagCompound.setBoolean("alwaysInvulnerable", this.disableDamagePersist);

View file

@ -130,9 +130,6 @@ public class EntitySlime extends EntityNPC
// return this.dataWatcher.getWatchableObjectByte(16);
// }
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
@ -140,9 +137,6 @@ public class EntitySlime extends EntityNPC
tagCompound.setBool("wasOnGround", this.wasOnGround);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
@ -459,10 +453,6 @@ public class EntitySlime extends EntityNPC
return ExtMath.clampd((this.isPlayer() ? (this.isSneaking() ? 0.3 : (this.isSprinting() ? 0.8 : 0.55)) : this.rand.drange(0.3, 0.8)) * this.height, 0.2, 1.0);
}
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
public Object onInitialSpawn(Object livingdata)
{
// if(this.rand.chance(5))

View file

@ -178,10 +178,6 @@ public class EntityZombie extends EntityNPC
// return stack.getItem() == Items.egg && this.isRiding() ? false : super.canPickUpItem(stack);
// }
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
public Object onInitialSpawn(Object livingdata)
{
livingdata = super.onInitialSpawn(livingdata);

View file

@ -464,9 +464,6 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setShort("xTile", (short)this.xTile);
@ -482,9 +479,6 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
tagCompound.setDouble("damage", this.damage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.xTile = tagCompund.getShort("xTile");

View file

@ -117,24 +117,6 @@ public class EntityBox extends EntityProjectile
this.setDead();
}
}
// public void onUpdate() {
// super.onUpdate();
// if(!this.worldObj.client && this.age++ >= 200)
// this.setDead();
// }
// public void writeEntityToNBT(NBTTagCompound tagCompound)
// {
// super.writeEntityToNBT(tagCompound);
// tagCompound.setInteger("Age", this.age);
// }
//
// public void readEntityFromNBT(NBTTagCompound tagCompund)
// {
// super.readEntityFromNBT(tagCompund);
// this.age = tagCompund.getInteger("Age");
// }
/**
* Returns true if other Entities should be prevented from moving through this Entity.

View file

@ -53,18 +53,12 @@ public class EntityFireball extends EntityProjectile
return false;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setInt("ExplosionPower", this.explosionPower);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -514,9 +514,6 @@ public class EntityHook extends Entity implements IObjectData
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setShort("xTile", (short)this.xTile);
@ -530,9 +527,6 @@ public class EntityHook extends Entity implements IObjectData
tagCompound.setBool("inGround", this.inGround);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.xTile = tagCompund.getShort("xTile");

View file

@ -148,9 +148,6 @@ public class EntityPotion extends EntityThrowable implements IObjectData
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
@ -170,9 +167,6 @@ public class EntityPotion extends EntityThrowable implements IObjectData
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);

View file

@ -250,9 +250,6 @@ public abstract class EntityProjectile extends Entity
*/
protected abstract void onImpact(HitPosition movingObject);
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setShort("xTile", (short)this.xTile);
@ -269,9 +266,6 @@ public abstract class EntityProjectile extends Entity
tagCompound.setInt("Age", this.age);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.xTile = tagCompund.getShort("xTile");

View file

@ -97,18 +97,12 @@ public abstract class EntityAnimal extends EntityLiving
return this.worldObj.getState(pos.down()).getBlock() == Blocks.grass ? 10.0F : this.worldObj.getLightBrightness(pos) - 0.5F;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setInt("InLove", this.inLove);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -527,9 +527,6 @@ public abstract class EntityLiving extends Entity
// return this.entityAge;
// }
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setInt("MaxHealth", this.getMaxHealth());
@ -581,9 +578,6 @@ public abstract class EntityLiving extends Entity
tagCompound.setString("Description", this.description);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.setAbsorptionAmount(tagCompund.getInt("Absorption"));
@ -612,20 +606,7 @@ public abstract class EntityLiving extends Entity
}
else
{
// NBTBase nbtbase = tagCompund.getTag("Health");
//
// if (nbtbase == null)
// {
this.setHealth(this.getMaxHealth());
// }
// else if (nbtbase.getId() == 5)
// {
// this.setHealth((int)((NBTTagFloat)nbtbase).getFloat());
// }
// else if (nbtbase.getId() == 2)
// {
// this.setHealth((int)((NBTTagShort)nbtbase).getShort());
// }
}
this.hurtTime = tagCompund.getShort("HurtTime");

View file

@ -22,9 +22,6 @@ public abstract class EntityTameable extends EntityAnimal implements IEntityOwna
// this.dataWatcher.addObject(17, "");
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
@ -42,9 +39,6 @@ public abstract class EntityTameable extends EntityAnimal implements IEntityOwna
tagCompound.setBool("Sitting", this.isSitting());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);

View file

@ -300,9 +300,6 @@ public abstract class EntityThrowable extends Entity implements IProjectile
*/
protected abstract void onImpact(HitPosition p_70184_1_);
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntity(TagObject tagCompound)
{
tagCompound.setShort("xTile", (short)this.xTile);
@ -323,9 +320,6 @@ public abstract class EntityThrowable extends Entity implements IProjectile
// tagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntity(TagObject tagCompund)
{
this.xTile = tagCompund.getShort("xTile");

View file

@ -275,7 +275,7 @@ public abstract class BlockRegistry {
register("hardened_clay", (new BlockHardenedClay()).setHardness(1.25F).setResistance(7.0F).setStepSound(SoundType.STONE).setDisplay("Gebrannter Ton"));
for(DyeColor color : DyeColor.values()) {
register(color.getName() + "_clay", (new BlockColoredClay(color)).setHardness(1.25F).setResistance(7.0F)
.setStepSound(SoundType.STONE).setDisplay(color.getSubject(null) + " gefärbter Ton"));
.setStepSound(SoundType.STONE).setDisplay(color.getDisplay() + " gefärbter Ton"));
}
register("coal_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
.setStepSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE).setFlammable(5, 5));
@ -421,11 +421,11 @@ public abstract class BlockRegistry {
register("glass", (new BlockGlass()).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glas"));
for(DyeColor color : DyeColor.values()) {
register(color.getName() + "_glass", (new BlockStainedGlass(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getSubject(null) + " gefärbtes Glas"));
register(color.getName() + "_glass", (new BlockStainedGlass(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getDisplay() + " gefärbtes Glas"));
}
register("glass_pane", (new BlockPane(Material.TRANSLUCENT, false)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glasscheibe"));
for(DyeColor color : DyeColor.values()) {
register(color.getName() + "_glass_pane", (new BlockStainedGlassPane(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getSubject(null) + " gefärbte Glasscheibe"));
register(color.getName() + "_glass_pane", (new BlockStainedGlassPane(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getDisplay() + " gefärbte Glasscheibe"));
}

View file

@ -596,7 +596,7 @@ public abstract class CraftingRegistry
if (type != null)
{
int k = 0;
String k = DyeColor.WHITE.getName();
for (int j = 0; j < inv.getSizeInventory(); ++j)
{
@ -604,12 +604,12 @@ public abstract class CraftingRegistry
if (itemstack2 != null && itemstack2.getItem() instanceof ItemDye dye)
{
k = dye.getColor().getDyeDamage();
k = dye.getColor().getName();
break;
}
}
TagObject tag = itemstack.getSubCompound("BlockEntityTag", true);
TagObject tag = itemstack.getSubTag("BlockEntityTag", true);
List<TagObject> list = null;
if (tag.hasList("Patterns"))
@ -624,7 +624,7 @@ public abstract class CraftingRegistry
TagObject pattern = new TagObject();
pattern.setString("Pattern", type.getPatternID());
pattern.setInt("Color", k);
pattern.setString("Color", k);
list.add(pattern);
}
@ -869,7 +869,7 @@ public abstract class CraftingRegistry
{
aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
}
else if (itemstack.hasTagCompound() && TileEntityBanner.getPatterns(itemstack) > 0)
else if (itemstack.hasTag() && TileEntityBanner.getPatterns(itemstack) > 0)
{
aitemstack[i] = itemstack.copy();
aitemstack[i].size = 1;
@ -970,16 +970,16 @@ public abstract class CraftingRegistry
{
ItemStack itemstack3 = inv.getStackInSlot(k2);
if (itemstack3 != null && itemstack3.getItem() == Items.firework_charge && itemstack3.hasTagCompound() && itemstack3.getTagCompound().hasObject("Explosion"))
if (itemstack3 != null && itemstack3.getItem() == Items.firework_charge && itemstack3.hasTag() && itemstack3.getTag().hasObject("Explosion"))
{
list.add(itemstack3.getTagCompound().getObject("Explosion"));
list.add(itemstack3.getTag().getObject("Explosion"));
}
}
data.setList("Explosions", list);
data.setByte("Flight", (byte)j);
tag.setObject("Fireworks", data);
this.field_92102_a.setTagCompound(tag);
this.field_92102_a.setTag(tag);
}
return true;
@ -1000,7 +1000,7 @@ public abstract class CraftingRegistry
{
if (itemstack2.getItem() instanceof ItemDye dye)
{
list.add(ItemDye.FIREWORK_COLORS[dye.getColor().getDyeDamage()]);
list.add(dye.getColor().getColor());
}
else if (itemstack2.getItem() == Items.glowstone_dust)
{
@ -1039,7 +1039,7 @@ public abstract class CraftingRegistry
data.setIntArray("Colors", aint1);
data.setByte("Type", b0);
tag.setObject("Explosion", data);
this.field_92102_a.setTagCompound(tag);
this.field_92102_a.setTag(tag);
return true;
}
else if (j == 0 && i == 0 && l == 1 && k > 0 && k == i1)
@ -1054,7 +1054,7 @@ public abstract class CraftingRegistry
{
if (itemstack1.getItem() instanceof ItemDye dye)
{
list1.add(ItemDye.FIREWORK_COLORS[dye.getColor().getDyeDamage()]);
list1.add(dye.getColor().getColor());
}
else if (itemstack1.getItem() == Items.firework_charge)
{
@ -1071,9 +1071,9 @@ public abstract class CraftingRegistry
aint[j2] = ((Integer)list1.get(j2)).intValue();
}
if (this.field_92102_a != null && this.field_92102_a.hasTagCompound())
if (this.field_92102_a != null && this.field_92102_a.hasTag())
{
TagObject tag = this.field_92102_a.getTagCompound().getObject("Explosion");
TagObject tag = this.field_92102_a.getTag().getObject("Explosion");
if (tag == null)
{
@ -1540,9 +1540,9 @@ public abstract class CraftingRegistry
{
ItemStack itemstack1 = inv.getStackInSlot(i);
if (itemstack1 != null && itemstack1.hasTagCompound())
if (itemstack1 != null && itemstack1.hasTag())
{
itemstack.setTagCompound(itemstack1.getTagCompound().copy());
itemstack.setTag(itemstack1.getTag().copy());
}
}
}

View file

@ -325,7 +325,7 @@ public class ContainerEnchantment extends Container
return null;
}
if (itemstack1.hasTagCompound() && itemstack1.size == 1)
if (itemstack1.hasTag() && itemstack1.size == 1)
{
((Slot)this.inventorySlots.get(0)).putStack(itemstack1.copy());
itemstack1.size = 0;

View file

@ -52,9 +52,9 @@ public class InventoryHelper
stack.size -= i;
EntityItem entityitem = new EntityItem(worldIn, x + (double)f, y + (double)f1, z + (double)f2, new ItemStack(stack.getItem(), i));
if (stack.hasTagCompound())
if (stack.hasTag())
{
entityitem.getEntityItem().setTagCompound(stack.getTagCompound().copy());
entityitem.getEntityItem().setTag(stack.getTag().copy());
}
float f3 = 0.05F;

View file

@ -201,9 +201,9 @@ public class InventoryPlayer implements IInventory
{
this.mainInventory[j] = new ItemStack(item, 0);
if (itemStackIn.hasTagCompound())
if (itemStackIn.hasTag())
{
this.mainInventory[j].setTagCompound(itemStackIn.getTagCompound().copy());
this.mainInventory[j].setTag(itemStackIn.getTag().copy());
}
}
@ -431,22 +431,16 @@ public class InventoryPlayer implements IInventory
return f;
}
/**
* Writes the inventory out as a list of compound tags. This is where the slot indices are used (+100 for armor, +80
* for crafting).
*
* @param nbtTagListIn List to append tags to
*/
public List<TagObject> writeToNBT(List<TagObject> nbtTagListIn)
public List<TagObject> toTag(List<TagObject> list)
{
for (int i = 0; i < this.mainInventory.length; ++i)
{
if (this.mainInventory[i] != null)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
this.mainInventory[i].writeTags(nbttagcompound);
nbtTagListIn.add(nbttagcompound);
TagObject tag = new TagObject();
tag.setByte("Slot", (byte)i);
this.mainInventory[i].writeTags(tag);
list.add(tag);
}
}
@ -454,42 +448,37 @@ public class InventoryPlayer implements IInventory
{
if (this.armorInventory[j] != null)
{
TagObject nbttagcompound1 = new TagObject();
nbttagcompound1.setByte("Slot", (byte)(j + 100));
this.armorInventory[j].writeTags(nbttagcompound1);
nbtTagListIn.add(nbttagcompound1);
TagObject tag = new TagObject();
tag.setByte("Slot", (byte)(j + 100));
this.armorInventory[j].writeTags(tag);
list.add(tag);
}
}
return nbtTagListIn;
return list;
}
/**
* Reads from the given tag list and fills the slots in the inventory with the correct items.
*
* @param nbtTagListIn tagList to read from
*/
public void readFromNBT(List<TagObject> nbtTagListIn)
public void fromTag(List<TagObject> list)
{
this.mainInventory = new ItemStack[36];
this.armorInventory = new ItemStack[4];
for (int i = 0; i < nbtTagListIn.size(); ++i)
for (int i = 0; i < list.size(); ++i)
{
TagObject nbttagcompound = nbtTagListIn.get(i);
int j = nbttagcompound.getByte("Slot") & 255;
ItemStack itemstack = ItemStack.readFromTag(nbttagcompound);
TagObject tag = list.get(i);
int j = tag.getByte("Slot") & 255;
ItemStack stack = ItemStack.readFromTag(tag);
if (itemstack != null)
if (stack != null)
{
if (j >= 0 && j < this.mainInventory.length)
{
this.mainInventory[j] = itemstack;
this.mainInventory[j] = stack;
}
if (j >= 100 && j < this.armorInventory.length + 100)
{
this.armorInventory[j - 100] = itemstack;
this.armorInventory[j - 100] = stack;
}
}
}

View file

@ -2,13 +2,10 @@ package common.item;
import java.util.List;
import java.util.Map;
import java.util.Set;
import common.attributes.Attribute;
import common.attributes.UsageSlot;
import common.block.Block;
import common.block.tech.BlockDispenser;
import common.collect.Sets;
import common.color.TextColor;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -17,6 +14,7 @@ import common.entity.types.IProjectile;
import common.model.Model;
import common.model.ModelProvider;
import common.model.Transforms;
import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.ExtMath;
@ -26,6 +24,8 @@ import common.util.Vec3;
import common.world.World;
public class Item {
private final List<TagObject> validTags;
private int maxAmount = 64;
private int maxDamage = 0;
private Item containerItem;
@ -33,6 +33,10 @@ public class Item {
private String display;
private CheatTab tab;
private TextColor color = null;
public Item() {
this.validTags = this.getItemTags();
}
public final Item setUnstackable() {
this.maxAmount = 1;
@ -204,9 +208,22 @@ public class Item {
public int getItemEnchantability() {
return 0;
}
protected List<TagObject> getItemTags() {
return null;
}
public void getSubItems(List<ItemStack> subItems) {
subItems.add(new ItemStack(this));
public final void getSubItems(List<ItemStack> subItems) {
if(this.validTags != null) {
for(TagObject valid : this.validTags) {
ItemStack stack = new ItemStack(this);
stack.setTag(valid);
subItems.add(stack);
}
}
else {
subItems.add(new ItemStack(this));
}
}
public CheatTab getTab() {
@ -228,8 +245,14 @@ public class Item {
return false;
}
public final Set<String> getValidTags() {
return Sets.newHashSet();
public final boolean isValidTag(TagObject tag) {
if(this.validTags == null)
return false;
for(TagObject valid : this.validTags) {
if(valid.equals(tag))
return true;
}
return false;
}
public float getRadiation(ItemStack stack) {

View file

@ -431,26 +431,17 @@ public final class ItemStack
this.getItem().onPlayerStoppedUsing(this, worldIn, playerIn, timeLeft);
}
/**
* Returns true if the ItemStack has an NBTTagCompound. Currently used to store enchantments.
*/
public boolean hasTagCompound()
public boolean hasTag()
{
return this.tag != null;
}
/**
* Returns the NBTTagCompound of the ItemStack.
*/
public TagObject getTagCompound()
public TagObject getTag()
{
return this.tag;
}
/**
* Get an NBTTagCompound from this stack's NBT data.
*/
public TagObject getSubCompound(String key, boolean create)
public TagObject getSubTag(String key, boolean create)
{
if (this.tag != null && this.tag.hasObject(key))
{
@ -458,9 +449,9 @@ public final class ItemStack
}
else if (create)
{
TagObject nbttagcompound = new TagObject();
this.setTagInfo(key, nbttagcompound);
return nbttagcompound;
TagObject tag = new TagObject();
this.setTagInfo(key, tag);
return tag;
}
else
{
@ -473,9 +464,9 @@ public final class ItemStack
return this.tag == null ? null : this.tag.getList("ench");
}
public void setTagCompound(TagObject nbt)
public void setTag(TagObject tag)
{
this.tag = nbt;
this.tag = tag;
}
public String getDisplayName()
@ -519,7 +510,7 @@ public final class ItemStack
if (this.tag.isEmpty())
{
this.setTagCompound(null);
this.setTag(null);
}
}
}
@ -540,19 +531,19 @@ public final class ItemStack
list.add(s);
this.item.addInformation(this, playerIn, list);
if (this.hasTagCompound())
if (this.hasTag())
{
List<TagObject> nbttaglist = this.getEnchantmentTagList();
List<TagObject> ench = this.getEnchantmentTagList();
if (nbttaglist != null)
if (ench != null)
{
for (int j = 0; j < nbttaglist.size(); ++j)
for (int j = 0; j < ench.size(); ++j)
{
Enchantment k = Enchantment.getEnchantment(nbttaglist.get(j).getString("id"));
Enchantment k = Enchantment.getEnchantment(ench.get(j).getString("id"));
if (k != null)
{
int l = nbttaglist.get(j).getShort("lvl");
int l = ench.get(j).getShort("lvl");
list.add(k.getFormattedName(l));
}
}
@ -603,9 +594,9 @@ public final class ItemStack
list.add(TextColor.GRAY + ItemRegistry.getName(this.item));
if (this.hasTagCompound())
if (this.hasTag())
{
list.add(TextColor.GRAY + String.format("NBT-Tags: %d", this.getTagCompound().keySet().size()));
list.add(TextColor.GRAY + String.format("Tags: %d", this.getTag().keySet().size()));
}
return list;
@ -636,7 +627,7 @@ public final class ItemStack
{
if (this.tag == null)
{
this.setTagCompound(new TagObject());
this.setTag(new TagObject());
}
if (!this.tag.hasList("ench"))
@ -644,11 +635,11 @@ public final class ItemStack
this.tag.setList("ench", Lists.newArrayList());
}
List<TagObject> nbttaglist = this.tag.getList("ench");
TagObject nbttagcompound = new TagObject();
nbttagcompound.setString("id", ench.getName());
nbttagcompound.setShort("lvl", (short)(/* (byte) */ level));
nbttaglist.add(nbttagcompound);
List<TagObject> list = this.tag.getList("ench");
TagObject tag = new TagObject();
tag.setString("id", ench.getName());
tag.setShort("lvl", (short)(/* (byte) */ level));
list.add(tag);
}
/**
@ -718,7 +709,7 @@ public final class ItemStack
{
if (this.tag == null)
{
this.setTagCompound(new TagObject());
this.setTag(new TagObject());
}
this.tag.setObject(key, value);
@ -728,7 +719,7 @@ public final class ItemStack
{
if (this.tag == null)
{
this.setTagCompound(new TagObject());
this.setTag(new TagObject());
}
this.tag.setList(key, value);
@ -736,7 +727,7 @@ public final class ItemStack
public int getRepairCost()
{
return this.hasTagCompound() && this.tag.hasInt("RepairCost") ? this.tag.getInt("RepairCost") : 0;
return this.hasTag() && this.tag.hasInt("RepairCost") ? this.tag.getInt("RepairCost") : 0;
}
public void setRepairCost(int cost)
@ -755,7 +746,7 @@ public final class ItemStack
return;
}
if (!this.hasTagCompound())
if (!this.hasTag())
{
this.tag = new TagObject();
}

View file

@ -6,6 +6,7 @@ import common.block.Block;
import common.block.tile.BlockBannerStanding;
import common.block.tile.BlockStandingSign;
import common.block.tile.BlockWallSign;
import common.collect.Lists;
import common.color.DyeColor;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
@ -40,11 +41,11 @@ public class ItemBanner extends Item
private ItemStack getColored(DyeColor color) {
TagObject tag = new TagObject();
TileEntityBanner.setBaseColorAndPatterns(tag, color.getDyeDamage(), null);
TileEntityBanner.setBaseColorAndPatterns(tag, color, null);
TagObject tile = new TagObject();
tile.setObject("BlockEntityTag", tag);
ItemStack stack = new ItemStack(this);
stack.setTagCompound(tile);
stack.setTag(tile);
return stack;
}
@ -120,22 +121,22 @@ public class ItemBanner extends Item
*/
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
TagObject tag = stack.getSubTag("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasList("Patterns"))
if (tag != null && tag.hasList("Patterns"))
{
List<TagObject> nbttaglist = nbttagcompound.getList("Patterns");
List<TagObject> list = tag.getList("Patterns");
for (int i = 0; i < nbttaglist.size() && i < 6; ++i)
for (int i = 0; i < list.size() && i < 6; ++i)
{
TagObject nbttagcompound1 = nbttaglist.get(i);
DyeColor enumdyecolor = DyeColor.byDyeDamage(nbttagcompound1.getInt("Color"));
TileEntityBanner.EnumBannerPattern pattern = TileEntityBanner.EnumBannerPattern.getPatternByID(nbttagcompound1.getString("Pattern"));
TagObject pat = list.get(i);
DyeColor color = DyeColor.byName(pat.getString("Color"));
TileEntityBanner.EnumBannerPattern pattern = TileEntityBanner.EnumBannerPattern.getPatternByID(pat.getString("Pattern"));
if (pattern != null)
{
tooltip.add(String.format(pattern.getDisplay(), pattern.isColorLowercase() ?
enumdyecolor.getSubject(pattern.getDisplayType()).toLowerCase() : enumdyecolor.getSubject(pattern.getDisplayType())));
color.getSubject(pattern.getDisplayType()).toLowerCase() : color.getSubject(pattern.getDisplayType())));
}
}
}
@ -154,15 +155,14 @@ public class ItemBanner extends Item
}
}
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
public void getSubItems(List<ItemStack> subItems)
public List<TagObject> getItemTags()
{
List<TagObject> tags = Lists.newArrayList();
for (DyeColor color : DyeColor.values())
{
subItems.add(this.getColored(color));
tags.add(this.getColored(color).getTag());
}
return tags;
}
/**
@ -175,19 +175,19 @@ public class ItemBanner extends Item
private DyeColor getBaseColor(ItemStack stack)
{
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
DyeColor enumdyecolor = null;
TagObject tag = stack.getSubTag("BlockEntityTag", false);
DyeColor color = null;
if (nbttagcompound != null && nbttagcompound.hasInt("Base"))
if (tag != null && tag.hasString("Base"))
{
enumdyecolor = DyeColor.byDyeDamage(nbttagcompound.getInt("Base"));
color = DyeColor.byName(tag.getString("Base"));
}
else
{
enumdyecolor = DyeColor.WHITE;
color = DyeColor.WHITE;
}
return enumdyecolor;
return color;
}
public Transforms getTransform() {

View file

@ -52,9 +52,6 @@ public class ItemBlock extends Item
return this;
}
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
{
State iblockstate = worldIn.getState(pos);
@ -83,7 +80,7 @@ public class ItemBlock extends Item
if (iblockstate1.getBlock() == this.block)
{
setTileEntityNBT(worldIn, playerIn, pos, stack);
setTileData(worldIn, playerIn, pos, stack);
this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
}
@ -99,47 +96,38 @@ public class ItemBlock extends Item
}
}
public static boolean setTileEntityNBT(World worldIn, EntityNPC pos, BlockPos stack, ItemStack p_179224_3_)
public static boolean setTileData(World world, EntityNPC player, BlockPos pos, ItemStack stack)
{
// Server server = Server.getServer();
//
// if (server == null)
// {
// return false;
// }
// else
// {
if (p_179224_3_.hasTagCompound() && p_179224_3_.getTagCompound().hasObject("BlockEntityTag"))
if (stack.hasTag() && stack.getTag().hasObject("BlockEntityTag"))
{
TileEntity tileentity = worldIn.getTileEntity(stack);
TileEntity tile = world.getTileEntity(pos);
if (tileentity != null)
if (tile != null)
{
if (!worldIn.client /* && tileentity.hasSpecialNBT() */ && !pos.connection.isAdmin())
if (!world.client && !player.connection.isAdmin())
{
return false;
}
TagObject nbttagcompound = new TagObject();
TagObject nbttagcompound1 = nbttagcompound.copy();
tileentity.writeTags(nbttagcompound);
TagObject nbttagcompound2 = p_179224_3_.getTagCompound().getObject("BlockEntityTag");
nbttagcompound.merge(nbttagcompound2);
nbttagcompound.setInt("x", stack.getX());
nbttagcompound.setInt("y", stack.getY());
nbttagcompound.setInt("z", stack.getZ());
TagObject tag = new TagObject();
TagObject tileTag = tag.copy();
tile.writeTags(tag);
TagObject stackTag = stack.getTag().getObject("BlockEntityTag");
tag.merge(stackTag);
tag.setInt("x", pos.getX());
tag.setInt("y", pos.getY());
tag.setInt("z", pos.getZ());
if (!nbttagcompound.equals(nbttagcompound1))
if (!tag.equals(tileTag))
{
tileentity.readTags(nbttagcompound);
tileentity.markDirty();
tile.readTags(tag);
tile.markDirty();
return true;
}
}
}
return false;
// }
}
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, Facing side, EntityNPC player, ItemStack stack)
@ -158,26 +146,11 @@ public class ItemBlock extends Item
return worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack);
}
/**
* Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
* different names based on their damage or NBT.
*/
public String getDisplay(ItemStack stack)
{
return this.block.getDisplay();
}
// /**
// * Returns the unlocalized name of this item.
// */
// public String getUnlocalizedName()
// {
// return this.block.getUnlocalizedName();
// }
/**
* gets the tab this item is displayed on
*/
public CheatTab getTab()
{
return this.block.getTab();
@ -188,19 +161,6 @@ public class ItemBlock extends Item
return this.block;
}
// public Set<String> getValidTags() {
// return Sets.newHashSet("BlockEntityTag");
// }
//
// protected boolean validateNbt(NBTTagCompound tag) {
// if(tag.hasKey("BlockEntityTag")) {
// if(!tag.hasTag("BlockEntityTag")) {
// return false;
// }
// }
// return true;
// }
public boolean isMagnetic() {
return this.block.isMagnetic();
}

View file

@ -74,7 +74,7 @@ public class ItemSign extends Item
--stack.size;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
if (tileentity instanceof TileEntitySign && !ItemBlock.setTileData(worldIn, playerIn, pos, stack))
{
playerIn.openEditSign((TileEntitySign)tileentity);
}

View file

@ -40,7 +40,7 @@ public class ItemSmallBlock extends Item {
newState = world.getState(pos);
if(newState.getBlock() == this.block) {
ItemBlock.setTileEntityNBT(world, player, pos, stack);
ItemBlock.setTileData(world, player, pos, stack);
newState.getBlock().onBlockPlacedBy(world, pos, newState, player, stack);
}

View file

@ -24,22 +24,20 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class ItemDye extends Item
{
public static final int[] FIREWORK_COLORS = new int[] {1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320};
public class ItemDye extends Item {
private static final ItemDye[] DIES = new ItemDye[DyeColor.values().length];
private final DyeColor color;
public static ItemDye getByColor(DyeColor color) {
return DIES[color.getMetadata()];
return DIES[color.ordinal()];
}
public ItemDye(DyeColor color)
{
this.color = color;
this.setTab(CheatTab.MATERIALS);
DIES[this.color.getMetadata()] = this;
this.setTab(color == DyeColor.BLUE ? CheatTab.METALS : CheatTab.MATERIALS);
DIES[this.color.ordinal()] = this;
}
public DyeColor getColor() {

View file

@ -34,12 +34,14 @@ public class ItemEnchantedBook extends Item
return false;
}
public void getSubItems(List<ItemStack> subItems)
public List<TagObject> getItemTags()
{
List<TagObject> tags = Lists.newArrayList();
for (Enchantment enchantment : Enchantment.values()) {
if(enchantment != null && enchantment.getType() != null)
subItems.add(this.getEnchantedItemStack(new RngEnchantment(enchantment, enchantment.getMaxLevel())));
tags.add(this.getEnchantedItemStack(new RngEnchantment(enchantment, enchantment.getMaxLevel())).getTag());
}
return tags;
}
// /**
@ -52,7 +54,7 @@ public class ItemEnchantedBook extends Item
public List<TagObject> getEnchantments(ItemStack stack)
{
TagObject nbttagcompound = stack.getTagCompound();
TagObject nbttagcompound = stack.getTag();
return nbttagcompound != null && nbttagcompound.hasList("StoredEnchantments") ? nbttagcompound.getList("StoredEnchantments") : Lists.newArrayList();
}
@ -111,12 +113,12 @@ public class ItemEnchantedBook extends Item
nbttaglist.add(nbttagcompound1);
}
if (!stack.hasTagCompound())
if (!stack.hasTag())
{
stack.setTagCompound(new TagObject());
stack.setTag(new TagObject());
}
stack.getTagCompound().setList("StoredEnchantments", nbttaglist);
stack.getTag().setList("StoredEnchantments", nbttaglist);
}
/**

View file

@ -101,7 +101,7 @@ public class ItemArmor extends Item
*/
public boolean hasColor(ItemStack stack)
{
return this.material.canBeDyed() && stack.hasTagCompound() && stack.getTagCompound().hasInt("color");
return this.material.canBeDyed() && stack.hasTag() && stack.getTag().hasInt("color");
}
/**
@ -115,16 +115,11 @@ public class ItemArmor extends Item
}
else
{
TagObject nbttagcompound = stack.getTagCompound();
TagObject nbttagcompound = stack.getTag();
if (nbttagcompound != null && nbttagcompound.hasInt("color"))
{
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
//
// if (nbttagcompound1 != null && nbttagcompound1.hasInt("color"))
// {
return nbttagcompound.getInt("color");
// }
}
return this.material.getDefaultColor();
@ -138,17 +133,15 @@ public class ItemArmor extends Item
{
if (this.material.canBeDyed())
{
TagObject nbttagcompound = stack.getTagCompound();
TagObject nbttagcompound = stack.getTag();
if (nbttagcompound != null)
{
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
if (nbttagcompound.hasInt("color"))
{
nbttagcompound.remove("color");
if(nbttagcompound.isEmpty())
stack.setTagCompound(null);
stack.setTag(null);
}
}
}
@ -165,21 +158,14 @@ public class ItemArmor extends Item
}
else
{
TagObject nbttagcompound = stack.getTagCompound();
TagObject nbttagcompound = stack.getTag();
if (nbttagcompound == null)
{
nbttagcompound = new TagObject();
stack.setTagCompound(nbttagcompound);
stack.setTag(nbttagcompound);
}
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
//
// if (!nbttagcompound.hasTag("display"))
// {
// nbttagcompound.setTag("display", nbttagcompound1);
// }
nbttagcompound.setInt("color", color);
}
}
@ -242,8 +228,8 @@ public class ItemArmor extends Item
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip) {
if(this.material.canBeDyed()) {
int color = this.material.getDefaultColor();
if(stack.hasTagCompound() && stack.getTagCompound().hasInt("color"))
color = stack.getTagCompound().getInt("color");
if(stack.hasTag() && stack.getTag().hasInt("color"))
color = stack.getTag().getInt("color");
tooltip.add("Farbe: #" + Integer.toHexString(color).toUpperCase());
}
}

View file

@ -51,7 +51,7 @@ public class ItemCarrotOnAStick extends Item
if (itemStackIn.size == 0)
{
ItemStack itemstack = new ItemStack(Items.fishing_rod);
itemstack.setTagCompound(itemStackIn.getTagCompound());
itemstack.setTag(itemStackIn.getTag());
return itemstack;
}
}

View file

@ -44,9 +44,9 @@ public class ItemFirework extends Item
*/
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{
if (stack.hasTagCompound())
if (stack.hasTag())
{
TagObject nbttagcompound = stack.getTagCompound().getObject("Fireworks");
TagObject nbttagcompound = stack.getTag().getObject("Fireworks");
if (nbttagcompound != null)
{

View file

@ -7,7 +7,6 @@ import common.entity.npc.EntityNPC;
import common.entity.projectile.EntityFireCharge;
import common.item.Item;
import common.item.ItemStack;
import common.item.material.ItemDye;
import common.model.Model;
import common.model.ModelProvider;
import common.tags.TagObject;
@ -29,9 +28,9 @@ public class ItemFireworkCharge extends Item
}
else
{
if (stack.hasTagCompound())
if (stack.hasTag())
{
TagObject nbttagcompound = stack.getTagCompound().getObject("Explosion");
TagObject nbttagcompound = stack.getTag().getObject("Explosion");
if (nbttagcompound != null)
{
@ -72,9 +71,9 @@ public class ItemFireworkCharge extends Item
*/
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{
if (stack.hasTagCompound())
if (stack.hasTag())
{
TagObject nbttagcompound = stack.getTagCompound().getObject("Explosion");
TagObject nbttagcompound = stack.getTag().getObject("Explosion");
if (nbttagcompound != null)
{
@ -113,12 +112,12 @@ public class ItemFireworkCharge extends Item
flag = false;
boolean flag1 = false;
for (int j = 0; j < ItemDye.FIREWORK_COLORS.length; ++j)
for (DyeColor color : DyeColor.values())
{
if (i == ItemDye.FIREWORK_COLORS[j])
if (i == color.getColor())
{
flag1 = true;
s = s + DyeColor.byDyeDamage(j).getDisplay();
s = s + color.getDisplay();
break;
}
}
@ -149,12 +148,12 @@ public class ItemFireworkCharge extends Item
flag2 = false;
boolean flag5 = false;
for (int k = 0; k < 16; ++k)
for (DyeColor color : DyeColor.values())
{
if (l == ItemDye.FIREWORK_COLORS[k])
if (l == color.getColor())
{
flag5 = true;
s1 = s1 + DyeColor.byDyeDamage(k).getDisplay();
s1 = s1 + color.getDisplay();
break;
}
}

View file

@ -119,7 +119,7 @@ public class PacketBuffer {
}
this.writeShort(ItemRegistry.getId(stack.getItem()));
this.writeVarInt(stack.size);
this.writeTag(stack.getTagCompound());
this.writeTag(stack.getTag());
}
public ItemStack readItemStack() throws IOException {
@ -128,7 +128,7 @@ public class PacketBuffer {
return null;
int amt = this.readVarInt();
ItemStack stack = new ItemStack(ItemRegistry.byId(id), amt);
stack.setTagCompound(this.readTag());
stack.setTag(this.readTag());
return stack;
}

View file

@ -23,7 +23,7 @@ public class MachineResource {
this.overcharge = over;
}
public void readFromNbt(TagObject tag) {
public void fromTag(TagObject tag) {
this.amount = tag.getInt("Amount");
this.capacity = tag.getInt("Capacity");
this.undercharge = tag.getInt("Under");
@ -31,7 +31,7 @@ public class MachineResource {
this.entropy = tag.getInt("Entropy");
}
public void writeToNbt(TagObject tag) {
public void toTag(TagObject tag) {
tag.setInt("Amount", this.amount);
tag.setInt("Capacity", this.capacity);
tag.setInt("Under", this.undercharge);

View file

@ -9,11 +9,11 @@ public record Passcode(String code) {
return this.code == null || this.code.isEmpty();
}
public void toNBT(TagObject tag) {
public void toTag(TagObject tag) {
tag.setString("Lock", this.code);
}
public static Passcode fromNBT(TagObject tag) {
public static Passcode fromTag(TagObject tag) {
return tag.hasString("Lock") ? new Passcode(tag.getString("Lock")) : EMPTY_CODE;
}
}

View file

@ -75,16 +75,13 @@ public abstract class TileEntity
}
}
/**
* Creates a new entity and loads its data from the specified NBT.
*/
public static TileEntity createAndLoadEntity(TagObject nbt)
public static TileEntity createAndLoadEntity(TagObject tag)
{
TileEntity tileentity = null;
try
{
Class <? extends TileEntity > oclass = (Class)TileRegistry.NAME_TO_CLASS.get(nbt.getString("id"));
Class <? extends TileEntity > oclass = (Class)TileRegistry.NAME_TO_CLASS.get(tag.getString("id"));
if (oclass != null)
{
@ -98,11 +95,11 @@ public abstract class TileEntity
if (tileentity != null)
{
tileentity.readTags(nbt);
tileentity.readTags(tag);
}
else
{
Log.TICK.warn("Ignoriere Block-Objekt mit ID " + nbt.getString("id"));
Log.TICK.warn("Ignoriere Block-Objekt mit ID " + tag.getString("id"));
}
return tileentity;
@ -214,11 +211,6 @@ public abstract class TileEntity
{
this.pos = posIn;
}
// public boolean hasSpecialNBT()
// {
// return false;
// }
public abstract int getColor();
}

View file

@ -12,7 +12,7 @@ import common.tags.TagObject;
public class TileEntityBanner extends TileEntity
{
private int baseColor;
private DyeColor baseColor;
/** A list of all the banner patterns. */
private List<TagObject> patterns;
@ -29,9 +29,9 @@ public class TileEntityBanner extends TileEntity
{
this.patterns = null;
if (stack.hasTagCompound() && stack.getTagCompound().hasObject("BlockEntityTag"))
if (stack.hasTag() && stack.getTag().hasObject("BlockEntityTag"))
{
TagObject nbttagcompound = stack.getTagCompound().getObject("BlockEntityTag");
TagObject nbttagcompound = stack.getTag().getObject("BlockEntityTag");
if (nbttagcompound.hasList("Patterns"))
{
@ -41,18 +41,18 @@ public class TileEntityBanner extends TileEntity
}
}
if (nbttagcompound.hasInt("Base"))
if (nbttagcompound.hasString("Base"))
{
this.baseColor = nbttagcompound.getInt("Base");
this.baseColor = DyeColor.byName(nbttagcompound.getString("Base"));
}
else
{
this.baseColor = DyeColor.WHITE.getDyeDamage();
this.baseColor = DyeColor.WHITE;
}
}
else
{
this.baseColor = DyeColor.WHITE.getDyeDamage();
this.baseColor = DyeColor.WHITE;
}
this.patternList = null;
@ -67,9 +67,9 @@ public class TileEntityBanner extends TileEntity
setBaseColorAndPatterns(compound, this.baseColor, this.patterns);
}
public static void setBaseColorAndPatterns(TagObject compound, int baseColorIn, List<TagObject> patternsIn)
public static void setBaseColorAndPatterns(TagObject compound, DyeColor baseColorIn, List<TagObject> patternsIn)
{
compound.setInt("Base", baseColorIn);
compound.setString("Base", baseColorIn.getName());
if (patternsIn != null)
{
@ -80,7 +80,7 @@ public class TileEntityBanner extends TileEntity
public void readTags(TagObject compound)
{
super.readTags(compound);
this.baseColor = compound.getInt("Base");
this.baseColor = DyeColor.byName(compound.getString("Base"));
this.patterns = compound.getList("Patterns");
this.patternList = null;
this.colorList = null;
@ -97,15 +97,15 @@ public class TileEntityBanner extends TileEntity
return new SPacketUpdateTileEntity(this);
}
public int getBaseColor()
public DyeColor getBaseColor()
{
return this.baseColor;
}
public static DyeColor getBaseColor(ItemStack stack)
{
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasInt("Base") ? DyeColor.byDyeDamage(nbttagcompound.getInt("Base")) : DyeColor.WHITE;
TagObject nbttagcompound = stack.getSubTag("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasString("Base") ? DyeColor.byName(nbttagcompound.getString("Base")) : DyeColor.WHITE;
}
/**
@ -113,7 +113,7 @@ public class TileEntityBanner extends TileEntity
*/
public static int getPatterns(ItemStack stack)
{
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
TagObject nbttagcompound = stack.getSubTag("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasList("Patterns") ? nbttagcompound.getList("Patterns").size() : 0;
}
@ -157,8 +157,8 @@ public class TileEntityBanner extends TileEntity
this.patternList = Lists.<TileEntityBanner.EnumBannerPattern>newArrayList();
this.colorList = Lists.<DyeColor>newArrayList();
this.patternList.add(TileEntityBanner.EnumBannerPattern.BASE);
this.colorList.add(DyeColor.byDyeDamage(this.baseColor));
this.patternResourceLocation = "b" + this.baseColor;
this.colorList.add(this.baseColor);
this.patternResourceLocation = "b" + this.baseColor.ordinal();
if (this.patterns != null)
{
@ -170,9 +170,10 @@ public class TileEntityBanner extends TileEntity
if (tileentitybanner$enumbannerpattern != null)
{
this.patternList.add(tileentitybanner$enumbannerpattern);
int j = nbttagcompound.getInt("Color");
this.colorList.add(DyeColor.byDyeDamage(j));
this.patternResourceLocation = this.patternResourceLocation + tileentitybanner$enumbannerpattern.getPatternID() + j;
String j = nbttagcompound.getString("Color");
DyeColor color = DyeColor.byName(j);
this.colorList.add(color);
this.patternResourceLocation = this.patternResourceLocation + tileentitybanner$enumbannerpattern.getPatternID() + color.ordinal();
}
}
}
@ -189,7 +190,7 @@ public class TileEntityBanner extends TileEntity
*/
public static void removeBannerData(ItemStack stack)
{
TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
TagObject nbttagcompound = stack.getSubTag("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasList("Patterns"))
{
@ -201,11 +202,11 @@ public class TileEntityBanner extends TileEntity
if (nbttaglist.isEmpty())
{
stack.getTagCompound().remove("BlockEntityTag");
stack.getTag().remove("BlockEntityTag");
if (stack.getTagCompound().isEmpty())
if (stack.getTag().isEmpty())
{
stack.setTagCompound((TagObject)null);
stack.setTag((TagObject)null);
}
}
}

View file

@ -310,7 +310,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
this.secondaryEffect = compound.hasString("Secondary") ? this.getEffect(compound.getString("Secondary")) : null;
this.levels = compound.getInt("Levels");
// try {
this.beamColor = DyeColor.getByName(compound.getString("Color"));
this.beamColor = DyeColor.byName(compound.getString("Color"));
// }
// catch(IllegalArgumentException e) {
// this.beamColor = DyeColor.WHITE;
@ -509,7 +509,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
{
if (id == 1)
{
this.beamColor = DyeColor.byMetadata(type);
this.beamColor = DyeColor.values()[type % DyeColor.values().length];
return true;
}
else
@ -529,7 +529,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
public void setBeamColor(DyeColor color) {
this.beamColor = color;
if(!this.worldObj.client)
this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, color.getMetadata());
this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, color.ordinal());
}
// public static class BeamSegment

View file

@ -80,56 +80,56 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
this.status = status;
}
public void readTags(TagObject compound) {
super.readTags(compound);
public void readTags(TagObject tag) {
super.readTags(tag);
List<TagObject> nbttaglist = compound.getList("Items");
List<TagObject> list = tag.getList("Items");
this.clear();
for(int i = 0; i < nbttaglist.size(); ++i) {
TagObject nbttagcompound = nbttaglist.get(i);
int j = nbttagcompound.getByte("Slot");
for(int i = 0; i < list.size(); ++i) {
TagObject slot = list.get(i);
int j = slot.getByte("Slot");
if(j >= 0 && j < this.inventory.length) {
this.inventory[j] = ItemStack.readFromTag(nbttagcompound);
this.inventory[j] = ItemStack.readFromTag(slot);
}
}
nbttaglist = compound.getList("Resources");
list = tag.getList("Resources");
for(MachineResource res : this.resources) {
res.reset();
}
for(int i = 0; i < nbttaglist.size() && i < this.inventory.length; ++i) {
this.resources[i].readFromNbt(nbttaglist.get(i));
for(int i = 0; i < list.size() && i < this.inventory.length; ++i) {
this.resources[i].fromTag(list.get(i));
}
this.temperature = compound.getInt("Temperature");
this.status = Status.values()[(int)compound.getByte("Status") % Status.values().length];
this.temperature = tag.getInt("Temperature");
this.status = Status.values()[(int)tag.getByte("Status") % Status.values().length];
}
public void writeTags(TagObject compound) {
super.writeTags(compound);
public void writeTags(TagObject tag) {
super.writeTags(tag);
List<TagObject> nbttaglist = Lists.newArrayList();
List<TagObject> list = Lists.newArrayList();
for(int i = 0; i < this.inventory.length; ++i) {
if(this.inventory[i] != null) {
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
this.inventory[i].writeTags(nbttagcompound);
nbttaglist.add(nbttagcompound);
TagObject slot = new TagObject();
slot.setByte("Slot", (byte)i);
this.inventory[i].writeTags(slot);
list.add(slot);
}
}
compound.setList("Items", nbttaglist);
tag.setList("Items", list);
nbttaglist = Lists.newArrayList();
list = Lists.newArrayList();
for(int z = 0; z < this.resources.length; z++) {
TagObject res = new TagObject();
this.resources[z].writeToNbt(res);
nbttaglist.add(res);
this.resources[z].toTag(res);
list.add(res);
}
compound.setList("Resources", nbttaglist);
tag.setList("Resources", list);
compound.setInt("Temperature", this.temperature);
compound.setByte("Status", (byte)this.status.ordinal());
tag.setInt("Temperature", this.temperature);
tag.setByte("Status", (byte)this.status.ordinal());
}
public int getSizeInventory() {

View file

@ -9,7 +9,7 @@ public abstract class TileEntityLockable extends TileEntity implements IInteract
public void readTags(TagObject compound)
{
super.readTags(compound);
this.code = Passcode.fromNBT(compound);
this.code = Passcode.fromTag(compound);
}
public void writeTags(TagObject compound)
@ -18,7 +18,7 @@ public abstract class TileEntityLockable extends TileEntity implements IInteract
if (this.code != null)
{
this.code.toNBT(compound);
this.code.toTag(compound);
}
}

View file

@ -80,29 +80,29 @@ public class TileEntityMobSpawner extends TileEntityDevice implements ITickable
}
}
public void readTags(TagObject nbt)
public void readTags(TagObject tag)
{
super.readTags(nbt);
this.spawnDelay = nbt.getShort("Delay");
super.readTags(tag);
this.spawnDelay = tag.getShort("Delay");
if (nbt.hasShort("MinSpawnDelay"))
if (tag.hasShort("MinSpawnDelay"))
{
this.minSpawnDelay = nbt.getShort("MinSpawnDelay");
this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay");
this.minSpawnDelay = tag.getShort("MinSpawnDelay");
this.maxSpawnDelay = tag.getShort("MaxSpawnDelay");
}
if (nbt.hasShort("SpawnRange"))
if (tag.hasShort("SpawnRange"))
{
this.spawnRange = nbt.getShort("SpawnRange");
this.spawnRange = tag.getShort("SpawnRange");
}
}
public void writeTags(TagObject nbt)
public void writeTags(TagObject tag)
{
super.writeTags(nbt);
nbt.setShort("Delay", (short)this.spawnDelay);
nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
nbt.setShort("SpawnRange", (short)this.spawnRange);
super.writeTags(tag);
tag.setShort("Delay", (short)this.spawnDelay);
tag.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
tag.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
tag.setShort("SpawnRange", (short)this.spawnRange);
}
}

View file

@ -8,16 +8,7 @@ import common.tags.TagObject;
public class TileEntitySign extends TileEntity {
public final String[] signText = new String[] {"", "", "", ""};
/**
* The index of the line currently being edited. Only used on client side, but
* defined on both. Note this is only really used when the > < are going to be
* visible.
*/
// public int lineBeingEdited = -1;
// public String command;
// private boolean isEditable = true;
private EntityNPC player;
// private boolean oldFormat;
public void writeTags(TagObject compound) {
super.writeTags(compound);
@ -25,72 +16,16 @@ public class TileEntitySign extends TileEntity {
for(int i = 0; i < 4; ++i) {
compound.setString("Text" + (i + 1), this.signText[i]);
}
// if(this.command != null)
// compound.setString("Command", this.command);
}
public void readTags(TagObject compound) {
// this.isEditable = false;
super.readTags(compound);
for(int i = 0; i < 4; ++i) {
this.signText[i] = compound.getString("Text" + (i + 1));
}
// if(compound.hasString("Command"))
// this.command = compound.getString("Command");
// if(!compound.getBoolean("NewFormat")) {
// Log.debug("Konvertiere Schild bei " + this.pos.getX() + "," + this.pos.getY() + "," + this.pos.getZ() + " ...");
// byte newComp = 0;
// byte quotes = 0;
// String[] old = new String[4];
// for(int i = 0; i < 4; ++i) {
// old[i] = this.signText[i];
//// if(ChatFormat.hasLegacy(this.signText[i])) {
// this.signText[i] = ChatFormat.replaceLegacy(this.signText[i]);
//// }
// if(this.signText[i].startsWith("{") && this.signText[i].endsWith("}")) {
// try {
// TextComponent comp = TextSerializer.toComponent(this.signText[i]);
// this.signText[i] = comp.getFormattedText();
// newComp++;
// }
// catch(Throwable e) {
// }
// }
// else if(this.signText[i].startsWith("\"") && this.signText[i].endsWith("\"")) {
// newComp++;
// quotes |= 1 << i;
// }
// }
// for(int i = 0; i < 4; ++i) {
// if(newComp == 4 && (quotes & (1 << i)) != 0) {
// this.signText[i] = this.signText[i].substring(1, this.signText[i].length() - 1);
// }
// if(old[i] != this.signText[i]) {
// Log.debug("Zeile " + (i + 1) + ": '" + ChatFormat.stripCodes(this.signText[i]) + "'");
// }
// }
// this.oldFormat = true;
// }
}
// public boolean validate() {
// super.validate();
// if(this.oldFormat) {
// this.oldFormat = false;
// return true;
// }
// return false;
// }
/**
* Allows for a specialized description packet to be created. This is often used
* to sync tile entity data from the server to the client easily. For example
* this is used by signs to synchronise the text to be displayed.
*/
public Packet getDescriptionPacket() {
String[] aichatcomponent = new String[4];
System.arraycopy(this.signText, 0, aichatcomponent, 0, 4);
@ -98,25 +33,6 @@ public class TileEntitySign extends TileEntity {
return new SPacketUpdateSign(this.worldObj, this.pos, aichatcomponent);
}
// public boolean hasSpecialNBT() {
// return true;
// }
// public boolean getIsEditable() {
// return this.isEditable;
// }
//
// /**
// * Sets the sign's isEditable flag to the specified parameter.
// */
// public void setEditable(boolean isEditableIn) {
// this.isEditable = isEditableIn;
//
// if(!isEditableIn) {
// this.player = null;
// }
// }
public void setPlayer(EntityNPC playerIn) {
this.player = playerIn;
}
@ -124,8 +40,8 @@ public class TileEntitySign extends TileEntity {
public EntityNPC getPlayer() {
return this.player;
}
public int getColor() {
return 0x00ffff;
}
public int getColor() {
return 0x00ffff;
}
}

View file

@ -33,7 +33,7 @@ public class MerchantRecipeList extends ArrayList<MerchantRecipe> {
private static boolean areItemsSimilar(ItemStack stack1, ItemStack stack2) {
return ItemStack.areItemsEqual(stack1, stack2)
&& (!stack2.hasTagCompound() || stack1.hasTagCompound() && TagObject.compare(stack2.getTagCompound(), stack1.getTagCompound()));
&& (!stack2.hasTag() || stack1.hasTag() && TagObject.compare(stack2.getTag(), stack1.getTag()));
}
public void fromTags(List<TagObject> list) {

View file

@ -16,7 +16,7 @@ public class ColorParser extends IntParser {
input = input.substring(1);
}
else {
DyeColor color = DyeColor.getByString(input);
DyeColor color = DyeColor.getExact(input);
if(color != null)
return color.getColor();
}

View file

@ -34,7 +34,7 @@ public class CommandItem extends Command {
ItemStack stack = ItemStack.getStack(item, null);
if(stack == null)
throw new RunException("Gegenstand '%s' existiert nicht", item);
stack.setTagCompound(tag);
stack.setTag(tag);
int done = 0;
int given = 0;
for(EntityNPC player : players) {

View file

@ -2870,69 +2870,22 @@ public class Player extends User implements ICrafting, Executor, IPlayer
public void processCheat(CPacketCheat packet)
{
NetHandler.checkThread(packet, this, this.server);
if(this.charEditor)
return;
if(!this.isAdmin())
if(this.charEditor || !this.isAdmin())
return;
// if (this.playerEntity.creative)
// {
// boolean drop = packetIn.getSlotId() < 0;
// boolean changed = false;
ItemStack itemstack = packet.getStack();
// if(itemstack != null && itemstack.getItem() == Items.barrier && !this.playerEntity.canUse(Permissions.BARRIER)) {
// changed = true;
// itemstack = null;
// }
// if(itemstack != null && !itemstack.validate()) {
// changed = true;
// }
if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasObject("BlockEntityTag"))
ItemStack stack = packet.getStack();
if (stack.getItem() != null && stack.size <= stack.getMaxStackSize() && stack.size > 0 && (!stack.hasTag() || stack.getItem().isValidTag(stack.getTag())))
{
// if(!itemstack.getTagCompound().hasTag("BlockEntityTag")) {
// changed = true;
// itemstack.setTagCompound(null);
// }
// else {
TagObject tag = itemstack.getTagCompound().getObject("BlockEntityTag");
if (tag.hasInt("x") && tag.hasInt("y") && tag.hasInt("z"))
{
BlockPos pos = new BlockPos(tag.getInt("x"), tag.getInt("y"), tag.getInt("z"));
TileEntity te = this.entity.worldObj.getTileEntity(pos);
if (te != null)
{
TagObject tile = new TagObject();
te.writeTags(tile);
tile.remove("x");
tile.remove("y");
tile.remove("z");
itemstack.setTagInfo("BlockEntityTag", tile);
}
}
// }
}
// boolean validSlot = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize();
boolean validItem = itemstack.getItem() != null;
boolean validData = itemstack.size <= itemstack.getMaxStackSize() && itemstack.size > 0; // TODO: max
if (validItem && validData)
{
int amount = itemstack.size;
int amount = stack.size;
if(packet.getSlot() == -1) {
this.entity.inventory.addItemStackToInventory(itemstack);
amount -= itemstack.size;
this.entity.inventory.addItemStackToInventory(stack);
amount -= stack.size;
}
else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) {
else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) {
ItemStack old = this.entity.inventory.getStackInSlot(packet.getSlot());
if(old != null) {
if(ItemStack.areItemsEqual(itemstack, old) && ItemStack.areItemStackTagsEqual(itemstack, old)) {
itemstack.size = Math.min(itemstack.getMaxStackSize(), old.size + itemstack.size);
amount = itemstack.size - old.size;
if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) {
stack.size = Math.min(stack.getMaxStackSize(), old.size + stack.size);
amount = stack.size - old.size;
}
else if(old.size == 1)
this.addFeed(TextColor.DRED + "* %s zerstört",
@ -2941,7 +2894,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size,
old.getColoredName(TextColor.DRED));
}
this.entity.inventory.setInventorySlotContents(packet.getSlot(), itemstack);
this.entity.inventory.setInventorySlotContents(packet.getSlot(), stack);
}
else {
return;
@ -2952,10 +2905,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.entity.worldObj.playSoundAtEntity(this.entity, SoundEvent.POP, 0.2F);
if(amount == 1)
this.addFeed(TextColor.DGREEN + "* %s geschummelt",
itemstack.getColoredName(TextColor.DGREEN));
stack.getColoredName(TextColor.DGREEN));
else
this.addFeed(TextColor.DGREEN + "* %d %s geschummelt", amount,
itemstack.getColoredName(TextColor.DGREEN));
stack.getColoredName(TextColor.DGREEN));
}
}

View file

@ -312,6 +312,10 @@ public abstract class Converter {
private static final Map<String, String> ENTITY_MAP = Maps.newHashMap();
private static final Map<String, String> TILE_MAP = Maps.newHashMap();
private static final State[] BLOCK_MAP = new State[65536];
private static final DyeColor[] COLOR_LOOKUP = new DyeColor[] {
DyeColor.WHITE, DyeColor.ORANGE, DyeColor.MAGENTA, DyeColor.LIGHT_BLUE, DyeColor.YELLOW, DyeColor.LIME, DyeColor.PINK, DyeColor.GRAY,
DyeColor.SILVER, DyeColor.CYAN, DyeColor.PURPLE, DyeColor.BLUE, DyeColor.BROWN, DyeColor.GREEN, DyeColor.RED, DyeColor.BLACK
};
private static void mapEntity(Class<? extends Entity> clazz, String ... names) {
String name = EntityRegistry.getEntityString(clazz);
@ -575,7 +579,7 @@ public abstract class Converter {
mapBlock(Blocks.piston_head.getState().withProperty(BlockPistonHead.FACING, Facing.EAST).withProperty(BlockPistonHead.TYPE, EnumPistonType.STICKY), 34, 13);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockWool.getByColor(DyeColor.byMetadata(data)).getState();
return BlockWool.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 35);
mapBlock(Blocks.stone, 36); // mapBlockData(Blocks.piston_extension, 36);
@ -901,7 +905,7 @@ public abstract class Converter {
mapBlock(Blocks.powered_repeater.getState().withProperty(BlockRedstoneRepeater.DELAY, 4).withProperty(BlockRedstoneRepeater.FACING, Facing.EAST), 94, 15);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockStainedGlass.getByColor(DyeColor.byMetadata(data)).getState();
return BlockStainedGlass.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 95);
mapBlock(Blocks.trapdoor.getState().withProperty(BlockTrapDoor.FACING, Facing.NORTH).withProperty(BlockTrapDoor.HALF, DoorHalf.BOTTOM).withProperty(BlockTrapDoor.OPEN, false), 96, 0);
@ -1352,12 +1356,12 @@ public abstract class Converter {
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST).withProperty(BlockDropper.TRIGGERED, true), 158, 13);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(DyeColor.byMetadata(data)).getState();
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 159);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockStainedGlassPane.getByColor(DyeColor.byMetadata(data)).getState();
return BlockStainedGlassPane.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 160);
mapBlock(Blocks.acacia_leaves_spring.getState()
@ -1425,7 +1429,7 @@ public abstract class Converter {
mapBlock(Blocks.hay_block.getState().withProperty(BlockHay.AXIS, Axis.Z), 170, 8, 9, 10, 11);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockCarpet.getByColor(DyeColor.byMetadata(data)).getState();
return BlockCarpet.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 171);
mapBlock(Blocks.hardened_clay, 172);
@ -1631,19 +1635,19 @@ public abstract class Converter {
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.WEST).withProperty(BlockDropper.TRIGGERED, true), 218, 12);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST).withProperty(BlockDropper.TRIGGERED, true), 218, 13);
for(int id = 219; id <= 234; id++) {
mapBlock(BlockWool.getByColor(DyeColor.byMetadata(id - 219)).getState(), id);
mapBlock(BlockWool.getByColor(COLOR_LOOKUP[id - 219]).getState(), id);
}
for(int id = 235; id <= 250; id++) {
mapBlock(BlockColoredClay.getByColor(DyeColor.byMetadata(id - 235)).getState(), id);
mapBlock(BlockColoredClay.getByColor(COLOR_LOOKUP[id - 235]).getState(), id);
}
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(DyeColor.byMetadata(data)).getState();
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 251);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(DyeColor.byMetadata(data)).getState();
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 252);
mapBlock(Blocks.obsidian, 255);