Migrate mappings, 1888 errors to go

This commit is contained in:
modmuss50 2021-05-28 14:58:12 +01:00
parent b0c7a733c7
commit 9520a3e607
83 changed files with 407 additions and 408 deletions

View file

@ -28,8 +28,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.util.collection.DefaultedList;
public abstract class InventoryBase implements Inventory {
@ -42,15 +42,15 @@ public abstract class InventoryBase implements Inventory {
stacks = DefaultedList.ofSize(size, ItemStack.EMPTY);
}
public Tag serializeNBT() {
CompoundTag tag = new CompoundTag();
Inventories.toTag(tag, stacks);
public NbtElement serializeNBT() {
NbtCompound tag = new NbtCompound();
Inventories.writeNbt(tag, stacks);
return tag;
}
public void deserializeNBT(CompoundTag tag) {
public void deserializeNBT(NbtCompound tag) {
stacks = DefaultedList.ofSize(size, ItemStack.EMPTY);
Inventories.fromTag(tag, stacks);
Inventories.readNbt(tag, stacks);
}
@Override

View file

@ -35,9 +35,9 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import reborncore.common.RebornCoreConfig;
import reborncore.common.util.CalenderUtils;
@ -74,8 +74,8 @@ public class HolidayRenderManager {
float yaw = player.prevYaw + (player.yaw - player.prevYaw) * tickDelta - (player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw) * tickDelta);
float pitch = player.prevPitch + (player.pitch - player.prevPitch) * tickDelta;
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(pitch));
matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(yaw));
matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(pitch));
santaHat.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(player, 0.0F), 1F, 1F, 1F, 1F);
matrixStack.pop();
}

View file

@ -34,7 +34,7 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
@ -109,9 +109,9 @@ public class StackToolTipHandler implements ItemTooltipCallback {
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world);
boolean hasData = false;
if (itemStack.hasTag() && itemStack.getOrCreateTag().contains("blockEntity_data")) {
CompoundTag blockEntityData = itemStack.getOrCreateTag().getCompound("blockEntity_data");
NbtCompound blockEntityData = itemStack.getOrCreateTag().getCompound("blockEntity_data");
if (blockEntity != null) {
blockEntity.fromTag(block.getDefaultState(), blockEntityData);
blockEntity.readNbt(block.getDefaultState(), blockEntityData);
hasData = true;
tooltipLines.add(new LiteralText(I18n.translate("reborncore.tooltip.has_data")).formatted(Formatting.DARK_GREEN));
}

View file

@ -69,7 +69,7 @@ public class GuiButtonCustomTexture extends ButtonWidget {
if (this.visible) {
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
&& mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(WIDGETS_LOCATION);
mc.getTextureManager().bindTexture(WIDGETS_TEXTURE);
int u = textureU;
int v = textureV;

View file

@ -59,7 +59,7 @@ public class GuiButtonItemTexture extends ButtonWidget {
MinecraftClient mc = MinecraftClient.getInstance();
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
&& mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(WIDGETS_LOCATION);
mc.getTextureManager().bindTexture(WIDGETS_TEXTURE);
int u = textureU;
int v = textureV;
if (flag) {

View file

@ -31,7 +31,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
@ -277,7 +277,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
offset += 24;
}
for (AbstractButtonWidget abstractButtonWidget : buttons) {
for (ClickableWidget abstractButtonWidget : buttons) {
if (abstractButtonWidget.isHovered()) {
abstractButtonWidget.renderToolTip(matrixStack, mouseX, mouseY);
break;

View file

@ -35,11 +35,11 @@ import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.network.Packet;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.World;
import reborncore.RebornCore;
import reborncore.client.gui.GuiUtil;
@ -76,12 +76,12 @@ public class FluidConfigPopupElement extends ElementBase {
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState());
MinecraftClient.getInstance().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, Vector3f.POSITIVE_Y.getDegreesQuaternion(90F)); //left
drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, Vector3f.NEGATIVE_X.getDegreesQuaternion(90F)); //top
drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //left
drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, Vec3f.NEGATIVE_X.getDegreesQuaternion(90F)); //top
drawState(gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre
drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, Vector3f.POSITIVE_X.getDegreesQuaternion(90F)); //bottom
drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vector3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right
drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vector3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, Vec3f.POSITIVE_X.getDegreesQuaternion(90F)); //bottom
drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right
drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui);
drawSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui);

View file

@ -35,11 +35,11 @@ import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.network.Packet;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.World;
import reborncore.RebornCore;
import reborncore.client.gui.GuiUtil;
@ -80,12 +80,12 @@ public class SlotConfigPopupElement extends ElementBase {
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState());
MinecraftClient.getInstance().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, Vector3f.POSITIVE_Y.getDegreesQuaternion(90F)); //left
drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, Vector3f.NEGATIVE_X.getDegreesQuaternion(90F)); //top
drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //left
drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, Vec3f.NEGATIVE_X.getDegreesQuaternion(90F)); //top
drawState(gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre
drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, Vector3f.POSITIVE_X.getDegreesQuaternion(90F)); //bottom
drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vector3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right
drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vector3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, Vec3f.POSITIVE_X.getDegreesQuaternion(90F)); //bottom
drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right
drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);

View file

@ -48,7 +48,7 @@ public class GuiHiddenButton extends ButtonWidget {
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
TextRenderer fontrenderer = MinecraftClient.getInstance().textRenderer;
MinecraftClient.getInstance().getTextureManager().bindTexture(WIDGETS_LOCATION);
MinecraftClient.getInstance().getTextureManager().bindTexture(WIDGETS_TEXTURE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y
&& mouseX < this.x + this.width && mouseY < this.y + this.height;

View file

@ -31,9 +31,9 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.tuple.Pair;
import reborncore.RebornCore;
@ -155,11 +155,11 @@ public class BlockEntityScreenHandlerBuilder {
public <T> BlockEntityScreenHandlerBuilder sync(Codec<T> codec) {
return sync(() -> {
DataResult<Tag> dataResult = codec.encodeStart(NbtOps.INSTANCE, (T) blockEntity);
DataResult<NbtElement> dataResult = codec.encodeStart(NbtOps.INSTANCE, (T) blockEntity);
if (dataResult.error().isPresent()) {
throw new RuntimeException("Failed to encode: " + dataResult.error().get().message() + " " + blockEntity);
} else {
return (CompoundTag) dataResult.result().get();
return (NbtCompound) dataResult.result().get();
}
}, compoundTag -> {
DataResult<T> dataResult = codec.parse(NbtOps.INSTANCE, compoundTag);

View file

@ -258,7 +258,7 @@ public class BuiltScreenHandler extends ScreenHandler implements ExtendedScreenH
}
}
slot.onStackChanged(stackInSlot, originalStack);
slot.onQuickTransfer(stackInSlot, originalStack);
if (stackInSlot.getCount() <= 0) {
slot.setStack(ItemStack.EMPTY);
} else {

View file

@ -30,7 +30,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -48,10 +48,10 @@ public abstract class BaseBlockEntityProvider extends Block implements BlockEnti
return Optional.empty();
}
ItemStack newStack = stack.copy();
CompoundTag blockEntityData = blockEntity.toTag(new CompoundTag());
NbtCompound blockEntityData = blockEntity.writeNbt(new NbtCompound());
stripLocationData(blockEntityData);
if (!newStack.hasTag()) {
newStack.setTag(new CompoundTag());
newStack.setTag(new NbtCompound());
}
newStack.getTag().put("blockEntity_data", blockEntityData);
return Optional.of(newStack);
@ -61,20 +61,20 @@ public abstract class BaseBlockEntityProvider extends Block implements BlockEnti
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
if (stack.hasTag() && stack.getTag().contains("blockEntity_data")) {
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
CompoundTag nbt = stack.getTag().getCompound("blockEntity_data");
NbtCompound nbt = stack.getTag().getCompound("blockEntity_data");
injectLocationData(nbt, pos);
blockEntity.fromTag(state, nbt);
blockEntity.readNbt(state, nbt);
blockEntity.markDirty();
}
}
private void stripLocationData(CompoundTag compound) {
private void stripLocationData(NbtCompound compound) {
compound.remove("x");
compound.remove("y");
compound.remove("z");
}
private void injectLocationData(CompoundTag compound, BlockPos pos) {
private void injectLocationData(NbtCompound compound, BlockPos pos) {
compound.putInt("x", pos.getX());
compound.putInt("y", pos.getY());
compound.putInt("z", pos.getZ());

View file

@ -25,7 +25,7 @@
package reborncore.common.blockentity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import reborncore.common.fluid.FluidUtil;
@ -48,7 +48,7 @@ public class FluidConfiguration implements NBTSerializable {
Arrays.stream(Direction.values()).forEach(facing -> sideMap.put(facing, new FluidConfig(facing)));
}
public FluidConfiguration(CompoundTag tagCompound) {
public FluidConfiguration(NbtCompound tagCompound) {
sideMap = new HashMap<>();
read(tagCompound);
}
@ -119,8 +119,8 @@ public class FluidConfiguration implements NBTSerializable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag compound = new CompoundTag();
public NbtCompound write() {
NbtCompound compound = new NbtCompound();
Arrays.stream(Direction.values()).forEach(facing -> compound.put("side_" + facing.ordinal(), sideMap.get(facing).write()));
compound.putBoolean("input", input);
compound.putBoolean("output", output);
@ -128,10 +128,10 @@ public class FluidConfiguration implements NBTSerializable {
}
@Override
public void read(@NotNull CompoundTag nbt) {
public void read(@NotNull NbtCompound nbt) {
sideMap.clear();
Arrays.stream(Direction.values()).forEach(facing -> {
CompoundTag compound = nbt.getCompound("side_" + facing.ordinal());
NbtCompound compound = nbt.getCompound("side_" + facing.ordinal());
FluidConfig config = new FluidConfig(compound);
sideMap.put(facing, config);
});
@ -153,7 +153,7 @@ public class FluidConfiguration implements NBTSerializable {
this.ioConfig = ioConfig;
}
public FluidConfig(CompoundTag tagCompound) {
public FluidConfig(NbtCompound tagCompound) {
read(tagCompound);
}
@ -167,15 +167,15 @@ public class FluidConfiguration implements NBTSerializable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag tagCompound = new CompoundTag();
public NbtCompound write() {
NbtCompound tagCompound = new NbtCompound();
tagCompound.putInt("side", side.ordinal());
tagCompound.putInt("config", ioConfig.ordinal());
return tagCompound;
}
@Override
public void read(@NotNull CompoundTag nbt) {
public void read(@NotNull NbtCompound nbt) {
side = Direction.values()[nbt.getInt("side")];
ioConfig = FluidConfiguration.ExtractConfig.values()[nbt.getInt("config")];
}

View file

@ -34,7 +34,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.LiteralText;
@ -129,13 +129,13 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
@Nullable
@Override
public BlockEntityUpdateS2CPacket toUpdatePacket() {
return new BlockEntityUpdateS2CPacket(getPos(), 0, toInitialChunkDataTag());
return new BlockEntityUpdateS2CPacket(getPos(), 0, toInitialChunkDataNbt());
}
@Override
public CompoundTag toInitialChunkDataTag() {
CompoundTag compound = super.toTag(new CompoundTag());
toTag(compound);
public NbtCompound toInitialChunkDataNbt() {
NbtCompound compound = super.writeNbt(new NbtCompound());
writeNbt(compound);
return compound;
}
@ -232,8 +232,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
}
@Override
public void fromTag(BlockState blockState, CompoundTag tagCompound) {
super.fromTag(blockState, tagCompound);
public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
if (getOptionalInventory().isPresent()) {
getOptionalInventory().get().read(tagCompound);
}
@ -258,8 +258,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
}
@Override
public CompoundTag toTag(CompoundTag tagCompound) {
super.toTag(tagCompound);
public NbtCompound writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound);
if (getOptionalInventory().isPresent()) {
getOptionalInventory().get().write(tagCompound);
}

View file

@ -27,7 +27,7 @@ package reborncore.common.blockentity;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.tuple.Pair;
@ -147,8 +147,8 @@ public class RedstoneConfiguration implements NBTSerializable, Syncable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag tag = new CompoundTag();
public NbtCompound write() {
NbtCompound tag = new NbtCompound();
for (Element element : getElements()) {
tag.putInt(element.getName(), getState(element).ordinal());
}
@ -156,7 +156,7 @@ public class RedstoneConfiguration implements NBTSerializable, Syncable {
}
@Override
public void read(@NotNull CompoundTag tag) {
public void read(@NotNull NbtCompound tag) {
stateMap = new HashMap<>();
for (String key : tag.getKeys()) {
Element element = ELEMENT_MAP.get(key);
@ -178,7 +178,7 @@ public class RedstoneConfiguration implements NBTSerializable, Syncable {
@Override
public void getSyncPair(List<Pair<Supplier, Consumer>> pairList) {
pairList.add(Pair.of(this::write, (Consumer<CompoundTag>) this::read));
pairList.add(Pair.of(this::write, (Consumer<NbtCompound>) this::read));
}
public static Element getElementByName(String name) {

View file

@ -31,7 +31,7 @@ import it.unimi.dsi.fastutil.ints.IntLists;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringNbtReader;
import net.minecraft.util.math.Direction;
import org.apache.commons.lang3.Validate;
@ -80,7 +80,7 @@ public class SlotConfiguration implements NBTSerializable {
}
}
public SlotConfiguration(CompoundTag tagCompound) {
public SlotConfiguration(NbtCompound tagCompound) {
read(tagCompound);
}
@ -119,8 +119,8 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag tagCompound = new CompoundTag();
public NbtCompound write() {
NbtCompound tagCompound = new NbtCompound();
tagCompound.putInt("size", slotDetails.size());
for (int i = 0; i < slotDetails.size(); i++) {
tagCompound.put("slot_" + i, slotDetails.get(i).write());
@ -129,10 +129,10 @@ public class SlotConfiguration implements NBTSerializable {
}
@Override
public void read(@NotNull CompoundTag nbt) {
public void read(@NotNull NbtCompound nbt) {
int size = nbt.getInt("size");
for (int i = 0; i < size; i++) {
CompoundTag tagCompound = nbt.getCompound("slot_" + i);
NbtCompound tagCompound = nbt.getCompound("slot_" + i);
SlotConfigHolder slotConfigHolder = new SlotConfigHolder(tagCompound);
updateSlotDetails(slotConfigHolder);
}
@ -150,7 +150,7 @@ public class SlotConfiguration implements NBTSerializable {
Arrays.stream(Direction.values()).forEach(facing -> sideMap.put(facing, new SlotConfig(facing, slotID)));
}
public SlotConfigHolder(CompoundTag tagCompound) {
public SlotConfigHolder(NbtCompound tagCompound) {
sideMap = new HashMap<>();
read(tagCompound);
Validate.isTrue(Arrays.stream(Direction.values())
@ -218,8 +218,8 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag compound = new CompoundTag();
public NbtCompound write() {
NbtCompound compound = new NbtCompound();
compound.putInt("slotID", slotID);
Arrays.stream(Direction.values()).forEach(facing -> compound.put("side_" + facing.ordinal(), sideMap.get(facing).write()));
compound.putBoolean("input", input);
@ -229,11 +229,11 @@ public class SlotConfiguration implements NBTSerializable {
}
@Override
public void read(@NotNull CompoundTag nbt) {
public void read(@NotNull NbtCompound nbt) {
sideMap.clear();
slotID = nbt.getInt("slotID");
Arrays.stream(Direction.values()).forEach(facing -> {
CompoundTag compound = nbt.getCompound("side_" + facing.ordinal());
NbtCompound compound = nbt.getCompound("side_" + facing.ordinal());
SlotConfig config = new SlotConfig(compound);
sideMap.put(facing, config);
});
@ -264,7 +264,7 @@ public class SlotConfiguration implements NBTSerializable {
this.slotID = slotID;
}
public SlotConfig(CompoundTag tagCompound) {
public SlotConfig(NbtCompound tagCompound) {
read(tagCompound);
Validate.notNull(side, "error when loading slot config");
Validate.notNull(slotIO, "error when loading slot config");
@ -358,8 +358,8 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag tagCompound = new CompoundTag();
public NbtCompound write() {
NbtCompound tagCompound = new NbtCompound();
tagCompound.putInt("side", side.ordinal());
tagCompound.put("config", slotIO.write());
tagCompound.putInt("slot", slotID);
@ -367,7 +367,7 @@ public class SlotConfiguration implements NBTSerializable {
}
@Override
public void read(@NotNull CompoundTag nbt) {
public void read(@NotNull NbtCompound nbt) {
side = Direction.values()[nbt.getInt("side")];
slotIO = new SlotIO(nbt.getCompound("config"));
slotID = nbt.getInt("slot");
@ -377,7 +377,7 @@ public class SlotConfiguration implements NBTSerializable {
public static class SlotIO implements NBTSerializable {
ExtractConfig ioConfig;
public SlotIO(CompoundTag tagCompound) {
public SlotIO(NbtCompound tagCompound) {
read(tagCompound);
}
@ -391,14 +391,14 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull
@Override
public CompoundTag write() {
CompoundTag compound = new CompoundTag();
public NbtCompound write() {
NbtCompound compound = new NbtCompound();
compound.putInt("config", ioConfig.ordinal());
return compound;
}
@Override
public void read(@NotNull CompoundTag nbt) {
public void read(@NotNull NbtCompound nbt) {
ioConfig = ExtractConfig.values()[nbt.getInt("config")];
}
}
@ -434,14 +434,14 @@ public class SlotConfiguration implements NBTSerializable {
}
public String toJson(String machineIdent) {
CompoundTag tagCompound = new CompoundTag();
NbtCompound tagCompound = new NbtCompound();
tagCompound.put("data", write());
tagCompound.putString("machine", machineIdent);
return tagCompound.toString();
}
public void readJson(String json, String machineIdent) throws UnsupportedOperationException {
CompoundTag compound;
NbtCompound compound;
try {
compound = StringNbtReader.parse(json);
} catch (CommandSyntaxException e) {

View file

@ -26,7 +26,7 @@ package reborncore.common.chunkloading;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ChunkTicketType;
@ -68,7 +68,7 @@ public class ChunkLoaderManager extends PersistentState {
private final List<LoadedChunk> loadedChunks = new ArrayList<>();
@Override
public void fromTag(CompoundTag tag) {
public void fromNbt(NbtCompound tag) {
loadedChunks.clear();
List<LoadedChunk> chunks = CODEC.parse(NbtOps.INSTANCE, tag.getCompound("loadedchunks"))
@ -79,7 +79,7 @@ public class ChunkLoaderManager extends PersistentState {
}
@Override
public CompoundTag toTag(CompoundTag compoundTag) {
public NbtCompound writeNbt(NbtCompound compoundTag) {
CODEC.encodeStart(NbtOps.INSTANCE, loadedChunks)
.result()
.ifPresent(tag -> compoundTag.put("loadedchunks", tag));

View file

@ -158,7 +158,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
// use the RebornIngredient version to ensure stack sizes are checked
@Deprecated
@Override
public DefaultedList<Ingredient> getPreviewInputs() {
public DefaultedList<Ingredient> getIngredients() {
return ingredients.stream().map(RebornIngredient::getPreview).collect(DefaultedListCollector.toList());
}
@ -231,7 +231,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
}
@Override
public DefaultedList<ItemStack> getRemainingStacks(Inventory p_179532_1_) {
public DefaultedList<ItemStack> getRemainder(Inventory p_179532_1_) {
throw new UnsupportedOperationException();
}

View file

@ -31,7 +31,7 @@ import com.mojang.serialization.JsonOps;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
@ -73,7 +73,7 @@ public class RecipeUtils {
}
ItemStack stack = new ItemStack(item, count);
if (jsonObject.has("nbt")) {
CompoundTag tag = (CompoundTag) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonObject.get("nbt"));
NbtCompound tag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonObject.get("nbt"));
stack.setTag(tag);
}
return stack;

View file

@ -31,7 +31,7 @@ import com.mojang.serialization.Dynamic;
import com.mojang.serialization.JsonOps;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps;
import net.minecraft.recipe.Ingredient;
import net.minecraft.util.Identifier;
@ -49,10 +49,10 @@ public class StackIngredient extends RebornIngredient {
private final List<ItemStack> stacks;
private final Optional<Integer> count;
private final Optional<CompoundTag> tag;
private final Optional<NbtCompound> tag;
private final boolean requireEmptyTag;
public StackIngredient(List<ItemStack> stacks, Optional<Integer> count, Optional<CompoundTag> tag, boolean requireEmptyTag) {
public StackIngredient(List<ItemStack> stacks, Optional<Integer> count, Optional<NbtCompound> tag, boolean requireEmptyTag) {
super(IngredientManager.STACK_RECIPE_TYPE);
this.stacks = stacks;
this.count = count;
@ -73,7 +73,7 @@ public class StackIngredient extends RebornIngredient {
stackSize = Optional.of(JsonHelper.getInt(json, "count"));
}
Optional<CompoundTag> tag = Optional.empty();
Optional<NbtCompound> tag = Optional.empty();
boolean requireEmptyTag = false;
if (json.has("nbt")) {
@ -82,7 +82,7 @@ public class StackIngredient extends RebornIngredient {
requireEmptyTag = true;
}
} else {
tag = Optional.of((CompoundTag) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, json.get("nbt")));
tag = Optional.of((NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, json.get("nbt")));
}
}
@ -109,9 +109,9 @@ public class StackIngredient extends RebornIngredient {
//Bit of a meme here, as DataFixer likes to use the most basic primative type over using an int.
//So we have to go to json and back on the incoming stack to be sure its using types that match our input.
CompoundTag compoundTag = itemStack.getTag();
NbtCompound compoundTag = itemStack.getTag();
JsonElement jsonElement = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, compoundTag);
compoundTag = (CompoundTag) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonElement);
compoundTag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonElement);
if (!tag.get().equals(compoundTag)) {
return false;

View file

@ -124,7 +124,7 @@ public abstract class RebornFluid extends FlowableFluid {
@Override
protected BlockState toBlockState(FluidState fluidState) {
return fluidBlockSupplier.get().getDefaultState().with(FluidBlock.LEVEL, method_15741(fluidState));
return fluidBlockSupplier.get().getDefaultState().with(FluidBlock.LEVEL, getBlockStateLevel(fluidState));
}
@Override

View file

@ -80,7 +80,7 @@ public class RebornFluidRenderManager implements ClientSpriteRegistryCallback, S
}
@Override
public void apply(ResourceManager manager) {
public void reload(ResourceManager manager) {
//Reset the cached fluid sprites
spriteMap.forEach((key, value) -> value.reset());
}

View file

@ -26,7 +26,7 @@ package reborncore.common.fluid.container;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import reborncore.common.fluid.FluidValue;
@ -41,7 +41,7 @@ public class FluidInstance implements NBTSerializable {
protected Fluid fluid;
protected FluidValue amount;
protected CompoundTag tag;
protected NbtCompound tag;
public FluidInstance(Fluid fluid, FluidValue amount) {
this.fluid = fluid;
@ -56,7 +56,7 @@ public class FluidInstance implements NBTSerializable {
this(Fluids.EMPTY);
}
public FluidInstance(CompoundTag tag) {
public FluidInstance(NbtCompound tag) {
this();
read(tag);
}
@ -69,7 +69,7 @@ public class FluidInstance implements NBTSerializable {
return amount;
}
public CompoundTag getTag() {
public NbtCompound getTag() {
return tag;
}
@ -93,7 +93,7 @@ public class FluidInstance implements NBTSerializable {
return this;
}
public void setTag(CompoundTag tag) {
public void setTag(NbtCompound tag) {
this.tag = tag;
}
@ -110,8 +110,8 @@ public class FluidInstance implements NBTSerializable {
}
@Override
public CompoundTag write() {
CompoundTag tag = new CompoundTag();
public NbtCompound write() {
NbtCompound tag = new NbtCompound();
tag.putString(FLUID_KEY, Registry.FLUID.getId(fluid).toString());
tag.putInt(AMOUNT_KEY, amount.getRawValue());
if (this.tag != null && !this.tag.isEmpty()) {
@ -121,7 +121,7 @@ public class FluidInstance implements NBTSerializable {
}
@Override
public void read(CompoundTag tag) {
public void read(NbtCompound tag) {
fluid = Registry.FLUID.get(new Identifier(tag.getString(FLUID_KEY)));
amount = FluidValue.fromRaw(tag.getInt(AMOUNT_KEY));
if (tag.contains(TAG_KEY)) {

View file

@ -27,7 +27,7 @@ package reborncore.common.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import java.util.Set;
@ -246,7 +246,7 @@ public abstract class IMultiblockPart extends BlockEntity {
* @return The part's saved multiblock game-data in NBT format, or null if
* there isn't any.
*/
public abstract CompoundTag getMultiblockSaveData();
public abstract NbtCompound getMultiblockSaveData();
/**
* Called after a block is added and the controller has incorporated the

View file

@ -27,8 +27,8 @@ package reborncore.common.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -50,7 +50,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
private boolean visited;
private boolean saveMultiblockData;
private CompoundTag cachedMultiblockData;
private NbtCompound cachedMultiblockData;
//private boolean paused;
public MultiblockBlockEntityBase(BlockEntityType<?> tBlockEntityType) {
@ -112,8 +112,8 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
// /// Overrides from base BlockEntity methods
@Override
public void fromTag(BlockState blockState, CompoundTag data) {
super.fromTag(blockState, data);
public void readNbt(BlockState blockState, NbtCompound data) {
super.readNbt(blockState, data);
// We can't directly initialize a multiblock controller yet, so we cache
// the data here until
@ -125,11 +125,11 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
}
@Override
public CompoundTag toTag(CompoundTag data) {
super.toTag(data);
public NbtCompound writeNbt(NbtCompound data) {
super.writeNbt(data);
if (isMultiblockSaveDelegate() && isConnected()) {
CompoundTag multiblockData = new CompoundTag();
NbtCompound multiblockData = new NbtCompound();
this.controller.write(multiblockData);
data.put("multiblockData", multiblockData);
}
@ -173,7 +173,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
// Network Communication
@Override
public BlockEntityUpdateS2CPacket toUpdatePacket() {
CompoundTag packetData = new CompoundTag();
NbtCompound packetData = new NbtCompound();
encodeDescriptionPacket(packetData);
return new BlockEntityUpdateS2CPacket(getPos(), 0, packetData);
}
@ -188,9 +188,9 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
* @param packetData An NBT compound tag into which you should write your custom
* description data.
*/
protected void encodeDescriptionPacket(CompoundTag packetData) {
protected void encodeDescriptionPacket(NbtCompound packetData) {
if (this.isMultiblockSaveDelegate() && isConnected()) {
CompoundTag tag = new CompoundTag();
NbtCompound tag = new NbtCompound();
getMultiblockController().formatDescriptionPacket(tag);
packetData.put("multiblockData", tag);
}
@ -202,9 +202,9 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
*
* @param packetData The NBT data from the blockEntity entity's description packet.
*/
protected void decodeDescriptionPacket(CompoundTag packetData) {
protected void decodeDescriptionPacket(NbtCompound packetData) {
if (packetData.contains("multiblockData")) {
CompoundTag tag = packetData.getCompound("multiblockData");
NbtCompound tag = packetData.getCompound("multiblockData");
if (isConnected()) {
getMultiblockController().decodeDescriptionPacket(tag);
} else {
@ -220,7 +220,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
}
@Override
public CompoundTag getMultiblockSaveData() {
public NbtCompound getMultiblockSaveData() {
return this.cachedMultiblockData;
}

View file

@ -25,7 +25,7 @@
package reborncore.common.multiblock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
@ -128,7 +128,7 @@ public abstract class MultiblockControllerBase {
* @param part Attached part
* @param data The NBT tag containing this controller's data.
*/
public abstract void onAttachedPartWithMultiblockData(IMultiblockPart part, CompoundTag data);
public abstract void onAttachedPartWithMultiblockData(IMultiblockPart part, NbtCompound data);
/**
* Check if a block is being tracked by this machine.
@ -160,7 +160,7 @@ public abstract class MultiblockControllerBase {
this.onBlockAdded(part);
if (part.hasMultiblockSaveData()) {
CompoundTag savedData = part.getMultiblockSaveData();
NbtCompound savedData = part.getMultiblockSaveData();
onAttachedPartWithMultiblockData(part, savedData);
part.onMultiblockDataAssimilated();
}
@ -679,9 +679,9 @@ public abstract class MultiblockControllerBase {
return connectedParts.size();
}
public abstract void write(CompoundTag data);
public abstract void write(NbtCompound data);
public abstract void read(CompoundTag data);
public abstract void read(NbtCompound data);
/**
* Force this multiblock to recalculate its minimum and maximum coordinates
@ -746,7 +746,7 @@ public abstract class MultiblockControllerBase {
*
* @param data A fresh compound tag to write your multiblock data into
*/
public abstract void formatDescriptionPacket(CompoundTag data);
public abstract void formatDescriptionPacket(NbtCompound data);
/**
* Called when the save delegate's blockEntity entity receiving a description
@ -754,7 +754,7 @@ public abstract class MultiblockControllerBase {
*
* @param data A compound tag containing multiblock data to import
*/
public abstract void decodeDescriptionPacket(CompoundTag data);
public abstract void decodeDescriptionPacket(NbtCompound data);
/**
* @return True if this controller has no associated blocks, false otherwise

View file

@ -30,7 +30,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
@ -51,13 +51,13 @@ public class ClientBoundPacketHandlers {
public static void init() {
NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "custom_description"), (client, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos();
CompoundTag tagCompound = packetBuffer.readCompoundTag();
NbtCompound tagCompound = packetBuffer.readNbt();
client.execute(() -> {
World world = MinecraftClient.getInstance().world;
if (world.isChunkLoaded(pos)) {
BlockEntity blockentity = world.getBlockEntity(pos);
if (blockentity != null && tagCompound != null) {
blockentity.fromTag(blockentity.getCachedState(), tagCompound);
blockentity.readNbt(blockentity.getCachedState(), tagCompound);
}
}
});
@ -65,7 +65,7 @@ public class ClientBoundPacketHandlers {
NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "fluid_config_sync"), (client, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag();
NbtCompound compoundTag = packetBuffer.readNbt();
client.execute(() -> {
FluidConfiguration fluidConfiguration = new FluidConfiguration(compoundTag);
@ -86,7 +86,7 @@ public class ClientBoundPacketHandlers {
NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "slot_sync"), (client, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag();
NbtCompound compoundTag = packetBuffer.readNbt();
client.execute(() -> {
SlotConfiguration slotConfig = new SlotConfiguration(compoundTag);

View file

@ -25,7 +25,7 @@
package reborncore.common.network;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
@ -38,27 +38,27 @@ import java.util.List;
public class ClientBoundPackets {
public static IdentifiedPacket createCustomDescriptionPacket(BlockEntity blockEntity) {
return createCustomDescriptionPacket(blockEntity.getPos(), blockEntity.toTag(new CompoundTag()));
return createCustomDescriptionPacket(blockEntity.getPos(), blockEntity.writeNbt(new NbtCompound()));
}
public static IdentifiedPacket createCustomDescriptionPacket(BlockPos blockPos, CompoundTag nbt) {
public static IdentifiedPacket createCustomDescriptionPacket(BlockPos blockPos, NbtCompound nbt) {
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "custom_description"), packetBuffer -> {
packetBuffer.writeBlockPos(blockPos);
packetBuffer.writeCompoundTag(nbt);
packetBuffer.writeNbt(nbt);
});
}
public static IdentifiedPacket createPacketFluidConfigSync(BlockPos pos, FluidConfiguration fluidConfiguration) {
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "fluid_config_sync"), packetBuffer -> {
packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(fluidConfiguration.write());
packetBuffer.writeNbt(fluidConfiguration.write());
});
}
public static IdentifiedPacket createPacketSlotSync(BlockPos pos, SlotConfiguration slotConfig) {
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "slot_sync"), packetBuffer -> {
packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(slotConfig.write());
packetBuffer.writeNbt(slotConfig.write());
});
}

View file

@ -27,10 +27,10 @@ package reborncore.common.network;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.network.PacketByteBuf;
import java.io.ByteArrayInputStream;
@ -74,19 +74,19 @@ public class ExtendedPacketBuffer extends PacketByteBuf {
// Supports reading and writing list codec's
public <T> void writeCodec(Codec<T> codec, T object) {
DataResult<Tag> dataResult = codec.encodeStart(NbtOps.INSTANCE, object);
DataResult<NbtElement> dataResult = codec.encodeStart(NbtOps.INSTANCE, object);
if (dataResult.error().isPresent()) {
throw new RuntimeException("Failed to encode: " + dataResult.error().get().message() + " " + object);
} else {
Tag tag = dataResult.result().get();
if (tag instanceof CompoundTag) {
NbtElement tag = dataResult.result().get();
if (tag instanceof NbtCompound) {
writeByte(0);
writeCompoundTag((CompoundTag) tag);
} else if (tag instanceof ListTag) {
writeNbt((NbtCompound) tag);
} else if (tag instanceof NbtList) {
writeByte(1);
CompoundTag compoundTag = new CompoundTag();
NbtCompound compoundTag = new NbtCompound();
compoundTag.put("tag", tag);
writeCompoundTag(compoundTag);
writeNbt(compoundTag);
} else {
throw new RuntimeException("Failed to write: " + tag);
}
@ -95,12 +95,12 @@ public class ExtendedPacketBuffer extends PacketByteBuf {
public <T> T readCodec(Codec<T> codec) {
byte type = readByte();
Tag tag = null;
NbtElement tag = null;
if (type == 0) {
tag = readCompoundTag();
tag = readNbt();
} else if (type == 1) {
tag = readCompoundTag().get("tag");
tag = readNbt().get("tag");
} else {
throw new RuntimeException("Failed to read codec");
}

View file

@ -24,7 +24,7 @@
package reborncore.common.network;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
@ -77,9 +77,9 @@ public enum ObjectBufferUtils {
return FluidValue.fromRaw(buffer.readInt());
}),
COMPOUND_TAG(CompoundTag.class, (value, buffer) -> {
buffer.writeCompoundTag(value);
}, PacketByteBuf::readCompoundTag),
COMPOUND_TAG(NbtCompound.class, (value, buffer) -> {
buffer.writeNbt(value);
}, PacketByteBuf::readNbt),
BIG_INT(BigInteger.class, (pos, buffer) -> {
buffer.writeBigInt(pos);

View file

@ -25,7 +25,7 @@
package reborncore.common.network;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
@ -43,7 +43,7 @@ public class ServerBoundPackets {
public static void init() {
NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "fluid_config_save"), (server, player, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag();
NbtCompound compoundTag = packetBuffer.readNbt();
server.execute(() -> {
FluidConfiguration.FluidConfig fluidConfiguration = new FluidConfiguration.FluidConfig(compoundTag);
@ -63,7 +63,7 @@ public class ServerBoundPackets {
NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "config_save"), (server, player, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos();
CompoundTag tagCompound = packetBuffer.readCompoundTag();
NbtCompound tagCompound = packetBuffer.readNbt();
server.execute(() -> {
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos);
@ -122,7 +122,7 @@ public class ServerBoundPackets {
NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "slot_save"), (server, player, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag();
NbtCompound compoundTag = packetBuffer.readNbt();
server.execute(() -> {
SlotConfiguration.SlotConfig slotConfig = new SlotConfiguration.SlotConfig(compoundTag);
@ -168,14 +168,14 @@ public class ServerBoundPackets {
public static IdentifiedPacket createPacketFluidConfigSave(BlockPos pos, FluidConfiguration.FluidConfig fluidConfiguration) {
return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "fluid_config_save"), packetBuffer -> {
packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(fluidConfiguration.write());
packetBuffer.writeNbt(fluidConfiguration.write());
});
}
public static IdentifiedPacket createPacketConfigSave(BlockPos pos, SlotConfiguration slotConfig) {
return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "config_save"), packetBuffer -> {
packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(slotConfig.write());
packetBuffer.writeNbt(slotConfig.write());
});
}
@ -200,7 +200,7 @@ public class ServerBoundPackets {
public static IdentifiedPacket createPacketSlotSave(BlockPos pos, SlotConfiguration.SlotConfig slotConfig) {
return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "slot_save"), packetBuffer -> {
packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(slotConfig.write());
packetBuffer.writeNbt(slotConfig.write());
});
}

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
@ -330,18 +330,18 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
}
@Override
public void fromTag(BlockState blockState, CompoundTag tag) {
super.fromTag(blockState, tag);
CompoundTag data = tag.getCompound("PowerAcceptor");
public void readNbt(BlockState blockState, NbtCompound tag) {
super.readNbt(blockState, tag);
NbtCompound data = tag.getCompound("PowerAcceptor");
if (shouldHandleEnergyNBT()) {
this.setStored(data.getDouble("energy"));
}
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
CompoundTag data = new CompoundTag();
public NbtCompound writeNbt(NbtCompound tag) {
super.writeNbt(tag);
NbtCompound data = new NbtCompound();
data.putDouble("energy", getStored(EnergySide.UNKNOWN));
tag.put("PowerAcceptor", data);
return tag;

View file

@ -27,7 +27,7 @@ package reborncore.common.recipes;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import reborncore.RebornCore;
import reborncore.api.recipe.IRecipeCrafterProvider;
@ -291,8 +291,8 @@ public class RecipeCrafter implements IUpgradeHandler {
}
}
public void read(CompoundTag tag) {
CompoundTag data = tag.getCompound("Crater");
public void read(NbtCompound tag) {
NbtCompound data = tag.getCompound("Crater");
if (data.contains("currentTickTime")) {
currentTickTime = data.getInt("currentTickTime");
@ -305,9 +305,9 @@ public class RecipeCrafter implements IUpgradeHandler {
}
}
public void write(CompoundTag tag) {
public void write(NbtCompound tag) {
CompoundTag data = new CompoundTag();
NbtCompound data = new NbtCompound();
data.putDouble("currentTickTime", currentTickTime);

View file

@ -25,7 +25,7 @@
package reborncore.common.util;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import org.apache.commons.lang3.Validate;
import reborncore.api.items.InventoryBase;
@ -58,30 +58,30 @@ public class InventoryItem extends InventoryBase {
return stack;
}
public CompoundTag getInvData() {
public NbtCompound getInvData() {
Validate.isTrue(!stack.isEmpty());
if (!stack.hasTag()) {
stack.setTag(new CompoundTag());
stack.setTag(new NbtCompound());
}
if (!stack.getTag().contains("inventory")) {
stack.getTag().put("inventory", new CompoundTag());
stack.getTag().put("inventory", new NbtCompound());
}
return stack.getTag().getCompound("inventory");
}
public CompoundTag getSlotData(int slot) {
public NbtCompound getSlotData(int slot) {
validateSlotIndex(slot);
CompoundTag invData = getInvData();
NbtCompound invData = getInvData();
if (!invData.contains("slot_" + slot)) {
invData.put("slot_" + slot, new CompoundTag());
invData.put("slot_" + slot, new NbtCompound());
}
return invData.getCompound("slot_" + slot);
}
public void setSlotData(int slot, CompoundTag tagCompound) {
public void setSlotData(int slot, NbtCompound tagCompound) {
validateSlotIndex(slot);
Validate.notNull(tagCompound);
CompoundTag invData = getInvData();
NbtCompound invData = getInvData();
invData.put("slot_" + slot, tagCompound);
}
@ -98,14 +98,14 @@ public class InventoryItem extends InventoryBase {
@NotNull
@Override
public ItemStack getStack(int slot) {
return ItemStack.fromTag(getSlotData(slot));
return ItemStack.fromNbt(getSlotData(slot));
}
@Override
public void setStack(int slot,
@NotNull
ItemStack stack) {
setSlotData(slot, stack.toTag(new CompoundTag()));
setSlotData(slot, stack.writeNbt(new NbtCompound()));
}
public int getSlotLimit(int slot) {

View file

@ -25,8 +25,8 @@
package reborncore.common.util;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
public class ItemNBTHelper {
@ -43,7 +43,7 @@ public class ItemNBTHelper {
**/
public static void initNBT(ItemStack stack) {
if (!detectNBT(stack)) {
injectNBT(stack, new CompoundTag());
injectNBT(stack, new NbtCompound());
}
}
@ -51,7 +51,7 @@ public class ItemNBTHelper {
* Injects an NBT Tag Compound to an ItemStack, no checks are made
* previously
**/
public static void injectNBT(ItemStack stack, CompoundTag nbt) {
public static void injectNBT(ItemStack stack, NbtCompound nbt) {
stack.setTag(nbt);
}
@ -59,7 +59,7 @@ public class ItemNBTHelper {
* Gets the NBTTagCompound in an ItemStack. Tries to init it previously in
* case there isn't one present
**/
public static CompoundTag getNBT(ItemStack stack) {
public static NbtCompound getNBT(ItemStack stack) {
initNBT(stack);
return stack.getTag();
}
@ -95,7 +95,7 @@ public class ItemNBTHelper {
getNBT(stack).putDouble(tag, d);
}
public static void setCompound(ItemStack stack, String tag, CompoundTag cmp) {
public static void setCompound(ItemStack stack, String tag, NbtCompound cmp) {
if (!tag.equalsIgnoreCase("ench")) // not override the enchantments
{
getNBT(stack).put(tag, cmp);
@ -106,7 +106,7 @@ public class ItemNBTHelper {
getNBT(stack).putString(tag, s);
}
public static void setList(ItemStack stack, String tag, ListTag list) {
public static void setList(ItemStack stack, String tag, NbtList list) {
getNBT(stack).put(tag, list);
}
@ -149,17 +149,17 @@ public class ItemNBTHelper {
* If nullifyOnFail is true it'll return null if it doesn't find any
* compounds, otherwise it'll return a new one.
**/
public static CompoundTag getCompound(ItemStack stack, String tag, boolean nullifyOnFail) {
public static NbtCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) {
return verifyExistance(stack, tag) ? getNBT(stack).getCompound(tag)
: nullifyOnFail ? null : new CompoundTag();
: nullifyOnFail ? null : new NbtCompound();
}
public static String getString(ItemStack stack, String tag, String defaultExpected) {
return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected;
}
public static ListTag getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) {
public static NbtList getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) {
return verifyExistance(stack, tag) ? getNBT(stack).getList(tag, objtype)
: nullifyOnFail ? null : new ListTag();
: nullifyOnFail ? null : new NbtList();
}
}

View file

@ -26,7 +26,7 @@ package reborncore.common.util;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
@ -88,18 +88,18 @@ public class ItemUtils {
return false;
}
public static void writeItemToNBT(ItemStack stack, CompoundTag data) {
public static void writeItemToNBT(ItemStack stack, NbtCompound data) {
if (stack.isEmpty() || stack.getCount() <= 0) {
return;
}
if (stack.getCount() > 127) {
stack.setCount(127);
}
stack.toTag(data);
stack.writeNbt(data);
}
public static ItemStack readItemFromNBT(CompoundTag data) {
return ItemStack.fromTag(data);
public static ItemStack readItemFromNBT(NbtCompound data) {
return ItemStack.fromNbt(data);
}
public static double getPowerForDurabilityBar(ItemStack stack) {

View file

@ -24,15 +24,14 @@
package reborncore.common.util;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.NotNull;
public interface NBTSerializable {
@NotNull
CompoundTag write();
NbtCompound write();
void read(@NotNull CompoundTag tag);
void read(@NotNull NbtCompound tag);
}

View file

@ -26,7 +26,7 @@ package reborncore.common.util;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.Direction;
import reborncore.api.items.InventoryBase;
import reborncore.common.blockentity.MachineBaseBlockEntity;
@ -105,21 +105,21 @@ public class RebornInventory<T extends MachineBaseBlockEntity> extends Inventory
//return externalInventory.withFacing(facing);
}
public void read(CompoundTag data) {
public void read(NbtCompound data) {
read(data, "Items");
}
public void read(CompoundTag data, String tag) {
CompoundTag nbttaglist = data.getCompound(tag);
public void read(NbtCompound data, String tag) {
NbtCompound nbttaglist = data.getCompound(tag);
deserializeNBT(nbttaglist);
hasChanged = true;
}
public void write(CompoundTag data) {
public void write(NbtCompound data) {
write(data, "Items");
}
public void write(CompoundTag data, String tag) {
public void write(NbtCompound data, String tag) {
data.put(tag, serializeNBT());
}

View file

@ -26,7 +26,7 @@ package reborncore.common.util;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
@ -93,8 +93,8 @@ public class Tank implements GenericFluidContainer<Direction>, Syncable {
return !getFluidInstance().isEmpty() && getFluidInstance().getAmount().equalOrMoreThan(getCapacity());
}
public final CompoundTag write(CompoundTag nbt) {
CompoundTag tankData = fluidInstance.write();
public final NbtCompound write(NbtCompound nbt) {
NbtCompound tankData = fluidInstance.write();
nbt.put(name, tankData);
return nbt;
}
@ -105,12 +105,12 @@ public class Tank implements GenericFluidContainer<Direction>, Syncable {
}
}
public final Tank read(CompoundTag nbt) {
public final Tank read(NbtCompound nbt) {
if (nbt.contains(name)) {
// allow to read empty tanks
setFluid(Fluids.EMPTY);
CompoundTag tankData = nbt.getCompound(name);
NbtCompound tankData = nbt.getCompound(name);
fluidInstance = new FluidInstance(tankData);
}
return this;

View file

@ -27,7 +27,7 @@ package reborncore.common.util.serialization;
import com.google.gson.*;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringNbtReader;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@ -50,7 +50,7 @@ public class ItemStackSerializer implements JsonSerializer<ItemStack>, JsonDeser
String name = null;
int stackSize = 1;
CompoundTag tagCompound = null;
NbtCompound tagCompound = null;
if (jsonObject.has(NAME) && jsonObject.get(NAME).isJsonPrimitive()) {
name = jsonObject.getAsJsonPrimitive(NAME).getAsString();