Pedestals serialization
This commit is contained in:
parent
068fa540be
commit
83f4f923b1
3 changed files with 38 additions and 40 deletions
|
@ -33,15 +33,6 @@ public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||||
linkedRitual.setWorld(world);
|
linkedRitual.setWorld(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromTag(BlockState state, CompoundTag tag) {
|
|
||||||
super.fromTag(state, tag);
|
|
||||||
if (tag.contains("ritual")) {
|
|
||||||
linkedRitual = new EternalRitual(world);
|
|
||||||
linkedRitual.fromTag(tag.getCompound("ritual"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag(CompoundTag tag) {
|
public CompoundTag toTag(CompoundTag tag) {
|
||||||
|
@ -50,4 +41,13 @@ public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||||
}
|
}
|
||||||
return super.toTag(tag);
|
return super.toTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fromTag(CompoundTag tag) {
|
||||||
|
super.fromTag(tag);
|
||||||
|
if (tag.contains("ritual")) {
|
||||||
|
linkedRitual = new EternalRitual(world);
|
||||||
|
linkedRitual.fromTag(tag.getCompound("ritual"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ru.betterend.blocks.entities;
|
package ru.betterend.blocks.entities;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -42,27 +43,21 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||||
}
|
}
|
||||||
super.tick();
|
super.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag toInitialChunkDataTag() {
|
public CompoundTag toTag(CompoundTag tag) {
|
||||||
return this.toTag(new CompoundTag());
|
if (hasRitual()) {
|
||||||
|
tag.put("ritual", linkedRitual.toTag(new CompoundTag()));
|
||||||
|
}
|
||||||
|
return super.toTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(BlockState state, CompoundTag tag) {
|
protected void fromTag(CompoundTag tag) {
|
||||||
super.fromTag(state, tag);
|
super.fromTag(tag);
|
||||||
if (tag.contains("ritual")) {
|
if (tag.contains("ritual")) {
|
||||||
linkedRitual = new InfusionRitual(world, pos);
|
linkedRitual = new InfusionRitual(world, pos);
|
||||||
linkedRitual.fromTag(tag.getCompound("ritual"));
|
linkedRitual.fromTag(tag.getCompound("ritual"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag toTag(CompoundTag tag) {
|
|
||||||
super.toTag(tag);
|
|
||||||
if (hasRitual()) {
|
|
||||||
tag.put("ritual", linkedRitual.toTag(new CompoundTag()));
|
|
||||||
}
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,14 +106,30 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(BlockState state, CompoundTag tag) {
|
public void fromTag(BlockState state, CompoundTag tag) {
|
||||||
super.fromTag(state, tag);
|
super.fromTag(state, tag);
|
||||||
fromClientTag(tag);
|
fromTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag(CompoundTag tag) {
|
public CompoundTag toTag(CompoundTag tag) {
|
||||||
super.toTag(tag);
|
|
||||||
tag.put("active_item", activeItem.toTag(new CompoundTag()));
|
tag.put("active_item", activeItem.toTag(new CompoundTag()));
|
||||||
return tag;
|
return super.toTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromClientTag(CompoundTag tag) {
|
||||||
|
fromTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag toClientTag(CompoundTag tag) {
|
||||||
|
return toTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fromTag(CompoundTag tag) {
|
||||||
|
if (tag.contains("active_item")) {
|
||||||
|
CompoundTag itemTag = tag.getCompound("active_item");
|
||||||
|
activeItem = ItemStack.fromTag(itemTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,17 +141,4 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromClientTag(CompoundTag tag) {
|
|
||||||
if (tag.contains("active_item")) {
|
|
||||||
CompoundTag itemTag = tag.getCompound("active_item");
|
|
||||||
activeItem = ItemStack.fromTag(itemTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag toClientTag(CompoundTag tag) {
|
|
||||||
return toTag(tag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue