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.Inventories;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.collection.DefaultedList;
public abstract class InventoryBase implements Inventory { public abstract class InventoryBase implements Inventory {
@ -42,15 +42,15 @@ public abstract class InventoryBase implements Inventory {
stacks = DefaultedList.ofSize(size, ItemStack.EMPTY); stacks = DefaultedList.ofSize(size, ItemStack.EMPTY);
} }
public Tag serializeNBT() { public NbtElement serializeNBT() {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
Inventories.toTag(tag, stacks); Inventories.writeNbt(tag, stacks);
return tag; return tag;
} }
public void deserializeNBT(CompoundTag tag) { public void deserializeNBT(NbtCompound tag) {
stacks = DefaultedList.ofSize(size, ItemStack.EMPTY); stacks = DefaultedList.ofSize(size, ItemStack.EMPTY);
Inventories.fromTag(tag, stacks); Inventories.readNbt(tag, stacks);
} }
@Override @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.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
import reborncore.common.util.CalenderUtils; 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 yaw = player.prevYaw + (player.yaw - player.prevYaw) * tickDelta - (player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw) * tickDelta);
float pitch = player.prevPitch + (player.pitch - player.prevPitch) * tickDelta; float pitch = player.prevPitch + (player.pitch - player.prevPitch) * tickDelta;
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw)); matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(yaw));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(pitch)); matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(pitch));
santaHat.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(player, 0.0F), 1F, 1F, 1F, 1F); santaHat.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(player, 0.0F), 1F, 1F, 1F, 1F);
matrixStack.pop(); matrixStack.pop();
} }

View file

@ -34,7 +34,7 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText; import net.minecraft.text.MutableText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -109,9 +109,9 @@ public class StackToolTipHandler implements ItemTooltipCallback {
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world); BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world);
boolean hasData = false; boolean hasData = false;
if (itemStack.hasTag() && itemStack.getOrCreateTag().contains("blockEntity_data")) { 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) { if (blockEntity != null) {
blockEntity.fromTag(block.getDefaultState(), blockEntityData); blockEntity.readNbt(block.getDefaultState(), blockEntityData);
hasData = true; hasData = true;
tooltipLines.add(new LiteralText(I18n.translate("reborncore.tooltip.has_data")).formatted(Formatting.DARK_GREEN)); 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) { if (this.visible) {
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
&& mouseY < this.y + this.height; && mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(WIDGETS_LOCATION); mc.getTextureManager().bindTexture(WIDGETS_TEXTURE);
int u = textureU; int u = textureU;
int v = textureV; int v = textureV;

View file

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

View file

@ -31,7 +31,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ingame.HandledScreen; 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.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -277,7 +277,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
offset += 24; offset += 24;
} }
for (AbstractButtonWidget abstractButtonWidget : buttons) { for (ClickableWidget abstractButtonWidget : buttons) {
if (abstractButtonWidget.isHovered()) { if (abstractButtonWidget.isHovered()) {
abstractButtonWidget.renderToolTip(matrixStack, mouseX, mouseY); abstractButtonWidget.renderToolTip(matrixStack, mouseX, mouseY);
break; 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.render.model.BakedModel;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.RebornCore; import reborncore.RebornCore;
import reborncore.client.gui.GuiUtil; import reborncore.client.gui.GuiUtil;
@ -76,12 +76,12 @@ public class FluidConfigPopupElement extends ElementBase {
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState());
MinecraftClient.getInstance().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE); 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, 4, 23, Vec3f.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, 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, 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, 23, 26, Vec3f.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, 42, 23, Vec3f.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, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui); drawSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui);
drawSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, 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.render.model.BakedModel;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.RebornCore; import reborncore.RebornCore;
import reborncore.client.gui.GuiUtil; import reborncore.client.gui.GuiUtil;
@ -80,12 +80,12 @@ public class SlotConfigPopupElement extends ElementBase {
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState());
MinecraftClient.getInstance().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE); 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, 4, 23, Vec3f.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, 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, 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, 23, 26, Vec3f.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, 42, 23, Vec3f.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, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui); drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, 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) { public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
if (this.visible) { if (this.visible) {
TextRenderer fontrenderer = MinecraftClient.getInstance().textRenderer; 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); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y this.hovered = mouseX >= this.x && mouseY >= this.y
&& mouseX < this.x + this.width && mouseY < this.y + this.height; && 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.CraftingInventory;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; 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.NbtOps;
import net.minecraft.nbt.Tag;
import org.apache.commons.lang3.Range; import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import reborncore.RebornCore; import reborncore.RebornCore;
@ -155,11 +155,11 @@ public class BlockEntityScreenHandlerBuilder {
public <T> BlockEntityScreenHandlerBuilder sync(Codec<T> codec) { public <T> BlockEntityScreenHandlerBuilder sync(Codec<T> codec) {
return sync(() -> { return sync(() -> {
DataResult<Tag> dataResult = codec.encodeStart(NbtOps.INSTANCE, (T) blockEntity); DataResult<NbtElement> dataResult = codec.encodeStart(NbtOps.INSTANCE, (T) blockEntity);
if (dataResult.error().isPresent()) { if (dataResult.error().isPresent()) {
throw new RuntimeException("Failed to encode: " + dataResult.error().get().message() + " " + blockEntity); throw new RuntimeException("Failed to encode: " + dataResult.error().get().message() + " " + blockEntity);
} else { } else {
return (CompoundTag) dataResult.result().get(); return (NbtCompound) dataResult.result().get();
} }
}, compoundTag -> { }, compoundTag -> {
DataResult<T> dataResult = codec.parse(NbtOps.INSTANCE, 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) { if (stackInSlot.getCount() <= 0) {
slot.setStack(ItemStack.EMPTY); slot.setStack(ItemStack.EMPTY);
} else { } else {

View file

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

View file

@ -25,7 +25,7 @@
package reborncore.common.blockentity; package reborncore.common.blockentity;
import net.minecraft.block.entity.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.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import reborncore.common.fluid.FluidUtil; 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))); Arrays.stream(Direction.values()).forEach(facing -> sideMap.put(facing, new FluidConfig(facing)));
} }
public FluidConfiguration(CompoundTag tagCompound) { public FluidConfiguration(NbtCompound tagCompound) {
sideMap = new HashMap<>(); sideMap = new HashMap<>();
read(tagCompound); read(tagCompound);
} }
@ -119,8 +119,8 @@ public class FluidConfiguration implements NBTSerializable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag compound = new CompoundTag(); NbtCompound compound = new NbtCompound();
Arrays.stream(Direction.values()).forEach(facing -> compound.put("side_" + facing.ordinal(), sideMap.get(facing).write())); Arrays.stream(Direction.values()).forEach(facing -> compound.put("side_" + facing.ordinal(), sideMap.get(facing).write()));
compound.putBoolean("input", input); compound.putBoolean("input", input);
compound.putBoolean("output", output); compound.putBoolean("output", output);
@ -128,10 +128,10 @@ public class FluidConfiguration implements NBTSerializable {
} }
@Override @Override
public void read(@NotNull CompoundTag nbt) { public void read(@NotNull NbtCompound nbt) {
sideMap.clear(); sideMap.clear();
Arrays.stream(Direction.values()).forEach(facing -> { 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); FluidConfig config = new FluidConfig(compound);
sideMap.put(facing, config); sideMap.put(facing, config);
}); });
@ -153,7 +153,7 @@ public class FluidConfiguration implements NBTSerializable {
this.ioConfig = ioConfig; this.ioConfig = ioConfig;
} }
public FluidConfig(CompoundTag tagCompound) { public FluidConfig(NbtCompound tagCompound) {
read(tagCompound); read(tagCompound);
} }
@ -167,15 +167,15 @@ public class FluidConfiguration implements NBTSerializable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag tagCompound = new CompoundTag(); NbtCompound tagCompound = new NbtCompound();
tagCompound.putInt("side", side.ordinal()); tagCompound.putInt("side", side.ordinal());
tagCompound.putInt("config", ioConfig.ordinal()); tagCompound.putInt("config", ioConfig.ordinal());
return tagCompound; return tagCompound;
} }
@Override @Override
public void read(@NotNull CompoundTag nbt) { public void read(@NotNull NbtCompound nbt) {
side = Direction.values()[nbt.getInt("side")]; side = Direction.values()[nbt.getInt("side")];
ioConfig = FluidConfiguration.ExtractConfig.values()[nbt.getInt("config")]; 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.Inventory;
import net.minecraft.inventory.SidedInventory; import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack; 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.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
@ -129,13 +129,13 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
@Nullable @Nullable
@Override @Override
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
return new BlockEntityUpdateS2CPacket(getPos(), 0, toInitialChunkDataTag()); return new BlockEntityUpdateS2CPacket(getPos(), 0, toInitialChunkDataNbt());
} }
@Override @Override
public CompoundTag toInitialChunkDataTag() { public NbtCompound toInitialChunkDataNbt() {
CompoundTag compound = super.toTag(new CompoundTag()); NbtCompound compound = super.writeNbt(new NbtCompound());
toTag(compound); writeNbt(compound);
return compound; return compound;
} }
@ -232,8 +232,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tagCompound) { public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
if (getOptionalInventory().isPresent()) { if (getOptionalInventory().isPresent()) {
getOptionalInventory().get().read(tagCompound); getOptionalInventory().get().read(tagCompound);
} }
@ -258,8 +258,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
} }
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public NbtCompound writeNbt(NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
if (getOptionalInventory().isPresent()) { if (getOptionalInventory().isPresent()) {
getOptionalInventory().get().write(tagCompound); getOptionalInventory().get().write(tagCompound);
} }

View file

@ -27,7 +27,7 @@ package reborncore.common.blockentity;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; 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.StringUtils;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -147,8 +147,8 @@ public class RedstoneConfiguration implements NBTSerializable, Syncable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
for (Element element : getElements()) { for (Element element : getElements()) {
tag.putInt(element.getName(), getState(element).ordinal()); tag.putInt(element.getName(), getState(element).ordinal());
} }
@ -156,7 +156,7 @@ public class RedstoneConfiguration implements NBTSerializable, Syncable {
} }
@Override @Override
public void read(@NotNull CompoundTag tag) { public void read(@NotNull NbtCompound tag) {
stateMap = new HashMap<>(); stateMap = new HashMap<>();
for (String key : tag.getKeys()) { for (String key : tag.getKeys()) {
Element element = ELEMENT_MAP.get(key); Element element = ELEMENT_MAP.get(key);
@ -178,7 +178,7 @@ public class RedstoneConfiguration implements NBTSerializable, Syncable {
@Override @Override
public void getSyncPair(List<Pair<Supplier, Consumer>> pairList) { 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) { 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.Inventory;
import net.minecraft.inventory.SidedInventory; import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringNbtReader; import net.minecraft.nbt.StringNbtReader;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import org.apache.commons.lang3.Validate; 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); read(tagCompound);
} }
@ -119,8 +119,8 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag tagCompound = new CompoundTag(); NbtCompound tagCompound = new NbtCompound();
tagCompound.putInt("size", slotDetails.size()); tagCompound.putInt("size", slotDetails.size());
for (int i = 0; i < slotDetails.size(); i++) { for (int i = 0; i < slotDetails.size(); i++) {
tagCompound.put("slot_" + i, slotDetails.get(i).write()); tagCompound.put("slot_" + i, slotDetails.get(i).write());
@ -129,10 +129,10 @@ public class SlotConfiguration implements NBTSerializable {
} }
@Override @Override
public void read(@NotNull CompoundTag nbt) { public void read(@NotNull NbtCompound nbt) {
int size = nbt.getInt("size"); int size = nbt.getInt("size");
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
CompoundTag tagCompound = nbt.getCompound("slot_" + i); NbtCompound tagCompound = nbt.getCompound("slot_" + i);
SlotConfigHolder slotConfigHolder = new SlotConfigHolder(tagCompound); SlotConfigHolder slotConfigHolder = new SlotConfigHolder(tagCompound);
updateSlotDetails(slotConfigHolder); updateSlotDetails(slotConfigHolder);
} }
@ -150,7 +150,7 @@ public class SlotConfiguration implements NBTSerializable {
Arrays.stream(Direction.values()).forEach(facing -> sideMap.put(facing, new SlotConfig(facing, slotID))); Arrays.stream(Direction.values()).forEach(facing -> sideMap.put(facing, new SlotConfig(facing, slotID)));
} }
public SlotConfigHolder(CompoundTag tagCompound) { public SlotConfigHolder(NbtCompound tagCompound) {
sideMap = new HashMap<>(); sideMap = new HashMap<>();
read(tagCompound); read(tagCompound);
Validate.isTrue(Arrays.stream(Direction.values()) Validate.isTrue(Arrays.stream(Direction.values())
@ -218,8 +218,8 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag compound = new CompoundTag(); NbtCompound compound = new NbtCompound();
compound.putInt("slotID", slotID); compound.putInt("slotID", slotID);
Arrays.stream(Direction.values()).forEach(facing -> compound.put("side_" + facing.ordinal(), sideMap.get(facing).write())); Arrays.stream(Direction.values()).forEach(facing -> compound.put("side_" + facing.ordinal(), sideMap.get(facing).write()));
compound.putBoolean("input", input); compound.putBoolean("input", input);
@ -229,11 +229,11 @@ public class SlotConfiguration implements NBTSerializable {
} }
@Override @Override
public void read(@NotNull CompoundTag nbt) { public void read(@NotNull NbtCompound nbt) {
sideMap.clear(); sideMap.clear();
slotID = nbt.getInt("slotID"); slotID = nbt.getInt("slotID");
Arrays.stream(Direction.values()).forEach(facing -> { 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); SlotConfig config = new SlotConfig(compound);
sideMap.put(facing, config); sideMap.put(facing, config);
}); });
@ -264,7 +264,7 @@ public class SlotConfiguration implements NBTSerializable {
this.slotID = slotID; this.slotID = slotID;
} }
public SlotConfig(CompoundTag tagCompound) { public SlotConfig(NbtCompound tagCompound) {
read(tagCompound); read(tagCompound);
Validate.notNull(side, "error when loading slot config"); Validate.notNull(side, "error when loading slot config");
Validate.notNull(slotIO, "error when loading slot config"); Validate.notNull(slotIO, "error when loading slot config");
@ -358,8 +358,8 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag tagCompound = new CompoundTag(); NbtCompound tagCompound = new NbtCompound();
tagCompound.putInt("side", side.ordinal()); tagCompound.putInt("side", side.ordinal());
tagCompound.put("config", slotIO.write()); tagCompound.put("config", slotIO.write());
tagCompound.putInt("slot", slotID); tagCompound.putInt("slot", slotID);
@ -367,7 +367,7 @@ public class SlotConfiguration implements NBTSerializable {
} }
@Override @Override
public void read(@NotNull CompoundTag nbt) { public void read(@NotNull NbtCompound nbt) {
side = Direction.values()[nbt.getInt("side")]; side = Direction.values()[nbt.getInt("side")];
slotIO = new SlotIO(nbt.getCompound("config")); slotIO = new SlotIO(nbt.getCompound("config"));
slotID = nbt.getInt("slot"); slotID = nbt.getInt("slot");
@ -377,7 +377,7 @@ public class SlotConfiguration implements NBTSerializable {
public static class SlotIO implements NBTSerializable { public static class SlotIO implements NBTSerializable {
ExtractConfig ioConfig; ExtractConfig ioConfig;
public SlotIO(CompoundTag tagCompound) { public SlotIO(NbtCompound tagCompound) {
read(tagCompound); read(tagCompound);
} }
@ -391,14 +391,14 @@ public class SlotConfiguration implements NBTSerializable {
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag compound = new CompoundTag(); NbtCompound compound = new NbtCompound();
compound.putInt("config", ioConfig.ordinal()); compound.putInt("config", ioConfig.ordinal());
return compound; return compound;
} }
@Override @Override
public void read(@NotNull CompoundTag nbt) { public void read(@NotNull NbtCompound nbt) {
ioConfig = ExtractConfig.values()[nbt.getInt("config")]; ioConfig = ExtractConfig.values()[nbt.getInt("config")];
} }
} }
@ -434,14 +434,14 @@ public class SlotConfiguration implements NBTSerializable {
} }
public String toJson(String machineIdent) { public String toJson(String machineIdent) {
CompoundTag tagCompound = new CompoundTag(); NbtCompound tagCompound = new NbtCompound();
tagCompound.put("data", write()); tagCompound.put("data", write());
tagCompound.putString("machine", machineIdent); tagCompound.putString("machine", machineIdent);
return tagCompound.toString(); return tagCompound.toString();
} }
public void readJson(String json, String machineIdent) throws UnsupportedOperationException { public void readJson(String json, String machineIdent) throws UnsupportedOperationException {
CompoundTag compound; NbtCompound compound;
try { try {
compound = StringNbtReader.parse(json); compound = StringNbtReader.parse(json);
} catch (CommandSyntaxException e) { } catch (CommandSyntaxException e) {

View file

@ -26,7 +26,7 @@ package reborncore.common.chunkloading;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ChunkTicketType; import net.minecraft.server.world.ChunkTicketType;
@ -68,7 +68,7 @@ public class ChunkLoaderManager extends PersistentState {
private final List<LoadedChunk> loadedChunks = new ArrayList<>(); private final List<LoadedChunk> loadedChunks = new ArrayList<>();
@Override @Override
public void fromTag(CompoundTag tag) { public void fromNbt(NbtCompound tag) {
loadedChunks.clear(); loadedChunks.clear();
List<LoadedChunk> chunks = CODEC.parse(NbtOps.INSTANCE, tag.getCompound("loadedchunks")) List<LoadedChunk> chunks = CODEC.parse(NbtOps.INSTANCE, tag.getCompound("loadedchunks"))
@ -79,7 +79,7 @@ public class ChunkLoaderManager extends PersistentState {
} }
@Override @Override
public CompoundTag toTag(CompoundTag compoundTag) { public NbtCompound writeNbt(NbtCompound compoundTag) {
CODEC.encodeStart(NbtOps.INSTANCE, loadedChunks) CODEC.encodeStart(NbtOps.INSTANCE, loadedChunks)
.result() .result()
.ifPresent(tag -> compoundTag.put("loadedchunks", tag)); .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 // use the RebornIngredient version to ensure stack sizes are checked
@Deprecated @Deprecated
@Override @Override
public DefaultedList<Ingredient> getPreviewInputs() { public DefaultedList<Ingredient> getIngredients() {
return ingredients.stream().map(RebornIngredient::getPreview).collect(DefaultedListCollector.toList()); return ingredients.stream().map(RebornIngredient::getPreview).collect(DefaultedListCollector.toList());
} }
@ -231,7 +231,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
} }
@Override @Override
public DefaultedList<ItemStack> getRemainingStacks(Inventory p_179532_1_) { public DefaultedList<ItemStack> getRemainder(Inventory p_179532_1_) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View file

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

View file

@ -31,7 +31,7 @@ import com.mojang.serialization.Dynamic;
import com.mojang.serialization.JsonOps; import com.mojang.serialization.JsonOps;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Ingredient;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -49,10 +49,10 @@ public class StackIngredient extends RebornIngredient {
private final List<ItemStack> stacks; private final List<ItemStack> stacks;
private final Optional<Integer> count; private final Optional<Integer> count;
private final Optional<CompoundTag> tag; private final Optional<NbtCompound> tag;
private final boolean requireEmptyTag; 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); super(IngredientManager.STACK_RECIPE_TYPE);
this.stacks = stacks; this.stacks = stacks;
this.count = count; this.count = count;
@ -73,7 +73,7 @@ public class StackIngredient extends RebornIngredient {
stackSize = Optional.of(JsonHelper.getInt(json, "count")); stackSize = Optional.of(JsonHelper.getInt(json, "count"));
} }
Optional<CompoundTag> tag = Optional.empty(); Optional<NbtCompound> tag = Optional.empty();
boolean requireEmptyTag = false; boolean requireEmptyTag = false;
if (json.has("nbt")) { if (json.has("nbt")) {
@ -82,7 +82,7 @@ public class StackIngredient extends RebornIngredient {
requireEmptyTag = true; requireEmptyTag = true;
} }
} else { } 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. //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. //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); 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)) { if (!tag.get().equals(compoundTag)) {
return false; return false;

View file

@ -124,7 +124,7 @@ public abstract class RebornFluid extends FlowableFluid {
@Override @Override
protected BlockState toBlockState(FluidState fluidState) { 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 @Override

View file

@ -80,7 +80,7 @@ public class RebornFluidRenderManager implements ClientSpriteRegistryCallback, S
} }
@Override @Override
public void apply(ResourceManager manager) { public void reload(ResourceManager manager) {
//Reset the cached fluid sprites //Reset the cached fluid sprites
spriteMap.forEach((key, value) -> value.reset()); 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.Fluid;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import reborncore.common.fluid.FluidValue; import reborncore.common.fluid.FluidValue;
@ -41,7 +41,7 @@ public class FluidInstance implements NBTSerializable {
protected Fluid fluid; protected Fluid fluid;
protected FluidValue amount; protected FluidValue amount;
protected CompoundTag tag; protected NbtCompound tag;
public FluidInstance(Fluid fluid, FluidValue amount) { public FluidInstance(Fluid fluid, FluidValue amount) {
this.fluid = fluid; this.fluid = fluid;
@ -56,7 +56,7 @@ public class FluidInstance implements NBTSerializable {
this(Fluids.EMPTY); this(Fluids.EMPTY);
} }
public FluidInstance(CompoundTag tag) { public FluidInstance(NbtCompound tag) {
this(); this();
read(tag); read(tag);
} }
@ -69,7 +69,7 @@ public class FluidInstance implements NBTSerializable {
return amount; return amount;
} }
public CompoundTag getTag() { public NbtCompound getTag() {
return tag; return tag;
} }
@ -93,7 +93,7 @@ public class FluidInstance implements NBTSerializable {
return this; return this;
} }
public void setTag(CompoundTag tag) { public void setTag(NbtCompound tag) {
this.tag = tag; this.tag = tag;
} }
@ -110,8 +110,8 @@ public class FluidInstance implements NBTSerializable {
} }
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
tag.putString(FLUID_KEY, Registry.FLUID.getId(fluid).toString()); tag.putString(FLUID_KEY, Registry.FLUID.getId(fluid).toString());
tag.putInt(AMOUNT_KEY, amount.getRawValue()); tag.putInt(AMOUNT_KEY, amount.getRawValue());
if (this.tag != null && !this.tag.isEmpty()) { if (this.tag != null && !this.tag.isEmpty()) {
@ -121,7 +121,7 @@ public class FluidInstance implements NBTSerializable {
} }
@Override @Override
public void read(CompoundTag tag) { public void read(NbtCompound tag) {
fluid = Registry.FLUID.get(new Identifier(tag.getString(FLUID_KEY))); fluid = Registry.FLUID.get(new Identifier(tag.getString(FLUID_KEY)));
amount = FluidValue.fromRaw(tag.getInt(AMOUNT_KEY)); amount = FluidValue.fromRaw(tag.getInt(AMOUNT_KEY));
if (tag.contains(TAG_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.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.Set; 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 * @return The part's saved multiblock game-data in NBT format, or null if
* there isn't any. * there isn't any.
*/ */
public abstract CompoundTag getMultiblockSaveData(); public abstract NbtCompound getMultiblockSaveData();
/** /**
* Called after a block is added and the controller has incorporated the * 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.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Tickable; import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@ -50,7 +50,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
private boolean visited; private boolean visited;
private boolean saveMultiblockData; private boolean saveMultiblockData;
private CompoundTag cachedMultiblockData; private NbtCompound cachedMultiblockData;
//private boolean paused; //private boolean paused;
public MultiblockBlockEntityBase(BlockEntityType<?> tBlockEntityType) { public MultiblockBlockEntityBase(BlockEntityType<?> tBlockEntityType) {
@ -112,8 +112,8 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
// /// Overrides from base BlockEntity methods // /// Overrides from base BlockEntity methods
@Override @Override
public void fromTag(BlockState blockState, CompoundTag data) { public void readNbt(BlockState blockState, NbtCompound data) {
super.fromTag(blockState, data); super.readNbt(blockState, data);
// We can't directly initialize a multiblock controller yet, so we cache // We can't directly initialize a multiblock controller yet, so we cache
// the data here until // the data here until
@ -125,11 +125,11 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
} }
@Override @Override
public CompoundTag toTag(CompoundTag data) { public NbtCompound writeNbt(NbtCompound data) {
super.toTag(data); super.writeNbt(data);
if (isMultiblockSaveDelegate() && isConnected()) { if (isMultiblockSaveDelegate() && isConnected()) {
CompoundTag multiblockData = new CompoundTag(); NbtCompound multiblockData = new NbtCompound();
this.controller.write(multiblockData); this.controller.write(multiblockData);
data.put("multiblockData", multiblockData); data.put("multiblockData", multiblockData);
} }
@ -173,7 +173,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
// Network Communication // Network Communication
@Override @Override
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
CompoundTag packetData = new CompoundTag(); NbtCompound packetData = new NbtCompound();
encodeDescriptionPacket(packetData); encodeDescriptionPacket(packetData);
return new BlockEntityUpdateS2CPacket(getPos(), 0, 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 * @param packetData An NBT compound tag into which you should write your custom
* description data. * description data.
*/ */
protected void encodeDescriptionPacket(CompoundTag packetData) { protected void encodeDescriptionPacket(NbtCompound packetData) {
if (this.isMultiblockSaveDelegate() && isConnected()) { if (this.isMultiblockSaveDelegate() && isConnected()) {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
getMultiblockController().formatDescriptionPacket(tag); getMultiblockController().formatDescriptionPacket(tag);
packetData.put("multiblockData", 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. * @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")) { if (packetData.contains("multiblockData")) {
CompoundTag tag = packetData.getCompound("multiblockData"); NbtCompound tag = packetData.getCompound("multiblockData");
if (isConnected()) { if (isConnected()) {
getMultiblockController().decodeDescriptionPacket(tag); getMultiblockController().decodeDescriptionPacket(tag);
} else { } else {
@ -220,7 +220,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
} }
@Override @Override
public CompoundTag getMultiblockSaveData() { public NbtCompound getMultiblockSaveData() {
return this.cachedMultiblockData; return this.cachedMultiblockData;
} }

View file

@ -25,7 +25,7 @@
package reborncore.common.multiblock; package reborncore.common.multiblock;
import net.minecraft.block.entity.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.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.chunk.WorldChunk;
@ -128,7 +128,7 @@ public abstract class MultiblockControllerBase {
* @param part Attached part * @param part Attached part
* @param data The NBT tag containing this controller's data. * @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. * Check if a block is being tracked by this machine.
@ -160,7 +160,7 @@ public abstract class MultiblockControllerBase {
this.onBlockAdded(part); this.onBlockAdded(part);
if (part.hasMultiblockSaveData()) { if (part.hasMultiblockSaveData()) {
CompoundTag savedData = part.getMultiblockSaveData(); NbtCompound savedData = part.getMultiblockSaveData();
onAttachedPartWithMultiblockData(part, savedData); onAttachedPartWithMultiblockData(part, savedData);
part.onMultiblockDataAssimilated(); part.onMultiblockDataAssimilated();
} }
@ -679,9 +679,9 @@ public abstract class MultiblockControllerBase {
return connectedParts.size(); 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 * 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 * @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 * 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 * @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 * @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.MinecraftClient;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen; 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.screen.ScreenHandler;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -51,13 +51,13 @@ public class ClientBoundPacketHandlers {
public static void init() { public static void init() {
NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "custom_description"), (client, handler, packetBuffer, responseSender) -> { NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "custom_description"), (client, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos(); BlockPos pos = packetBuffer.readBlockPos();
CompoundTag tagCompound = packetBuffer.readCompoundTag(); NbtCompound tagCompound = packetBuffer.readNbt();
client.execute(() -> { client.execute(() -> {
World world = MinecraftClient.getInstance().world; World world = MinecraftClient.getInstance().world;
if (world.isChunkLoaded(pos)) { if (world.isChunkLoaded(pos)) {
BlockEntity blockentity = world.getBlockEntity(pos); BlockEntity blockentity = world.getBlockEntity(pos);
if (blockentity != null && tagCompound != null) { 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) -> { NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "fluid_config_sync"), (client, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos(); BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag(); NbtCompound compoundTag = packetBuffer.readNbt();
client.execute(() -> { client.execute(() -> {
FluidConfiguration fluidConfiguration = new FluidConfiguration(compoundTag); FluidConfiguration fluidConfiguration = new FluidConfiguration(compoundTag);
@ -86,7 +86,7 @@ public class ClientBoundPacketHandlers {
NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "slot_sync"), (client, handler, packetBuffer, responseSender) -> { NetworkManager.registerClientBoundHandler(new Identifier("reborncore", "slot_sync"), (client, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos(); BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag(); NbtCompound compoundTag = packetBuffer.readNbt();
client.execute(() -> { client.execute(() -> {
SlotConfiguration slotConfig = new SlotConfiguration(compoundTag); SlotConfiguration slotConfig = new SlotConfiguration(compoundTag);

View file

@ -25,7 +25,7 @@
package reborncore.common.network; package reborncore.common.network;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -38,27 +38,27 @@ import java.util.List;
public class ClientBoundPackets { public class ClientBoundPackets {
public static IdentifiedPacket createCustomDescriptionPacket(BlockEntity blockEntity) { 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 -> { return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "custom_description"), packetBuffer -> {
packetBuffer.writeBlockPos(blockPos); packetBuffer.writeBlockPos(blockPos);
packetBuffer.writeCompoundTag(nbt); packetBuffer.writeNbt(nbt);
}); });
} }
public static IdentifiedPacket createPacketFluidConfigSync(BlockPos pos, FluidConfiguration fluidConfiguration) { public static IdentifiedPacket createPacketFluidConfigSync(BlockPos pos, FluidConfiguration fluidConfiguration) {
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "fluid_config_sync"), packetBuffer -> { return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "fluid_config_sync"), packetBuffer -> {
packetBuffer.writeBlockPos(pos); packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(fluidConfiguration.write()); packetBuffer.writeNbt(fluidConfiguration.write());
}); });
} }
public static IdentifiedPacket createPacketSlotSync(BlockPos pos, SlotConfiguration slotConfig) { public static IdentifiedPacket createPacketSlotSync(BlockPos pos, SlotConfiguration slotConfig) {
return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "slot_sync"), packetBuffer -> { return NetworkManager.createClientBoundPacket(new Identifier("reborncore", "slot_sync"), packetBuffer -> {
packetBuffer.writeBlockPos(pos); 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.Codec;
import com.mojang.serialization.DataResult; import com.mojang.serialization.DataResult;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -74,19 +74,19 @@ public class ExtendedPacketBuffer extends PacketByteBuf {
// Supports reading and writing list codec's // Supports reading and writing list codec's
public <T> void writeCodec(Codec<T> codec, T object) { 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()) { if (dataResult.error().isPresent()) {
throw new RuntimeException("Failed to encode: " + dataResult.error().get().message() + " " + object); throw new RuntimeException("Failed to encode: " + dataResult.error().get().message() + " " + object);
} else { } else {
Tag tag = dataResult.result().get(); NbtElement tag = dataResult.result().get();
if (tag instanceof CompoundTag) { if (tag instanceof NbtCompound) {
writeByte(0); writeByte(0);
writeCompoundTag((CompoundTag) tag); writeNbt((NbtCompound) tag);
} else if (tag instanceof ListTag) { } else if (tag instanceof NbtList) {
writeByte(1); writeByte(1);
CompoundTag compoundTag = new CompoundTag(); NbtCompound compoundTag = new NbtCompound();
compoundTag.put("tag", tag); compoundTag.put("tag", tag);
writeCompoundTag(compoundTag); writeNbt(compoundTag);
} else { } else {
throw new RuntimeException("Failed to write: " + tag); throw new RuntimeException("Failed to write: " + tag);
} }
@ -95,12 +95,12 @@ public class ExtendedPacketBuffer extends PacketByteBuf {
public <T> T readCodec(Codec<T> codec) { public <T> T readCodec(Codec<T> codec) {
byte type = readByte(); byte type = readByte();
Tag tag = null; NbtElement tag = null;
if (type == 0) { if (type == 0) {
tag = readCompoundTag(); tag = readNbt();
} else if (type == 1) { } else if (type == 1) {
tag = readCompoundTag().get("tag"); tag = readNbt().get("tag");
} else { } else {
throw new RuntimeException("Failed to read codec"); throw new RuntimeException("Failed to read codec");
} }

View file

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

View file

@ -25,7 +25,7 @@
package reborncore.common.network; package reborncore.common.network;
import net.minecraft.block.BlockState; 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.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -43,7 +43,7 @@ public class ServerBoundPackets {
public static void init() { public static void init() {
NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "fluid_config_save"), (server, player, handler, packetBuffer, responseSender) -> { NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "fluid_config_save"), (server, player, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos(); BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag(); NbtCompound compoundTag = packetBuffer.readNbt();
server.execute(() -> { server.execute(() -> {
FluidConfiguration.FluidConfig fluidConfiguration = new FluidConfiguration.FluidConfig(compoundTag); 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) -> { NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "config_save"), (server, player, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos(); BlockPos pos = packetBuffer.readBlockPos();
CompoundTag tagCompound = packetBuffer.readCompoundTag(); NbtCompound tagCompound = packetBuffer.readNbt();
server.execute(() -> { server.execute(() -> {
MachineBaseBlockEntity legacyMachineBase = (MachineBaseBlockEntity) player.world.getBlockEntity(pos); 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) -> { NetworkManager.registerServerBoundHandler(new Identifier("reborncore", "slot_save"), (server, player, handler, packetBuffer, responseSender) -> {
BlockPos pos = packetBuffer.readBlockPos(); BlockPos pos = packetBuffer.readBlockPos();
CompoundTag compoundTag = packetBuffer.readCompoundTag(); NbtCompound compoundTag = packetBuffer.readNbt();
server.execute(() -> { server.execute(() -> {
SlotConfiguration.SlotConfig slotConfig = new SlotConfiguration.SlotConfig(compoundTag); SlotConfiguration.SlotConfig slotConfig = new SlotConfiguration.SlotConfig(compoundTag);
@ -168,14 +168,14 @@ public class ServerBoundPackets {
public static IdentifiedPacket createPacketFluidConfigSave(BlockPos pos, FluidConfiguration.FluidConfig fluidConfiguration) { public static IdentifiedPacket createPacketFluidConfigSave(BlockPos pos, FluidConfiguration.FluidConfig fluidConfiguration) {
return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "fluid_config_save"), packetBuffer -> { return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "fluid_config_save"), packetBuffer -> {
packetBuffer.writeBlockPos(pos); packetBuffer.writeBlockPos(pos);
packetBuffer.writeCompoundTag(fluidConfiguration.write()); packetBuffer.writeNbt(fluidConfiguration.write());
}); });
} }
public static IdentifiedPacket createPacketConfigSave(BlockPos pos, SlotConfiguration slotConfig) { public static IdentifiedPacket createPacketConfigSave(BlockPos pos, SlotConfiguration slotConfig) {
return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "config_save"), packetBuffer -> { return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "config_save"), packetBuffer -> {
packetBuffer.writeBlockPos(pos); 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) { public static IdentifiedPacket createPacketSlotSave(BlockPos pos, SlotConfiguration.SlotConfig slotConfig) {
return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "slot_save"), packetBuffer -> { return NetworkManager.createServerBoundPacket(new Identifier("reborncore", "slot_save"), packetBuffer -> {
packetBuffer.writeBlockPos(pos); 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.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
@ -330,18 +330,18 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tag) { public void readNbt(BlockState blockState, NbtCompound tag) {
super.fromTag(blockState, tag); super.readNbt(blockState, tag);
CompoundTag data = tag.getCompound("PowerAcceptor"); NbtCompound data = tag.getCompound("PowerAcceptor");
if (shouldHandleEnergyNBT()) { if (shouldHandleEnergyNBT()) {
this.setStored(data.getDouble("energy")); this.setStored(data.getDouble("energy"));
} }
} }
@Override @Override
public CompoundTag toTag(CompoundTag tag) { public NbtCompound writeNbt(NbtCompound tag) {
super.toTag(tag); super.writeNbt(tag);
CompoundTag data = new CompoundTag(); NbtCompound data = new NbtCompound();
data.putDouble("energy", getStored(EnergySide.UNKNOWN)); data.putDouble("energy", getStored(EnergySide.UNKNOWN));
tag.put("PowerAcceptor", data); tag.put("PowerAcceptor", data);
return tag; return tag;

View file

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

View file

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

View file

@ -25,8 +25,8 @@
package reborncore.common.util; package reborncore.common.util;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
public class ItemNBTHelper { public class ItemNBTHelper {
@ -43,7 +43,7 @@ public class ItemNBTHelper {
**/ **/
public static void initNBT(ItemStack stack) { public static void initNBT(ItemStack stack) {
if (!detectNBT(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 * Injects an NBT Tag Compound to an ItemStack, no checks are made
* previously * previously
**/ **/
public static void injectNBT(ItemStack stack, CompoundTag nbt) { public static void injectNBT(ItemStack stack, NbtCompound nbt) {
stack.setTag(nbt); stack.setTag(nbt);
} }
@ -59,7 +59,7 @@ public class ItemNBTHelper {
* Gets the NBTTagCompound in an ItemStack. Tries to init it previously in * Gets the NBTTagCompound in an ItemStack. Tries to init it previously in
* case there isn't one present * case there isn't one present
**/ **/
public static CompoundTag getNBT(ItemStack stack) { public static NbtCompound getNBT(ItemStack stack) {
initNBT(stack); initNBT(stack);
return stack.getTag(); return stack.getTag();
} }
@ -95,7 +95,7 @@ public class ItemNBTHelper {
getNBT(stack).putDouble(tag, d); 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 if (!tag.equalsIgnoreCase("ench")) // not override the enchantments
{ {
getNBT(stack).put(tag, cmp); getNBT(stack).put(tag, cmp);
@ -106,7 +106,7 @@ public class ItemNBTHelper {
getNBT(stack).putString(tag, s); 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); 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 * If nullifyOnFail is true it'll return null if it doesn't find any
* compounds, otherwise it'll return a new one. * 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) 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) { public static String getString(ItemStack stack, String tag, String defaultExpected) {
return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : 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) 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.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
@ -88,18 +88,18 @@ public class ItemUtils {
return false; return false;
} }
public static void writeItemToNBT(ItemStack stack, CompoundTag data) { public static void writeItemToNBT(ItemStack stack, NbtCompound data) {
if (stack.isEmpty() || stack.getCount() <= 0) { if (stack.isEmpty() || stack.getCount() <= 0) {
return; return;
} }
if (stack.getCount() > 127) { if (stack.getCount() > 127) {
stack.setCount(127); stack.setCount(127);
} }
stack.toTag(data); stack.writeNbt(data);
} }
public static ItemStack readItemFromNBT(CompoundTag data) { public static ItemStack readItemFromNBT(NbtCompound data) {
return ItemStack.fromTag(data); return ItemStack.fromNbt(data);
} }
public static double getPowerForDurabilityBar(ItemStack stack) { public static double getPowerForDurabilityBar(ItemStack stack) {

View file

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

View file

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

View file

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

View file

@ -81,12 +81,12 @@ allprojects {
// Shared deps between TR and RC // Shared deps between TR and RC
dependencies { dependencies {
minecraft "com.mojang:minecraft:1.16.5" minecraft "com.mojang:minecraft:1.17-pre1"
mappings "net.fabricmc:yarn:1.16.5+build.4:v2" mappings "net.fabricmc:yarn:1.17-pre1+build.4:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.3" modImplementation "net.fabricmc:fabric-loader:0.11.3"
//Fabric api //Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.30.0+1.16" modImplementation "net.fabricmc.fabric-api:fabric-api:0.34.8+1.17"
modApi 'teamreborn:energy:0.1.1' modApi 'teamreborn:energy:0.1.1'
} }

View file

@ -97,8 +97,8 @@ public class RollingMachineRecipe extends RebornRecipe {
} }
@Override @Override
public DefaultedList<Ingredient> getPreviewInputs() { public DefaultedList<Ingredient> getIngredients() {
return shapedRecipe.getPreviewInputs(); return shapedRecipe.getIngredients();
} }
@Override @Override

View file

@ -29,7 +29,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtHelper;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
@ -122,20 +122,20 @@ public class CableBlockEntity extends BlockEntity
// BlockEntity // BlockEntity
@Override @Override
public CompoundTag toInitialChunkDataTag() { public NbtCompound toInitialChunkDataNbt() {
return toTag(new CompoundTag()); return writeNbt(new NbtCompound());
} }
@Override @Override
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
CompoundTag nbtTag = new CompoundTag(); NbtCompound nbtTag = new NbtCompound();
toTag(nbtTag); writeNbt(nbtTag);
return new BlockEntityUpdateS2CPacket(getPos(), 1, nbtTag); return new BlockEntityUpdateS2CPacket(getPos(), 1, nbtTag);
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag compound) { public void readNbt(BlockState blockState, NbtCompound compound) {
super.fromTag(blockState, compound); super.readNbt(blockState, compound);
if (compound.contains("energy")) { if (compound.contains("energy")) {
energy = compound.getDouble("energy"); energy = compound.getDouble("energy");
} }
@ -147,8 +147,8 @@ public class CableBlockEntity extends BlockEntity
} }
@Override @Override
public CompoundTag toTag(CompoundTag compound) { public NbtCompound writeNbt(NbtCompound compound) {
super.toTag(compound); super.writeNbt(compound);
compound.putDouble("energy", energy); compound.putDouble("energy", energy);
if (cover != null) { if (cover != null) {
compound.put("cover", NbtHelper.fromBlockState(cover)); compound.put("cover", NbtHelper.fromBlockState(cover));

View file

@ -27,7 +27,7 @@ package techreborn.blockentity.generator;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
@ -167,14 +167,14 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tagCompound) { public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
tank.read(tagCompound); tank.read(tagCompound);
} }
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public NbtCompound writeNbt(NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound; return tagCompound;
} }

View file

@ -28,7 +28,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
@ -264,13 +264,13 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tag) { public void readNbt(BlockState blockState, NbtCompound tag) {
if (world == null) { if (world == null) {
// We are in BlockEntity.create method during chunk load. // We are in BlockEntity.create method during chunk load.
this.checkOverfill = false; this.checkOverfill = false;
} }
updatePanel(); updatePanel();
super.fromTag(blockState, tag); super.readNbt(blockState, tag);
} }
// MachineBaseBlockEntity // MachineBaseBlockEntity

View file

@ -30,7 +30,7 @@ import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider; import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.MachineBaseBlockEntity;
@ -132,16 +132,16 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
// MachineBaseBlockEntity // MachineBaseBlockEntity
@Override @Override
public void fromTag(BlockState blockState, CompoundTag compoundTag) { public void readNbt(BlockState blockState, NbtCompound compoundTag) {
super.fromTag(blockState, compoundTag); super.readNbt(blockState, compoundTag);
burnTime = compoundTag.getInt("BurnTime"); burnTime = compoundTag.getInt("BurnTime");
totalBurnTime = compoundTag.getInt("TotalBurnTime"); totalBurnTime = compoundTag.getInt("TotalBurnTime");
progress = compoundTag.getInt("Progress"); progress = compoundTag.getInt("Progress");
} }
@Override @Override
public CompoundTag toTag(CompoundTag compoundTag) { public NbtCompound writeNbt(NbtCompound compoundTag) {
super.toTag(compoundTag); super.writeNbt(compoundTag);
compoundTag.putInt("BurnTime", burnTime); compoundTag.putInt("BurnTime", burnTime);
compoundTag.putInt("TotalBurnTime", totalBurnTime); compoundTag.putInt("TotalBurnTime", totalBurnTime);
compoundTag.putInt("Progress", progress); compoundTag.putInt("Progress", progress);

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.AbstractCookingRecipe;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeType;
@ -143,14 +143,14 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag compoundTag) { public void readNbt(BlockState blockState, NbtCompound compoundTag) {
super.fromTag(blockState, compoundTag); super.readNbt(blockState, compoundTag);
experience = compoundTag.getFloat("Experience"); experience = compoundTag.getFloat("Experience");
} }
@Override @Override
public CompoundTag toTag(CompoundTag compoundTag) { public NbtCompound writeNbt(NbtCompound compoundTag) {
super.toTag(compoundTag); super.writeNbt(compoundTag);
compoundTag.putFloat("Experience", experience); compoundTag.putFloat("Experience", experience);
return compoundTag; return compoundTag;
} }

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
@ -66,20 +66,20 @@ public class AlarmBlockEntity extends BlockEntity
// BlockEntity // BlockEntity
@Override @Override
public CompoundTag toTag(CompoundTag compound) { public NbtCompound writeNbt(NbtCompound compound) {
if (compound == null) { if (compound == null) {
compound = new CompoundTag(); compound = new NbtCompound();
} }
compound.putInt("selectedSound", this.selectedSound); compound.putInt("selectedSound", this.selectedSound);
return super.toTag(compound); return super.writeNbt(compound);
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag compound) { public void readNbt(BlockState blockState, NbtCompound compound) {
if (compound != null && compound.contains("selectedSound")) { if (compound != null && compound.contains("selectedSound")) {
selectedSound = compound.getInt("selectedSound"); selectedSound = compound.getInt("selectedSound");
} }
super.fromTag(blockState, compound); super.readNbt(blockState, compound);
} }
// Tickable // Tickable

View file

@ -27,7 +27,7 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
@ -99,14 +99,14 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
// TilePowerAcceptor // TilePowerAcceptor
@Override @Override
public void fromTag(BlockState blockState, final CompoundTag tagCompound) { public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
tank.read(tagCompound); tank.read(tagCompound);
} }
@Override @Override
public CompoundTag toTag(final CompoundTag tagCompound) { public NbtCompound writeNbt(final NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound; return tagCompound;
} }

View file

@ -27,7 +27,7 @@ package techreborn.blockentity.machine.multiblock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -352,8 +352,8 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
} }
@Override @Override
public void fromTag(BlockState blockState, final CompoundTag tagCompound) { public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
this.craftingTickTime = tagCompound.getInt("craftingTickTime"); this.craftingTickTime = tagCompound.getInt("craftingTickTime");
this.neededPower = tagCompound.getInt("neededPower"); this.neededPower = tagCompound.getInt("neededPower");
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting"); this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
@ -368,8 +368,8 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
} }
@Override @Override
public CompoundTag toTag(final CompoundTag tagCompound) { public NbtCompound writeNbt(final NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tagCompound.putInt("craftingTickTime", this.craftingTickTime); tagCompound.putInt("craftingTickTime", this.craftingTickTime);
tagCompound.putInt("neededPower", this.neededPower); tagCompound.putInt("neededPower", this.neededPower);
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting); tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
@ -93,14 +93,14 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
} }
@Override @Override
public void fromTag(BlockState blockState, final CompoundTag tagCompound) { public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
tank.read(tagCompound); tank.read(tagCompound);
} }
@Override @Override
public CompoundTag toTag(final CompoundTag tagCompound) { public NbtCompound writeNbt(final NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound; return tagCompound;
} }

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
@ -95,14 +95,14 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
// TilePowerAcceptor // TilePowerAcceptor
@Override @Override
public void fromTag(BlockState blockState, final CompoundTag tagCompound) { public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
tank.read(tagCompound); tank.read(tagCompound);
} }
@Override @Override
public CompoundTag toTag(final CompoundTag tagCompound) { public NbtCompound writeNbt(final NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound; return tagCompound;
} }

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.CraftingRecipe; import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeType;
@ -162,7 +162,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if (!hasOutputSpace(recipe.getOutput(), OUTPUT_SLOT)) return false; if (!hasOutputSpace(recipe.getOutput(), OUTPUT_SLOT)) return false;
DefaultedList<ItemStack> remainingStacks = recipe.getRemainingStacks(crafting); DefaultedList<ItemStack> remainingStacks = recipe.getRemainder(crafting);
for (ItemStack stack : remainingStacks){ for (ItemStack stack : remainingStacks){
if (!stack.isEmpty() && !hasRoomForExtraItem(stack)) return false; if (!stack.isEmpty() && !hasRoomForExtraItem(stack)) return false;
} }
@ -193,8 +193,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if (recipe == null || !canMake(recipe)) { if (recipe == null || !canMake(recipe)) {
return false; return false;
} }
for (int i = 0; i < recipe.getPreviewInputs().size(); i++) { for (int i = 0; i < recipe.getIngredients().size(); i++) {
DefaultedList<Ingredient> ingredients = recipe.getPreviewInputs(); DefaultedList<Ingredient> ingredients = recipe.getIngredients();
Ingredient ingredient = ingredients.get(i); Ingredient ingredient = ingredients.get(i);
// Looks for the best slot to take it from // Looks for the best slot to take it from
ItemStack bestSlot = inventory.getStack(i); ItemStack bestSlot = inventory.getStack(i);
@ -267,13 +267,13 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return Optional.empty(); return Optional.empty();
} }
List<Integer> possibleSlots = new ArrayList<>(); List<Integer> possibleSlots = new ArrayList<>();
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) { for (int s = 0; s < currentRecipe.getIngredients().size(); s++) {
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
if (possibleSlots.contains(i)) { if (possibleSlots.contains(i)) {
continue; continue;
} }
ItemStack stackInSlot = inventory.getStack(i); ItemStack stackInSlot = inventory.getStack(i);
Ingredient ingredient = currentRecipe.getPreviewInputs().get(s); Ingredient ingredient = currentRecipe.getIngredients().get(s);
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) { if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
if (stackInSlot.getItem() == sourceStack.getItem()) { if (stackInSlot.getItem() == sourceStack.getItem()) {
possibleSlots.add(i); possibleSlots.add(i);
@ -405,17 +405,17 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
} }
@Override @Override
public CompoundTag toTag(CompoundTag tag) { public NbtCompound writeNbt(NbtCompound tag) {
tag.putBoolean("locked", locked); tag.putBoolean("locked", locked);
return super.toTag(tag); return super.writeNbt(tag);
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tag) { public void readNbt(BlockState blockState, NbtCompound tag) {
if (tag.contains("locked")) { if (tag.contains("locked")) {
locked = tag.getBoolean("locked"); locked = tag.getBoolean("locked");
} }
super.fromTag(blockState, tag); super.readNbt(blockState, tag);
} }
// MachineBaseBlockEntity // MachineBaseBlockEntity

View file

@ -27,7 +27,7 @@ package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity; import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.WorldUtils; import reborncore.common.util.WorldUtils;
@ -117,14 +117,14 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tag) { public void readNbt(BlockState blockState, NbtCompound tag) {
super.fromTag(blockState, tag); super.readNbt(blockState, tag);
owenerUdid = tag.getString("ownerID"); owenerUdid = tag.getString("ownerID");
} }
@Override @Override
public CompoundTag toTag(CompoundTag tag) { public NbtCompound writeNbt(NbtCompound tag) {
super.toTag(tag); super.writeNbt(tag);
tag.putString("ownerID", owenerUdid); tag.putString("ownerID", owenerUdid);
return tag; return tag;
} }

View file

@ -30,7 +30,7 @@ import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@ -141,15 +141,15 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
} }
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public NbtCompound writeNbt(NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tagCompound) { public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
this.isFull = blockState.get(ResinBasinBlock.FULL); this.isFull = blockState.get(ResinBasinBlock.FULL);

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Ingredient;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -206,9 +206,9 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
return Optional.empty(); return Optional.empty();
} }
List<Integer> possibleSlots = new ArrayList<>(); List<Integer> possibleSlots = new ArrayList<>();
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) { for (int s = 0; s < currentRecipe.getIngredients().size(); s++) {
ItemStack stackInSlot = inventory.getStack(s); ItemStack stackInSlot = inventory.getStack(s);
Ingredient ingredient = currentRecipe.getPreviewInputs().get(s); Ingredient ingredient = currentRecipe.getIngredients().get(s);
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) { if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
if (stackInSlot.isEmpty()) { if (stackInSlot.isEmpty()) {
possibleSlots.add(s); possibleSlots.add(s);
@ -343,16 +343,16 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
} }
@Override @Override
public void fromTag(BlockState blockState, final CompoundTag tagCompound) { public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
this.isRunning = tagCompound.getBoolean("isRunning"); this.isRunning = tagCompound.getBoolean("isRunning");
this.tickTime = tagCompound.getInt("tickTime"); this.tickTime = tagCompound.getInt("tickTime");
this.locked = tagCompound.getBoolean("locked"); this.locked = tagCompound.getBoolean("locked");
} }
@Override @Override
public CompoundTag toTag(final CompoundTag tagCompound) { public NbtCompound writeNbt(final NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tagCompound.putBoolean("isRunning", this.isRunning); tagCompound.putBoolean("isRunning", this.isRunning);
tagCompound.putInt("tickTime", this.tickTime); tagCompound.putInt("tickTime", this.tickTime);
tagCompound.putBoolean("locked", locked); tagCompound.putBoolean("locked", locked);

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
@ -124,8 +124,8 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
} }
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public NbtCompound writeNbt(NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tagCompound.putInt("radius", radius); tagCompound.putInt("radius", radius);
if (ownerUdid != null && !ownerUdid.isEmpty()){ if (ownerUdid != null && !ownerUdid.isEmpty()){
tagCompound.putString("ownerUdid", ownerUdid); tagCompound.putString("ownerUdid", ownerUdid);
@ -135,8 +135,8 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag nbttagcompound) { public void readNbt(BlockState blockState, NbtCompound nbttagcompound) {
super.fromTag(blockState, nbttagcompound); super.readNbt(blockState, nbttagcompound);
this.radius = nbttagcompound.getInt("radius"); this.radius = nbttagcompound.getInt("radius");
this.ownerUdid = nbttagcompound.getString("ownerUdid"); this.ownerUdid = nbttagcompound.getString("ownerUdid");
if (!StringUtils.isBlank(ownerUdid)) { if (!StringUtils.isBlank(ownerUdid)) {

View file

@ -27,7 +27,7 @@ package techreborn.blockentity.storage.energy;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import reborncore.api.blockentity.IUpgrade; import reborncore.api.blockentity.IUpgrade;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
@ -76,10 +76,10 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
} }
public ItemStack getDropWithNBT() { public ItemStack getDropWithNBT() {
CompoundTag blockEntity = new CompoundTag(); NbtCompound blockEntity = new NbtCompound();
ItemStack dropStack = TRContent.Machine.ADJUSTABLE_SU.getStack(); ItemStack dropStack = TRContent.Machine.ADJUSTABLE_SU.getStack();
toTag(blockEntity); writeNbt(blockEntity);
dropStack.setTag(new CompoundTag()); dropStack.setTag(new NbtCompound());
dropStack.getOrCreateTag().put("blockEntity", blockEntity); dropStack.getOrCreateTag().put("blockEntity", blockEntity);
return dropStack; return dropStack;
} }
@ -137,15 +137,15 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
} }
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public NbtCompound writeNbt(NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tagCompound.putInt("output", OUTPUT); tagCompound.putInt("output", OUTPUT);
return tagCompound; return tagCompound;
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag nbttagcompound) { public void readNbt(BlockState blockState, NbtCompound nbttagcompound) {
super.fromTag(blockState, nbttagcompound); super.readNbt(blockState, nbttagcompound);
this.OUTPUT = nbttagcompound.getInt("output"); this.OUTPUT = nbttagcompound.getInt("output");
} }

View file

@ -24,7 +24,7 @@
package techreborn.blockentity.storage.energy.idsu; package techreborn.blockentity.storage.energy.idsu;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentState;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -59,14 +59,14 @@ public class IDSUManager extends PersistentState {
} }
@Override @Override
public void fromTag(CompoundTag tag) { public void fromNbt(NbtCompound tag) {
for (String uuid : tag.getKeys()) { for (String uuid : tag.getKeys()) {
playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid))); playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid)));
} }
} }
@Override @Override
public CompoundTag toTag(CompoundTag tag) { public NbtCompound writeNbt(NbtCompound tag) {
playerHashMap.forEach((uuid, player) -> tag.put(uuid, player.write())); playerHashMap.forEach((uuid, player) -> tag.put(uuid, player.write()));
return tag; return tag;
} }
@ -78,20 +78,20 @@ public class IDSUManager extends PersistentState {
private IDSUPlayer() { private IDSUPlayer() {
} }
private IDSUPlayer(CompoundTag compoundTag) { private IDSUPlayer(NbtCompound compoundTag) {
read(compoundTag); read(compoundTag);
} }
@NotNull @NotNull
@Override @Override
public CompoundTag write() { public NbtCompound write() {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
tag.putDouble("energy", energy); tag.putDouble("energy", energy);
return tag; return tag;
} }
@Override @Override
public void read(@NotNull CompoundTag tag) { public void read(@NotNull NbtCompound tag) {
energy = tag.getDouble("energy"); energy = tag.getDouble("energy");
} }

View file

@ -26,7 +26,7 @@ package techreborn.blockentity.storage.energy.idsu;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
@ -96,14 +96,14 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag nbttagcompound) { public void readNbt(BlockState blockState, NbtCompound nbttagcompound) {
super.fromTag(blockState, nbttagcompound); super.readNbt(blockState, nbttagcompound);
this.ownerUdid = nbttagcompound.getString("ownerUdid"); this.ownerUdid = nbttagcompound.getString("ownerUdid");
} }
@Override @Override
public CompoundTag toTag(CompoundTag nbttagcompound) { public NbtCompound writeNbt(NbtCompound nbttagcompound) {
super.toTag(nbttagcompound); super.writeNbt(nbttagcompound);
if (ownerUdid == null || StringUtils.isEmpty(ownerUdid)) { if (ownerUdid == null || StringUtils.isEmpty(ownerUdid)) {
return nbttagcompound; return nbttagcompound;
} }

View file

@ -27,7 +27,7 @@ package techreborn.blockentity.storage.fluid;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
@ -76,9 +76,9 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
public ItemStack getDropWithNBT() { public ItemStack getDropWithNBT() {
ItemStack dropStack = new ItemStack(getBlockType(), 1); ItemStack dropStack = new ItemStack(getBlockType(), 1);
final CompoundTag blockEntity = new CompoundTag(); final NbtCompound blockEntity = new NbtCompound();
this.toTag(blockEntity); this.writeNbt(blockEntity);
dropStack.setTag(new CompoundTag()); dropStack.setTag(new NbtCompound());
dropStack.getOrCreateTag().put("blockEntity", blockEntity); dropStack.getOrCreateTag().put("blockEntity", blockEntity);
return dropStack; return dropStack;
} }
@ -115,8 +115,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
} }
@Override @Override
public void fromTag(BlockState blockState, final CompoundTag tagCompound) { public void readNbt(BlockState blockState, final NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
if (tagCompound.contains("unitType")) { if (tagCompound.contains("unitType")) {
this.type = TRContent.TankUnit.valueOf(tagCompound.getString("unitType")); this.type = TRContent.TankUnit.valueOf(tagCompound.getString("unitType"));
configureEntity(type); configureEntity(type);
@ -125,8 +125,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
} }
@Override @Override
public CompoundTag toTag(final CompoundTag tagCompound) { public NbtCompound writeNbt(final NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tagCompound.putString("unitType", this.type.name()); tagCompound.putString("unitType", this.type.name());
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound; return tagCompound;

View file

@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
@ -285,8 +285,8 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
} }
@Override @Override
public void fromTag(BlockState blockState, CompoundTag tagCompound) { public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.fromTag(blockState, tagCompound); super.readNbt(blockState, tagCompound);
if (tagCompound.contains("unitType")) { if (tagCompound.contains("unitType")) {
this.type = TRContent.StorageUnit.valueOf(tagCompound.getString("unitType")); this.type = TRContent.StorageUnit.valueOf(tagCompound.getString("unitType"));
@ -298,7 +298,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
storeItemStack = ItemStack.EMPTY; storeItemStack = ItemStack.EMPTY;
if (tagCompound.contains("storedStack")) { if (tagCompound.contains("storedStack")) {
storeItemStack = ItemStack.fromTag(tagCompound.getCompound("storedStack")); storeItemStack = ItemStack.fromNbt(tagCompound.getCompound("storedStack"));
} }
if (!storeItemStack.isEmpty()) { if (!storeItemStack.isEmpty()) {
@ -311,15 +311,15 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
} }
if (tagCompound.contains("lockedItem")) { if (tagCompound.contains("lockedItem")) {
lockedItemStack = ItemStack.fromTag(tagCompound.getCompound("lockedItem")); lockedItemStack = ItemStack.fromNbt(tagCompound.getCompound("lockedItem"));
} }
inventory.read(tagCompound); inventory.read(tagCompound);
} }
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public NbtCompound writeNbt(NbtCompound tagCompound) {
super.toTag(tagCompound); super.writeNbt(tagCompound);
tagCompound.putString("unitType", this.type.name()); tagCompound.putString("unitType", this.type.name());
@ -328,7 +328,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
if (storeItemStack.getCount() > storeItemStack.getMaxCount()) { if (storeItemStack.getCount() > storeItemStack.getMaxCount()) {
temp.setCount(storeItemStack.getMaxCount()); temp.setCount(storeItemStack.getMaxCount());
} }
tagCompound.put("storedStack", temp.toTag(new CompoundTag())); tagCompound.put("storedStack", temp.writeNbt(new NbtCompound()));
tagCompound.putInt("storedQuantity", Math.min(storeItemStack.getCount(), maxCapacity)); tagCompound.putInt("storedQuantity", Math.min(storeItemStack.getCount(), maxCapacity));
} else { } else {
tagCompound.putInt("storedQuantity", 0); tagCompound.putInt("storedQuantity", 0);
@ -338,7 +338,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
tagCompound.putInt("totalStoredAmount", getCurrentCapacity()); tagCompound.putInt("totalStoredAmount", getCurrentCapacity());
if (isLocked()) { if (isLocked()) {
tagCompound.put("lockedItem", lockedItemStack.toTag(new CompoundTag())); tagCompound.put("lockedItem", lockedItemStack.writeNbt(new NbtCompound()));
} }
inventory.write(tagCompound); inventory.write(tagCompound);
@ -408,10 +408,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
@Override @Override
public ItemStack getToolDrop(PlayerEntity entityPlayer) { public ItemStack getToolDrop(PlayerEntity entityPlayer) {
ItemStack dropStack = new ItemStack(getBlockType(), 1); ItemStack dropStack = new ItemStack(getBlockType(), 1);
final CompoundTag blockEntity = new CompoundTag(); final NbtCompound blockEntity = new NbtCompound();
this.toTag(blockEntity); this.writeNbt(blockEntity);
dropStack.setTag(new CompoundTag()); dropStack.setTag(new NbtCompound());
dropStack.getOrCreateTag().put("blockEntity", blockEntity); dropStack.getOrCreateTag().put("blockEntity", blockEntity);
return dropStack; return dropStack;
@ -492,13 +492,13 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
this.serverCapacity = maxCapacity; this.serverCapacity = maxCapacity;
} }
public CompoundTag getStoredStackNBT() { public NbtCompound getStoredStackNBT() {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
getStoredStack().toTag(tag); getStoredStack().writeNbt(tag);
return tag; return tag;
} }
public void setStoredStackFromNBT(CompoundTag tag) { public void setStoredStackFromNBT(NbtCompound tag) {
storeItemStack = ItemStack.fromTag(tag); storeItemStack = ItemStack.fromNbt(tag);
} }
} }

View file

@ -27,15 +27,15 @@ package techreborn.blocks.misc;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock; import net.minecraft.block.FenceBlock;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
public class BlockRefinedIronFence extends FenceBlock { public class BlockRefinedIronFence extends FenceBlock {
public BlockRefinedIronFence() { public BlockRefinedIronFence() {
super(FabricBlockSettings.of(Material.METAL, MaterialColor.WOOD).strength(2.0F, 3.0F).sounds(BlockSoundGroup.METAL)); super(FabricBlockSettings.of(Material.METAL, MapColor.OAK_TAN).strength(2.0F, 3.0F).sounds(BlockSoundGroup.METAL));
} }
@Override @Override

View file

@ -66,7 +66,7 @@ public class BlockRubberLog extends PillarBlock {
public static BooleanProperty SHOULD_SAP = BooleanProperty.of("shouldsap"); public static BooleanProperty SHOULD_SAP = BooleanProperty.of("shouldsap");
public BlockRubberLog() { public BlockRubberLog() {
super(Settings.of(Material.WOOD, (blockState) -> MaterialColor.SPRUCE) super(Settings.of(Material.WOOD, (blockState) -> MapColor.SPRUCE_BROWN)
.strength(2.0F, 2f) .strength(2.0F, 2f)
.sounds(BlockSoundGroup.WOOD) .sounds(BlockSoundGroup.WOOD)
.ticksRandomly()); .ticksRandomly());

View file

@ -100,7 +100,7 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
} }
@Override @Override
public void renderBg(MatrixStack matrixStack, MinecraftClient mc, int mouseX, int mouseY) { public void renderBackground(MatrixStack matrixStack, MinecraftClient mc, int mouseX, int mouseY) {
mc.getItemRenderer().renderInGuiWithOverrides(new ItemStack(Items.EXPERIENCE_BOTTLE), x, y); mc.getItemRenderer().renderInGuiWithOverrides(new ItemStack(Items.EXPERIENCE_BOTTLE), x, y);
} }
}); });

View file

@ -24,7 +24,7 @@
package techreborn.client.keybindings; package techreborn.client.keybindings;
import net.minecraft.client.options.KeyBinding; import net.minecraft.client.option.KeyBinding;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
public class KeyBindings { public class KeyBindings {

View file

@ -30,9 +30,9 @@ import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.TntMinecartEntityRenderer; import net.minecraft.client.render.entity.TntMinecartEntityRenderer;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3f;
import techreborn.entities.EntityNukePrimed; import techreborn.entities.EntityNukePrimed;
import techreborn.init.TRContent; import techreborn.init.TRContent;
@ -67,7 +67,7 @@ public class NukeRenderer extends EntityRenderer<EntityNukePrimed> {
matrixStack.scale(j, j, j); matrixStack.scale(j, j, j);
} }
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F));
matrixStack.translate(-0.5D, -0.5D, 0.5D); matrixStack.translate(-0.5D, -0.5D, 0.5D);
TntMinecartEntityRenderer.renderFlashingBlock(TRContent.NUKE.getDefaultState(), matrixStack, vertexConsumerProvider, i, entity.getFuseTimer() / 5 % 2 == 0); TntMinecartEntityRenderer.renderFlashingBlock(TRContent.NUKE.getDefaultState(), matrixStack, vertexConsumerProvider, i, entity.getFuseTimer() / 5 % 2 == 0);
matrixStack.pop(); matrixStack.pop();

View file

@ -33,9 +33,9 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3f;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity; import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
/** /**
@ -59,7 +59,7 @@ public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBloc
// Item rendering // Item rendering
matrices.push(); matrices.push();
Direction direction = storage.getFacing(); Direction direction = storage.getFacing();
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((direction.getHorizontal() - 2) * 90F)); matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((direction.getHorizontal() - 2) * 90F));
matrices.scale(0.5F, 0.5F, 0.5F); matrices.scale(0.5F, 0.5F, 0.5F);
switch (direction) { switch (direction) {
case NORTH: case NORTH:
@ -85,7 +85,7 @@ public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBloc
// Render item only on horizontal facing #2183 // Render item only on horizontal facing #2183
if (Direction.Type.HORIZONTAL.test(facing) ){ if (Direction.Type.HORIZONTAL.test(facing) ){
matrices.translate(0.5, 0.5, 0.5); // Translate center matrices.translate(0.5, 0.5, 0.5); // Translate center
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90)); // Rotate depending on face matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90)); // Rotate depending on face
matrices.translate(0, 0, -0.505); // Translate forward matrices.translate(0, 0, -0.505); // Translate forward
} }

View file

@ -33,9 +33,9 @@ import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3f;
import techreborn.blockentity.generator.basic.WindMillBlockEntity; import techreborn.blockentity.generator.basic.WindMillBlockEntity;
public class TurbineRenderer extends BlockEntityRenderer<WindMillBlockEntity> { public class TurbineRenderer extends BlockEntityRenderer<WindMillBlockEntity> {
@ -55,7 +55,7 @@ public class TurbineRenderer extends BlockEntityRenderer<WindMillBlockEntity> {
matrixStack.push(); matrixStack.push();
matrixStack.translate(0.5, 0, 0.5); matrixStack.translate(0.5, 0, 0.5);
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90)); matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90));
matrixStack.translate(0, -1, -0.56); matrixStack.translate(0, -1, -0.56);
float spin = blockEntity.bladeAngle + tickDelta * blockEntity.spinSpeed; float spin = blockEntity.bladeAngle + tickDelta * blockEntity.spinSpeed;

View file

@ -100,7 +100,7 @@ public class ModRegistry {
RebornRegistry.registerBlock(TRContent.RUBBER_BUTTON = InitUtils.setup(new RubberButtonBlock(), "rubber_button"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_BUTTON = InitUtils.setup(new RubberButtonBlock(), "rubber_button"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_PRESSURE_PLATE = InitUtils.setup(new RubberPressurePlateBlock(), "rubber_pressure_plate"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_PRESSURE_PLATE = InitUtils.setup(new RubberPressurePlateBlock(), "rubber_pressure_plate"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_DOOR = InitUtils.setup(new RubberDoorBlock(), "rubber_door"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_DOOR = InitUtils.setup(new RubberDoorBlock(), "rubber_door"), itemGroup);
RebornRegistry.registerBlockNoItem(TRContent.POTTED_RUBBER_SAPLING = InitUtils.setup(new FlowerPotBlock(TRContent.RUBBER_SAPLING, AbstractBlock.Settings.of(Material.SUPPORTED).breakInstantly().nonOpaque()), "potted_rubber_sapling")); RebornRegistry.registerBlockNoItem(TRContent.POTTED_RUBBER_SAPLING = InitUtils.setup(new FlowerPotBlock(TRContent.RUBBER_SAPLING, AbstractBlock.Settings.of(Material.DECORATION).breakInstantly().nonOpaque()), "potted_rubber_sapling"));
TechReborn.LOGGER.debug("TechReborns Blocks Loaded"); TechReborn.LOGGER.debug("TechReborns Blocks Loaded");
} }

View file

@ -54,7 +54,7 @@ public class TRRecipeHandler {
if (!recipe.getId().getNamespace().equals(TechReborn.MOD_ID)) { if (!recipe.getId().getNamespace().equals(TechReborn.MOD_ID)) {
return false; return false;
} }
return recipe.getPreviewInputs().stream().noneMatch(ingredient -> ingredient.test(TRContent.Parts.UU_MATTER.getStack())); return recipe.getIngredients().stream().noneMatch(ingredient -> ingredient.test(TRContent.Parts.UU_MATTER.getStack()));
} }
} }

View file

@ -35,7 +35,7 @@ import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
@ -231,7 +231,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
@Override @Override
public Fluid getFluid(ItemStack itemStack) { public Fluid getFluid(ItemStack itemStack) {
CompoundTag tag = itemStack.getTag(); NbtCompound tag = itemStack.getTag();
if (tag != null && tag.contains("fluid")) { if (tag != null && tag.contains("fluid")) {
return Registry.FLUID.get(new Identifier(tag.getString("fluid"))); return Registry.FLUID.get(new Identifier(tag.getString("fluid")));
} }

View file

@ -115,8 +115,8 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
} }
@Override @Override
public boolean isEffectiveOn(BlockState state) { public boolean isSuitableFor(BlockState state) {
return referenceTool.isEffectiveOn(state); return referenceTool.isSuitableFor(state);
} }
// ItemDurabilityExtensions // ItemDurabilityExtensions

View file

@ -135,7 +135,7 @@ public class DebugToolItem extends Item {
MutableText s = new LiteralText("BlockEntity Tags:").formatted(Formatting.GREEN); MutableText s = new LiteralText("BlockEntity Tags:").formatted(Formatting.GREEN);
BlockDataObject bdo = new BlockDataObject(blockEntity, blockEntity.getPos()); BlockDataObject bdo = new BlockDataObject(blockEntity, blockEntity.getPos());
s.append(bdo.getTag().toText()); s.append(bdo.getNbt().toText());
return s; return s;
} }

View file

@ -69,7 +69,7 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
// Going to remain to use this ol reliable function, the fabric one is funky // Going to remain to use this ol reliable function, the fabric one is funky
if (Energy.of(stack).getEnergy() >= cost) { if (Energy.of(stack).getEnergy() >= cost) {
if (stack.getItem().isEffectiveOn(state)) { if (stack.getItem().isSuitableFor(state)) {
return poweredSpeed; return poweredSpeed;
} else { } else {
return Math.min(unpoweredSpeed * 10f, poweredSpeed); // Still be faster than unpowered when not effective return Math.min(unpoweredSpeed * 10f, poweredSpeed); // Still be faster than unpowered when not effective
@ -81,15 +81,15 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
// PickaxeItem // PickaxeItem
@Override @Override
public boolean isEffectiveOn(BlockState blockIn) { public boolean isSuitableFor(BlockState blockIn) {
if(blockIn == null){ if(blockIn == null){
return false; return false;
} }
if (Items.DIAMOND_PICKAXE.isEffectiveOn(blockIn)) { if (Items.DIAMOND_PICKAXE.isSuitableFor(blockIn)) {
return true; return true;
} }
if (Items.DIAMOND_SHOVEL.isEffectiveOn(blockIn)) { if (Items.DIAMOND_SHOVEL.isSuitableFor(blockIn)) {
return true; return true;
} }
// More checks to fix #2225 // More checks to fix #2225

View file

@ -66,13 +66,13 @@ public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlock
if (ToolsUtil.JackHammerSkippedBlocks(blockState)){ if (ToolsUtil.JackHammerSkippedBlocks(blockState)){
return false; return false;
} }
return (stack.getItem().isEffectiveOn(blockState)); return (stack.getItem().isSuitableFor(blockState));
} }
// JackhammerItem // JackhammerItem
@Override @Override
public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) { public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) {
if (!ItemUtils.isActive(stack) || !stack.getItem().isEffectiveOn(stateIn)) { if (!ItemUtils.isActive(stack) || !stack.getItem().isSuitableFor(stateIn)) {
return super.postMine(stack, worldIn, stateIn, pos, entityLiving); return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
} }
for (BlockPos additionalPos : ToolsUtil.getAOEMiningBlocks(worldIn, pos, entityLiving, 1)) { for (BlockPos additionalPos : ToolsUtil.getAOEMiningBlocks(worldIn, pos, entityLiving, 1)) {
@ -109,7 +109,7 @@ public class AdvancedJackhammerItem extends JackhammerItem implements MultiBlock
// MultiBlockBreakingTool // MultiBlockBreakingTool
@Override @Override
public Set<BlockPos> getBlocksToBreak(ItemStack stack, World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) { public Set<BlockPos> getBlocksToBreak(ItemStack stack, World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) {
if (!stack.getItem().isEffectiveOn(worldIn.getBlockState(pos))) { if (!stack.getItem().isSuitableFor(worldIn.getBlockState(pos))) {
return Collections.emptySet(); return Collections.emptySet();
} }
return ToolsUtil.getAOEMiningBlocks(worldIn, pos, entityLiving, 1, false) return ToolsUtil.getAOEMiningBlocks(worldIn, pos, entityLiving, 1, false)

View file

@ -60,8 +60,8 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
// PickaxeItem // PickaxeItem
@Override @Override
public boolean isEffectiveOn(BlockState state) { public boolean isSuitableFor(BlockState state) {
return Items.DIAMOND_PICKAXE.isEffectiveOn(state); return Items.DIAMOND_PICKAXE.isSuitableFor(state);
} }
@Override @Override

View file

@ -94,7 +94,7 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
return false; return false;
} }
return (stack.getItem().isEffectiveOn(blockState)); return (stack.getItem().isSuitableFor(blockState));
} }
private boolean isAOE5(ItemStack stack) { private boolean isAOE5(ItemStack stack) {
@ -104,7 +104,7 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
// JackhammerItem // JackhammerItem
@Override @Override
public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) { public boolean postMine(ItemStack stack, World worldIn, BlockState stateIn, BlockPos pos, LivingEntity entityLiving) {
if (!ItemUtils.isActive(stack) || !stack.getItem().isEffectiveOn(stateIn)) { if (!ItemUtils.isActive(stack) || !stack.getItem().isSuitableFor(stateIn)) {
return super.postMine(stack, worldIn, stateIn, pos, entityLiving); return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
} }
int radius = isAOE5(stack) ? 2 : 1; int radius = isAOE5(stack) ? 2 : 1;
@ -160,7 +160,7 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
// MultiBlockBreakingTool // MultiBlockBreakingTool
@Override @Override
public Set<BlockPos> getBlocksToBreak(ItemStack stack, World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) { public Set<BlockPos> getBlocksToBreak(ItemStack stack, World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving) {
if (!stack.getItem().isEffectiveOn(worldIn.getBlockState(pos))) { if (!stack.getItem().isSuitableFor(worldIn.getBlockState(pos))) {
return Collections.emptySet(); return Collections.emptySet();
} }
int radius = isAOE5(stack) ? 2 : 1; int radius = isAOE5(stack) ? 2 : 1;

View file

@ -36,7 +36,7 @@ import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@ -114,16 +114,16 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
return; return;
} }
ItemStack inactiveUncharged = new ItemStack(this); ItemStack inactiveUncharged = new ItemStack(this);
inactiveUncharged.setTag(new CompoundTag()); inactiveUncharged.setTag(new NbtCompound());
inactiveUncharged.getOrCreateTag().putBoolean("isActive", false); inactiveUncharged.getOrCreateTag().putBoolean("isActive", false);
ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER); ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER);
inactiveCharged.setTag(new CompoundTag()); inactiveCharged.setTag(new NbtCompound());
inactiveCharged.getOrCreateTag().putBoolean("isActive", false); inactiveCharged.getOrCreateTag().putBoolean("isActive", false);
Energy.of(inactiveCharged).set(Energy.of(inactiveCharged).getMaxStored()); Energy.of(inactiveCharged).set(Energy.of(inactiveCharged).getMaxStored());
ItemStack activeCharged = new ItemStack(TRContent.NANOSABER); ItemStack activeCharged = new ItemStack(TRContent.NANOSABER);
activeCharged.setTag(new CompoundTag()); activeCharged.setTag(new NbtCompound());
activeCharged.getOrCreateTag().putBoolean("isActive", true); activeCharged.getOrCreateTag().putBoolean("isActive", true);
Energy.of(activeCharged).set(Energy.of(activeCharged).getMaxStored()); Energy.of(activeCharged).set(Energy.of(activeCharged).getMaxStored());

View file

@ -75,10 +75,10 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
// PickaxeItem // PickaxeItem
@Override @Override
public boolean isEffectiveOn(BlockState state) { public boolean isSuitableFor(BlockState state) {
return Items.DIAMOND_AXE.isEffectiveOn(state) || Items.DIAMOND_SWORD.isEffectiveOn(state) return Items.DIAMOND_AXE.isSuitableFor(state) || Items.DIAMOND_SWORD.isSuitableFor(state)
|| Items.DIAMOND_PICKAXE.isEffectiveOn(state) || Items.DIAMOND_SHOVEL.isEffectiveOn(state) || Items.DIAMOND_PICKAXE.isSuitableFor(state) || Items.DIAMOND_SHOVEL.isSuitableFor(state)
|| Items.SHEARS.isEffectiveOn(state); || Items.SHEARS.isSuitableFor(state);
} }
@Override @Override

View file

@ -28,7 +28,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.entity.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.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.multiblock.IMultiblockPart; import reborncore.common.multiblock.IMultiblockPart;
@ -213,7 +213,7 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase {
} }
@Override @Override
public void onAttachedPartWithMultiblockData(IMultiblockPart part, CompoundTag data) { public void onAttachedPartWithMultiblockData(IMultiblockPart part, NbtCompound data) {
} }
@ -302,22 +302,22 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase {
} }
@Override @Override
public void write(CompoundTag data) { public void write(NbtCompound data) {
} }
@Override @Override
public void read(CompoundTag data) { public void read(NbtCompound data) {
} }
@Override @Override
public void formatDescriptionPacket(CompoundTag data) { public void formatDescriptionPacket(NbtCompound data) {
} }
@Override @Override
public void decodeDescriptionPacket(CompoundTag data) { public void decodeDescriptionPacket(NbtCompound data) {
} }

View file

@ -27,8 +27,8 @@ package techreborn.utils;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.AbstractBlock; import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
@ -68,13 +68,13 @@ public class InitUtils {
public static AbstractBlock.Settings setupRubberBlockSettings(boolean noCollision, float hardness, float resistance) { public static AbstractBlock.Settings setupRubberBlockSettings(boolean noCollision, float hardness, float resistance) {
FabricBlockSettings settings = FabricBlockSettings.of(Material.WOOD, MaterialColor.SPRUCE); FabricBlockSettings settings = FabricBlockSettings.of(Material.WOOD, MapColor.SPRUCE_BROWN);
settings.strength(hardness, resistance); settings.strength(hardness, resistance);
settings.sounds(BlockSoundGroup.WOOD); settings.sounds(BlockSoundGroup.WOOD);
if (noCollision) { if (noCollision) {
settings.noCollision(); settings.noCollision();
} }
settings.materialColor(MaterialColor.SPRUCE); settings.materialColor(MapColor.SPRUCE_BROWN);
return settings; return settings;
} }

View file

@ -43,7 +43,7 @@ public class RecipeUtils {
} }
public static boolean matchesSingleInput(Recipe<?> recipe, ItemStack input) { public static boolean matchesSingleInput(Recipe<?> recipe, ItemStack input) {
return recipe.getPreviewInputs().size() == 1 && recipe.getPreviewInputs().get(0).test(input); return recipe.getIngredients().size() == 1 && recipe.getIngredients().get(0).test(input);
} }
/** /**