Sweeping changes, mainly NBT related
This commit is contained in:
parent
4035d91151
commit
c8996c8fba
157 changed files with 622 additions and 623 deletions
|
@ -41,7 +41,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche
|
|||
public void deserialize(CompoundNBT tagCompound) {
|
||||
super.deserialize(tagCompound);
|
||||
this.isActive = tagCompound.getBoolean("isActive");
|
||||
this.activeCounter = tagCompound.getInteger("activeCounter");
|
||||
this.activeCounter = tagCompound.getInt("activeCounter");
|
||||
this.key = tagCompound.getString("key");
|
||||
if (!tagCompound.hasKey("doDropIngredients")) //Check if the array is old
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche
|
|||
} else {
|
||||
this.doDropIngredients = tagCompound.getBoolean("doDropIngredients");
|
||||
}
|
||||
this.rotation = Direction.HORIZONTALS[tagCompound.getInteger(Constants.NBT.DIRECTION)];
|
||||
this.rotation = Direction.HORIZONTALS[tagCompound.getInt(Constants.NBT.DIRECTION)];
|
||||
|
||||
CompoundNBT arrayTag = tagCompound.getCompoundTag("arrayTag");
|
||||
arrayEffect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(key);
|
||||
|
@ -61,17 +61,17 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche
|
|||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tagCompound) {
|
||||
super.serialize(tagCompound);
|
||||
tagCompound.setBoolean("isActive", isActive);
|
||||
tagCompound.setInteger("activeCounter", activeCounter);
|
||||
tagCompound.setString("key", "".equals(key) ? "empty" : key);
|
||||
tagCompound.setBoolean("doDropIngredients", doDropIngredients);
|
||||
tagCompound.setInteger(Constants.NBT.DIRECTION, rotation.getHorizontalIndex());
|
||||
tagCompound.putBoolean("isActive", isActive);
|
||||
tagCompound.putInt("activeCounter", activeCounter);
|
||||
tagCompound.putString("key", "".equals(key) ? "empty" : key);
|
||||
tagCompound.putBoolean("doDropIngredients", doDropIngredients);
|
||||
tagCompound.putInt(Constants.NBT.DIRECTION, rotation.getHorizontalIndex());
|
||||
|
||||
CompoundNBT arrayTag = new CompoundNBT();
|
||||
if (arrayEffect != null) {
|
||||
arrayEffect.writeToNBT(arrayTag);
|
||||
}
|
||||
tagCompound.setTag("arrayTag", arrayTag);
|
||||
tagCompound.putTag("arrayTag", arrayTag);
|
||||
|
||||
return tagCompound;
|
||||
}
|
||||
|
|
|
@ -73,11 +73,11 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
|
|||
super.deserialize(tag);
|
||||
|
||||
isSlave = tag.getBoolean("isSlave");
|
||||
direction = Direction.byIndex(tag.getInteger(Constants.NBT.DIRECTION));
|
||||
connectedPos = new BlockPos(tag.getInteger(Constants.NBT.X_COORD), tag.getInteger(Constants.NBT.Y_COORD), tag.getInteger(Constants.NBT.Z_COORD));
|
||||
direction = Direction.byIndex(tag.getInt(Constants.NBT.DIRECTION));
|
||||
connectedPos = new BlockPos(tag.getInt(Constants.NBT.X_COORD), tag.getInt(Constants.NBT.Y_COORD), tag.getInt(Constants.NBT.Z_COORD));
|
||||
|
||||
burnTime = tag.getInteger("burnTime");
|
||||
ticksRequired = tag.getInteger("ticksRequired");
|
||||
burnTime = tag.getInt("burnTime");
|
||||
ticksRequired = tag.getInt("ticksRequired");
|
||||
|
||||
byte[] array = tag.getByteArray("blockedSlots");
|
||||
for (int i = 0; i < array.length; i++)
|
||||
|
@ -88,20 +88,20 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
|
|||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setBoolean("isSlave", isSlave);
|
||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
tag.setInteger(Constants.NBT.X_COORD, connectedPos.getX());
|
||||
tag.setInteger(Constants.NBT.Y_COORD, connectedPos.getY());
|
||||
tag.setInteger(Constants.NBT.Z_COORD, connectedPos.getZ());
|
||||
tag.putBoolean("isSlave", isSlave);
|
||||
tag.putInt(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
tag.putInt(Constants.NBT.X_COORD, connectedPos.getX());
|
||||
tag.putInt(Constants.NBT.Y_COORD, connectedPos.getY());
|
||||
tag.putInt(Constants.NBT.Z_COORD, connectedPos.getZ());
|
||||
|
||||
tag.setInteger("burnTime", burnTime);
|
||||
tag.setInteger("ticksRequired", ticksRequired);
|
||||
tag.putInt("burnTime", burnTime);
|
||||
tag.putInt("ticksRequired", ticksRequired);
|
||||
|
||||
byte[] blockedSlotArray = new byte[blockedSlots.length];
|
||||
for (int i = 0; i < blockedSlots.length; i++)
|
||||
blockedSlotArray[i] = (byte) (blockedSlots[i] ? 1 : 0);
|
||||
|
||||
tag.setByteArray("blockedSlots", blockedSlotArray);
|
||||
tag.putByteArray("blockedSlots", blockedSlotArray);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable {
|
|||
CompoundNBT altarTag = new CompoundNBT();
|
||||
this.bloodAltar.writeToNBT(altarTag);
|
||||
|
||||
tagCompound.setTag("bloodAltar", altarTag);
|
||||
tagCompound.putTag("bloodAltar", altarTag);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TileBloodTank extends TileBase {
|
|||
public void deserialize(CompoundNBT tagCompound) {
|
||||
super.deserialize(tagCompound);
|
||||
tank.readFromNBT(tagCompound.getCompoundTag(Constants.NBT.TANK));
|
||||
capacity = tagCompound.getInteger(Constants.NBT.ALTAR_CAPACITY);
|
||||
capacity = tagCompound.getInt(Constants.NBT.ALTAR_CAPACITY);
|
||||
tank.setCapacity(capacity);
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ public class TileBloodTank extends TileBase {
|
|||
public CompoundNBT serialize(CompoundNBT tagCompound) {
|
||||
super.serialize(tagCompound);
|
||||
if (tank.getFluidAmount() != 0)
|
||||
tagCompound.setTag(Constants.NBT.TANK, tank.writeToNBT(new CompoundNBT()));
|
||||
tagCompound.setInteger(Constants.NBT.ALTAR_CAPACITY, capacity);
|
||||
tagCompound.putTag(Constants.NBT.TANK, tank.writeToNBT(new CompoundNBT()));
|
||||
tagCompound.putInt(Constants.NBT.ALTAR_CAPACITY, capacity);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
|
|||
super.serialize(tag);
|
||||
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet()) {
|
||||
tag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
||||
tag.putDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
|
|
@ -147,17 +147,17 @@ public class TileDemonCrystal extends TileTicking {
|
|||
@Override
|
||||
public void deserialize(CompoundNBT tag) {
|
||||
holder.readFromNBT(tag, "Will");
|
||||
crystalCount = tag.getInteger("crystalCount");
|
||||
placement = Direction.byIndex(tag.getInteger("placement"));
|
||||
crystalCount = tag.getInt("crystalCount");
|
||||
placement = Direction.byIndex(tag.getInt("placement"));
|
||||
progressToNextCrystal = tag.getDouble("progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.setInteger("crystalCount", crystalCount);
|
||||
tag.setInteger("placement", placement.getIndex());
|
||||
tag.setDouble("progress", progressToNextCrystal);
|
||||
tag.putInt("crystalCount", crystalCount);
|
||||
tag.putInt("placement", placement.getIndex());
|
||||
tag.putDouble("progress", progressToNextCrystal);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.setDouble("internalCounter", internalCounter);
|
||||
tag.putDouble("internalCounter", internalCounter);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,17 +15,17 @@ public class TileDimensionalPortal extends TileBase {
|
|||
public void deserialize(CompoundNBT tagCompound) {
|
||||
portalID = tagCompound.getString(RitualPortal.PORTAL_ID_TAG);
|
||||
|
||||
masterStoneX = tagCompound.getInteger("masterStoneX");
|
||||
masterStoneY = tagCompound.getInteger("masterStoneY");
|
||||
masterStoneZ = tagCompound.getInteger("masterStoneZ");
|
||||
masterStoneX = tagCompound.getInt("masterStoneX");
|
||||
masterStoneY = tagCompound.getInt("masterStoneY");
|
||||
masterStoneZ = tagCompound.getInt("masterStoneZ");
|
||||
}
|
||||
|
||||
public CompoundNBT serialize(CompoundNBT tagCompound) {
|
||||
tagCompound.setString(RitualPortal.PORTAL_ID_TAG, Strings.isNullOrEmpty(portalID) ? "" : portalID);
|
||||
tagCompound.putString(RitualPortal.PORTAL_ID_TAG, Strings.isNullOrEmpty(portalID) ? "" : portalID);
|
||||
|
||||
tagCompound.setInteger("masterStoneX", masterStoneX);
|
||||
tagCompound.setInteger("masterStoneY", masterStoneY);
|
||||
tagCompound.setInteger("masterStoneZ", masterStoneZ);
|
||||
tagCompound.putInt("masterStoneX", masterStoneX);
|
||||
tagCompound.putInt("masterStoneY", masterStoneY);
|
||||
tagCompound.putInt("masterStoneZ", masterStoneZ);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ public class TileIncenseAltar extends TileInventory implements ITickable {
|
|||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
tag.setDouble("tranquility", tranquility);
|
||||
tag.setDouble("incenseAddition", incenseAddition);
|
||||
tag.putDouble("tranquility", tranquility);
|
||||
tag.putDouble("incenseAddition", incenseAddition);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TileInventory extends TileBase implements IInventory {
|
|||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
if (!isSyncedSlot(i)) {
|
||||
CompoundNBT data = tags.getCompoundTagAt(i);
|
||||
CompoundNBT data = tags.getCompound(i);
|
||||
byte j = data.getByte("Slot");
|
||||
|
||||
if (j >= 0 && j < inventory.size()) {
|
||||
|
@ -81,7 +81,7 @@ public class TileInventory extends TileBase implements IInventory {
|
|||
}
|
||||
}
|
||||
|
||||
tagCompound.setTag("Items", tags);
|
||||
tagCompound.putTag("Items", tags);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -203,8 +203,8 @@ public class TileInversionPillar extends TileTicking {
|
|||
|
||||
type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
currentInversion = tag.getDouble("currentInversion");
|
||||
currentInfectionRadius = tag.getInteger("currentInfectionRadius");
|
||||
consecutiveFailedChecks = tag.getInteger("consecutiveFailedChecks");
|
||||
currentInfectionRadius = tag.getInt("currentInfectionRadius");
|
||||
consecutiveFailedChecks = tag.getInt("consecutiveFailedChecks");
|
||||
|
||||
animationOffsetValue = tag.getFloat("animationOffset");
|
||||
animationOffset.setValue(animationOffsetValue);
|
||||
|
@ -214,11 +214,11 @@ public class TileInversionPillar extends TileTicking {
|
|||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
tag.setDouble("currentInversion", currentInversion);
|
||||
tag.setInteger("currentInfectionRadius", currentInfectionRadius);
|
||||
tag.setInteger("consecutiveFailedChecks", consecutiveFailedChecks);
|
||||
tag.setFloat("animationOffset", animationOffsetValue);
|
||||
tag.putString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
tag.putDouble("currentInversion", currentInversion);
|
||||
tag.putInt("currentInfectionRadius", currentInfectionRadius);
|
||||
tag.putInt("consecutiveFailedChecks", consecutiveFailedChecks);
|
||||
tag.putFloat("animationOffset", animationOffsetValue);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
|
|
@ -79,14 +79,14 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS
|
|||
cachedNetwork = NetworkHelper.getSoulNetwork(owner);
|
||||
currentRitual = BloodMagic.RITUAL_MANAGER.getRitual(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||
if (currentRitual != null) {
|
||||
CompoundNBT ritualTag = tag.getCompoundTag(Constants.NBT.CURRENT_RITUAL_TAG);
|
||||
CompoundNBT ritualTag = tag.getCompound(Constants.NBT.CURRENT_RITUAL_TAG);
|
||||
if (!ritualTag.isEmpty()) {
|
||||
currentRitual.readFromNBT(ritualTag);
|
||||
}
|
||||
}
|
||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
||||
direction = Direction.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
||||
activeTime = tag.getInt(Constants.NBT.RUNTIME);
|
||||
direction = Direction.VALUES[tag.getInt(Constants.NBT.DIRECTION)];
|
||||
redstoned = tag.getBoolean(Constants.NBT.IS_REDSTONED);
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
|
@ -100,20 +100,20 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS
|
|||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
String ritualId = BloodMagic.RITUAL_MANAGER.getId(getCurrentRitual());
|
||||
if (owner != null)
|
||||
tag.setUniqueId("owner", owner);
|
||||
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
tag.putUniqueId("owner", owner);
|
||||
tag.putString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
if (currentRitual != null) {
|
||||
CompoundNBT ritualTag = new CompoundNBT();
|
||||
currentRitual.writeToNBT(ritualTag);
|
||||
tag.setTag(Constants.NBT.CURRENT_RITUAL_TAG, ritualTag);
|
||||
tag.put(Constants.NBT.CURRENT_RITUAL_TAG, ritualTag);
|
||||
}
|
||||
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
tag.setBoolean(Constants.NBT.IS_REDSTONED, redstoned);
|
||||
tag.putBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.putInt(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.putInt(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
tag.putBoolean(Constants.NBT.IS_REDSTONED, redstoned);
|
||||
|
||||
for (EnumDemonWillType type : currentActiveWillConfig) {
|
||||
tag.setBoolean("EnumWill" + type, true);
|
||||
tag.putBoolean("EnumWill" + type, true);
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
|
|
@ -256,24 +256,24 @@ public class TileMimic extends TileInventory implements ITickable {
|
|||
super.deserialize(tag);
|
||||
|
||||
dropItemsOnBreak = tag.getBoolean("dropItemsOnBreak");
|
||||
tileTag = tag.getCompoundTag("tileTag");
|
||||
tileTag = tag.getCompound("tileTag");
|
||||
stateOfReplacedBlock = StateUtil.parseState(tag.getString("stateOfReplacedBlock"));
|
||||
mimicedTile = getTileFromStackWithTag(getWorld(), pos, getStackInSlot(0), tileTag, stateOfReplacedBlock);
|
||||
playerCheckRadius = tag.getInteger("playerCheckRadius");
|
||||
potionSpawnRadius = tag.getInteger("potionSpawnRadius");
|
||||
potionSpawnInterval = Math.max(1, tag.getInteger("potionSpawnInterval"));
|
||||
playerCheckRadius = tag.getInt("playerCheckRadius");
|
||||
potionSpawnRadius = tag.getInt("potionSpawnRadius");
|
||||
potionSpawnInterval = Math.max(1, tag.getInt("potionSpawnInterval"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setBoolean("dropItemsOnBreak", dropItemsOnBreak);
|
||||
tag.setTag("tileTag", tileTag);
|
||||
tag.setInteger("playerCheckRadius", playerCheckRadius);
|
||||
tag.setInteger("potionSpawnRadius", potionSpawnRadius);
|
||||
tag.setInteger("potionSpawnInterval", potionSpawnInterval);
|
||||
tag.setString("stateOfReplacedBlock", stateOfReplacedBlock.toString());
|
||||
tag.putBoolean("dropItemsOnBreak", dropItemsOnBreak);
|
||||
tag.put("tileTag", tileTag);
|
||||
tag.putInt("playerCheckRadius", playerCheckRadius);
|
||||
tag.putInt("potionSpawnRadius", potionSpawnRadius);
|
||||
tag.putInt("potionSpawnInterval", potionSpawnInterval);
|
||||
tag.putString("stateOfReplacedBlock", stateOfReplacedBlock.toString());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
@ -320,9 +320,9 @@ public class TileMimic extends TileInventory implements ITickable {
|
|||
if (world.setBlockState(pos, state, 3)) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
tileTag.setInteger("x", pos.getX());
|
||||
tileTag.setInteger("y", pos.getY());
|
||||
tileTag.setInteger("z", pos.getZ());
|
||||
tileTag.putInt("x", pos.getX());
|
||||
tileTag.putInt("y", pos.getY());
|
||||
tileTag.putInt("z", pos.getZ());
|
||||
tile.readFromNBT(tileTag);
|
||||
}
|
||||
|
||||
|
@ -346,9 +346,9 @@ public class TileMimic extends TileInventory implements ITickable {
|
|||
|
||||
if (tag != null) {
|
||||
CompoundNBT copyTag = tag.copy();
|
||||
copyTag.setInteger("x", pos.getX());
|
||||
copyTag.setInteger("y", pos.getY());
|
||||
copyTag.setInteger("z", pos.getZ());
|
||||
copyTag.putInt("x", pos.getX());
|
||||
copyTag.putInt("y", pos.getY());
|
||||
copyTag.putInt("z", pos.getZ());
|
||||
tile.readFromNBT(copyTag);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ public class TilePhantomBlock extends TileTicking {
|
|||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tagCompound) {
|
||||
this.ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
this.ticksRemaining = tagCompound.getInt(Constants.NBT.TICKS_REMAINING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tagCompound) {
|
||||
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
tagCompound.putInt(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ public class TilePurificationAltar extends TileInventory implements ITickable {
|
|||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setDouble("totalPurity", totalPurity);
|
||||
tag.setDouble("maxPurity", maxPurity);
|
||||
tag.setDouble("purityRate", purityRate);
|
||||
tag.putDouble("totalPurity", totalPurity);
|
||||
tag.putDouble("maxPurity", maxPurity);
|
||||
tag.putDouble("purityRate", purityRate);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
|
|
@ -37,14 +37,14 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
|||
public void deserialize(CompoundNBT tag) {
|
||||
super.deserialize(tag);
|
||||
|
||||
burnTime = tag.getInteger(Constants.NBT.SOUL_FORGE_BURN);
|
||||
burnTime = tag.getInt(Constants.NBT.SOUL_FORGE_BURN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setInteger(Constants.NBT.SOUL_FORGE_BURN, burnTime);
|
||||
tag.putInt(Constants.NBT.SOUL_FORGE_BURN, burnTime);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,16 +22,16 @@ public class TileSpectralBlock extends TileTicking {
|
|||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tagCompound) {
|
||||
ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
ticksRemaining = tagCompound.getInt(Constants.NBT.TICKS_REMAINING);
|
||||
containedBlockName = tagCompound.getString(Constants.NBT.CONTAINED_BLOCK_NAME);
|
||||
containedBlockMeta = tagCompound.getInteger(Constants.NBT.CONTAINED_BLOCK_META);
|
||||
containedBlockMeta = tagCompound.getInt(Constants.NBT.CONTAINED_BLOCK_META);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tagCompound) {
|
||||
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
tagCompound.setString(Constants.NBT.CONTAINED_BLOCK_NAME, Strings.isNullOrEmpty(containedBlockName) ? "" : containedBlockName);
|
||||
tagCompound.setInteger(Constants.NBT.CONTAINED_BLOCK_META, containedBlockMeta);
|
||||
tagCompound.putInt(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
tagCompound.putString(Constants.NBT.CONTAINED_BLOCK_NAME, Strings.isNullOrEmpty(containedBlockName) ? "" : containedBlockName);
|
||||
tagCompound.putInt(Constants.NBT.CONTAINED_BLOCK_META, containedBlockMeta);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ public class TileTeleposer extends TileInventory implements ITickable {
|
|||
@Override
|
||||
public void deserialize(CompoundNBT tagCompound) {
|
||||
super.deserialize(tagCompound);
|
||||
previousInput = tagCompound.getInteger(Constants.NBT.PREVIOUS_INPUT);
|
||||
previousInput = tagCompound.getInt(Constants.NBT.PREVIOUS_INPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tagCompound) {
|
||||
super.serialize(tagCompound);
|
||||
tagCompound.setInteger(Constants.NBT.PREVIOUS_INPUT, previousInput);
|
||||
tagCompound.putInt(Constants.NBT.PREVIOUS_INPUT, previousInput);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,22 +16,23 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
* Handles data syncing and core data writing/reading.
|
||||
*/
|
||||
public class TileBase extends TileEntity {
|
||||
|
||||
@Override
|
||||
public final void readFromNBT(CompoundNBT compound) {
|
||||
super.readFromNBT(compound);
|
||||
deserializeBase(compound);
|
||||
deserialize(compound);
|
||||
public final void deserializeNBT(CompoundNBT nbt) {
|
||||
super.deserializeNBT(nbt);
|
||||
deserializeBase(nbt);
|
||||
deserialize(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompoundNBT writeToNBT(CompoundNBT compound) {
|
||||
super.writeToNBT(compound);
|
||||
serializeBase(compound);
|
||||
return serialize(compound);
|
||||
public final CompoundNBT serializeNBT() {
|
||||
CompoundNBT tag = super.serializeNBT();
|
||||
serializeBase(tag);
|
||||
return serialize(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@link #readFromNBT(CompoundNBT)}
|
||||
* Called by {@link #deserializeNBT(CompoundNBT)}
|
||||
* <p>
|
||||
* Internal data (such as coordinates) are handled for you. Just read the data you need.
|
||||
*
|
||||
|
@ -52,7 +53,7 @@ public class TileBase extends TileEntity {
|
|||
}
|
||||
|
||||
/**
|
||||
* Called by {@link #writeToNBT(CompoundNBT)}
|
||||
* Called by {@link #serializeNBT()}
|
||||
* <p>
|
||||
* Internal data (such as coordinates) are handled for you. Just read the data you need.
|
||||
*
|
||||
|
@ -89,14 +90,14 @@ public class TileBase extends TileEntity {
|
|||
|
||||
@Override
|
||||
public final SUpdateTileEntityPacket getUpdatePacket() {
|
||||
return new SUpdateTileEntityPacket(getPos(), -999, writeToNBT(new CompoundNBT()));
|
||||
return new SUpdateTileEntityPacket(getPos(), -999, serializeNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
deserialize(pkt.getNbtCompound());
|
||||
onDataPacketClientReceived();
|
||||
}
|
||||
|
||||
|
@ -109,11 +110,11 @@ public class TileBase extends TileEntity {
|
|||
|
||||
@Override
|
||||
public final CompoundNBT getUpdateTag() {
|
||||
return writeToNBT(new CompoundNBT());
|
||||
return serializeNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleUpdateTag(CompoundNBT tag) {
|
||||
readFromNBT(tag);
|
||||
deserializeNBT(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package WayofTime.bloodmagic.tile.base;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
|
||||
/**
|
||||
* Base class for tiles that tick. Allows disabling the ticking programmatically.
|
||||
*/
|
||||
// TODO - Move implementations that depend on existed ticks to new methods from here.
|
||||
public abstract class TileTicking extends TileBase implements ITickable {
|
||||
public abstract class TileTicking extends TileBase implements ITickableTileEntity {
|
||||
private int ticksExisted;
|
||||
private boolean shouldTick = true;
|
||||
|
||||
@Override
|
||||
public final void update() {
|
||||
public final void tick() {
|
||||
if (shouldTick()) {
|
||||
ticksExisted++;
|
||||
onUpdate();
|
||||
|
@ -21,14 +21,14 @@ public abstract class TileTicking extends TileBase implements ITickable {
|
|||
|
||||
@Override
|
||||
void deserializeBase(CompoundNBT tagCompound) {
|
||||
this.ticksExisted = tagCompound.getInteger("ticksExisted");
|
||||
this.ticksExisted = tagCompound.getInt("ticksExisted");
|
||||
this.shouldTick = tagCompound.getBoolean("shouldTick");
|
||||
}
|
||||
|
||||
@Override
|
||||
CompoundNBT serializeBase(CompoundNBT tagCompound) {
|
||||
tagCompound.setInteger("ticksExisted", getTicksExisted());
|
||||
tagCompound.setBoolean("shouldTick", shouldTick());
|
||||
tagCompound.putInt("ticksExisted", getTicksExisted());
|
||||
tagCompound.putBoolean("shouldTick", shouldTick());
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,18 +44,18 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
@Override
|
||||
public void deserialize(CompoundNBT tag) {
|
||||
super.deserialize(tag);
|
||||
currentActiveSlot = tag.getInteger("currentSlot");
|
||||
currentActiveSlot = tag.getInt("currentSlot");
|
||||
priorities = tag.getIntArray(Constants.NBT.ROUTING_PRIORITY);
|
||||
if (priorities.length != 6) {
|
||||
priorities = new int[6];
|
||||
}
|
||||
|
||||
if (!tag.getBoolean("updated")) {
|
||||
ListNBT tags = tag.getTagList("Items", 10);
|
||||
ListNBT tags = tag.getList("Items", 10);
|
||||
inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
if (!isSyncedSlot(i)) {
|
||||
CompoundNBT data = tags.getCompoundTagAt(i);
|
||||
CompoundNBT data = tags.getCompound(i);
|
||||
byte j = data.getByte("Slot");
|
||||
|
||||
if (j == 0) {
|
||||
|
@ -73,9 +73,9 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
tag.setInteger("currentSlot", currentActiveSlot);
|
||||
tag.setIntArray(Constants.NBT.ROUTING_PRIORITY, priorities);
|
||||
tag.setBoolean("updated", true);
|
||||
tag.putInt("currentSlot", currentActiveSlot);
|
||||
tag.putIntArray(Constants.NBT.ROUTING_PRIORITY, priorities);
|
||||
tag.putBoolean("updated", true);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,32 +191,32 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti
|
|||
ListNBT tags = new ListNBT();
|
||||
for (BlockPos pos : generalNodeList) {
|
||||
CompoundNBT posTag = new CompoundNBT();
|
||||
posTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.setInteger(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.setInteger(Constants.NBT.Z_COORD, pos.getZ());
|
||||
posTag.putInt(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.putInt(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.putInt(Constants.NBT.Z_COORD, pos.getZ());
|
||||
tags.appendTag(posTag);
|
||||
}
|
||||
tag.setTag(Constants.NBT.ROUTING_MASTER_GENERAL, tags);
|
||||
tag.put(Constants.NBT.ROUTING_MASTER_GENERAL, tags);
|
||||
|
||||
tags = new ListNBT();
|
||||
for (BlockPos pos : inputNodeList) {
|
||||
CompoundNBT posTag = new CompoundNBT();
|
||||
posTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.setInteger(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.setInteger(Constants.NBT.Z_COORD, pos.getZ());
|
||||
posTag.putInt(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.putInt(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.putInt(Constants.NBT.Z_COORD, pos.getZ());
|
||||
tags.appendTag(posTag);
|
||||
}
|
||||
tag.setTag(Constants.NBT.ROUTING_MASTER_INPUT, tags);
|
||||
tag.put(Constants.NBT.ROUTING_MASTER_INPUT, tags);
|
||||
|
||||
tags = new ListNBT();
|
||||
for (BlockPos pos : outputNodeList) {
|
||||
CompoundNBT posTag = new CompoundNBT();
|
||||
posTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.setInteger(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.setInteger(Constants.NBT.Z_COORD, pos.getZ());
|
||||
posTag.putInt(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.putInt(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.putInt(Constants.NBT.Z_COORD, pos.getZ());
|
||||
tags.appendTag(posTag);
|
||||
}
|
||||
tag.setTag(Constants.NBT.ROUTING_MASTER_OUTPUT, tags);
|
||||
tag.put(Constants.NBT.ROUTING_MASTER_OUTPUT, tags);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -224,24 +224,24 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti
|
|||
public void deserialize(CompoundNBT tag) {
|
||||
super.deserialize(tag);
|
||||
|
||||
ListNBT tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_GENERAL, 10);
|
||||
ListNBT tags = tag.getList(Constants.NBT.ROUTING_MASTER_GENERAL, 10);
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
CompoundNBT blockTag = tags.getCompoundTagAt(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD));
|
||||
CompoundNBT blockTag = tags.getCompound(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInt(Constants.NBT.X_COORD), blockTag.getInt(Constants.NBT.Y_COORD), blockTag.getInt(Constants.NBT.Z_COORD));
|
||||
generalNodeList.add(newPos);
|
||||
}
|
||||
|
||||
tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_INPUT, 10);
|
||||
tags = tag.getList(Constants.NBT.ROUTING_MASTER_INPUT, 10);
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
CompoundNBT blockTag = tags.getCompoundTagAt(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD));
|
||||
CompoundNBT blockTag = tags.getCompound(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInt(Constants.NBT.X_COORD), blockTag.getInt(Constants.NBT.Y_COORD), blockTag.getInt(Constants.NBT.Z_COORD));
|
||||
inputNodeList.add(newPos);
|
||||
}
|
||||
|
||||
tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_OUTPUT, 10);
|
||||
tags = tag.getList(Constants.NBT.ROUTING_MASTER_OUTPUT, 10);
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
CompoundNBT blockTag = tags.getCompoundTagAt(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD));
|
||||
CompoundNBT blockTag = tags.getCompound(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInt(Constants.NBT.X_COORD), blockTag.getInt(Constants.NBT.Y_COORD), blockTag.getInt(Constants.NBT.Z_COORD));
|
||||
outputNodeList.add(newPos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,20 +39,20 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte
|
|||
public CompoundNBT serialize(CompoundNBT tag) {
|
||||
super.serialize(tag);
|
||||
CompoundNBT masterTag = new CompoundNBT();
|
||||
masterTag.setInteger(Constants.NBT.X_COORD, masterPos.getX());
|
||||
masterTag.setInteger(Constants.NBT.Y_COORD, masterPos.getY());
|
||||
masterTag.setInteger(Constants.NBT.Z_COORD, masterPos.getZ());
|
||||
tag.setTag(Constants.NBT.ROUTING_MASTER, masterTag);
|
||||
masterTag.putInt(Constants.NBT.X_COORD, masterPos.getX());
|
||||
masterTag.putInt(Constants.NBT.Y_COORD, masterPos.getY());
|
||||
masterTag.putInt(Constants.NBT.Z_COORD, masterPos.getZ());
|
||||
tag.put(Constants.NBT.ROUTING_MASTER, masterTag);
|
||||
|
||||
ListNBT tags = new ListNBT();
|
||||
for (BlockPos pos : connectionList) {
|
||||
CompoundNBT posTag = new CompoundNBT();
|
||||
posTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.setInteger(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.setInteger(Constants.NBT.Z_COORD, pos.getZ());
|
||||
tags.appendTag(posTag);
|
||||
posTag.putInt(Constants.NBT.X_COORD, pos.getX());
|
||||
posTag.putInt(Constants.NBT.Y_COORD, pos.getY());
|
||||
posTag.putInt(Constants.NBT.Z_COORD, pos.getZ());
|
||||
tags.add(posTag);
|
||||
}
|
||||
tag.setTag(Constants.NBT.ROUTING_CONNECTION, tags);
|
||||
tag.put(Constants.NBT.ROUTING_CONNECTION, tags);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte
|
|||
public void deserialize(CompoundNBT tag) {
|
||||
super.deserialize(tag);
|
||||
connectionList.clear();
|
||||
CompoundNBT masterTag = tag.getCompoundTag(Constants.NBT.ROUTING_MASTER);
|
||||
masterPos = new BlockPos(masterTag.getInteger(Constants.NBT.X_COORD), masterTag.getInteger(Constants.NBT.Y_COORD), masterTag.getInteger(Constants.NBT.Z_COORD));
|
||||
CompoundNBT masterTag = tag.getCompound(Constants.NBT.ROUTING_MASTER);
|
||||
masterPos = new BlockPos(masterTag.getInt(Constants.NBT.X_COORD), masterTag.getInt(Constants.NBT.Y_COORD), masterTag.getInt(Constants.NBT.Z_COORD));
|
||||
|
||||
ListNBT tags = tag.getTagList(Constants.NBT.ROUTING_CONNECTION, 10);
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
CompoundNBT blockTag = tags.getCompoundTagAt(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD));
|
||||
ListNBT tags = tag.getList(Constants.NBT.ROUTING_CONNECTION, 10);
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
CompoundNBT blockTag = tags.getCompound(i);
|
||||
BlockPos newPos = new BlockPos(blockTag.getInt(Constants.NBT.X_COORD), blockTag.getInt(Constants.NBT.Y_COORD), blockTag.getInt(Constants.NBT.Z_COORD));
|
||||
connectionList.add(newPos);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue