diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/custom/GeneratorBlock.java b/common/src/main/java/net/cmr/jurassicrevived/block/custom/GeneratorBlock.java index 14e0717..384acd5 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/custom/GeneratorBlock.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/custom/GeneratorBlock.java @@ -93,7 +93,7 @@ public class GeneratorBlock extends BaseEntityBlock { @Override public @Nullable BlockState getStateForPlacement(BlockPlaceContext context) { - return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(LIT, false); + return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite().getOpposite()).setValue(LIT, false); } @Override diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAAnalyzerBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAAnalyzerBlockEntity.java index 787c202..50d37f7 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAAnalyzerBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAAnalyzerBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -157,7 +158,7 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); tag.put("Energy", energyStorage.saveNBT()); @@ -166,7 +167,7 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); progress = tag.getInt("Prog"); maxProgress = tag.getInt("MaxProg"); if (tag.contains("Energy")) { @@ -175,6 +176,35 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + public void tick(Level level, BlockPos pos, BlockState state) { if (level.isClientSide) return; diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAExtractorBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAExtractorBlockEntity.java index 4e63d64..4ad31f9 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAExtractorBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAExtractorBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -157,7 +158,7 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); tag.put("Energy", energyStorage.saveNBT()); @@ -166,7 +167,7 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); progress = tag.getInt("Prog"); maxProgress = tag.getInt("MaxProg"); if (tag.contains("Energy")) { @@ -175,6 +176,35 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + public void tick(Level level, BlockPos pos, BlockState state) { if (level.isClientSide) return; diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAHybridizerBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAHybridizerBlockEntity.java index d33a169..eb46e63 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAHybridizerBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/DNAHybridizerBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -151,18 +152,47 @@ public class DNAHybridizerBlockEntity extends BlockEntity implements ExtendedMen @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); saveCommonData(tag); } @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); loadCommonData(tag); } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + private void saveCommonData(CompoundTag tag) { tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryoCalcificationMachineBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryoCalcificationMachineBlockEntity.java index 340aed5..7d5f337 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryoCalcificationMachineBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryoCalcificationMachineBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -148,18 +149,47 @@ public class EmbryoCalcificationMachineBlockEntity extends BlockEntity implement @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); saveCommonData(tag); } @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); loadCommonData(tag); } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + private void saveCommonData(CompoundTag tag) { tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryonicMachineBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryonicMachineBlockEntity.java index 6881328..2341509 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryonicMachineBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/EmbryonicMachineBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -152,18 +153,47 @@ public class EmbryonicMachineBlockEntity extends BlockEntity implements Extended @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); saveCommonData(tag); } @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); loadCommonData(tag); } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + private void saveCommonData(CompoundTag tag) { tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilCleanerBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilCleanerBlockEntity.java index ebd7a4f..c95c466 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilCleanerBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilCleanerBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -181,7 +182,7 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); tag.put("Energy", energyStorage.saveNBT()); @@ -193,7 +194,7 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); progress = tag.getInt("Prog"); maxProgress = tag.getInt("MaxProg"); if (tag.contains("Energy")) energyStorage.loadNBT(tag.getCompound("Energy")); @@ -201,6 +202,35 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + public void tick(Level level, BlockPos pos, BlockState state) { if (level.isClientSide) return; diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilGrinderBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilGrinderBlockEntity.java index 7b7c4de..d1f64ea 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilGrinderBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/FossilGrinderBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -148,18 +149,47 @@ public class FossilGrinderBlockEntity extends BlockEntity implements ExtendedMen @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); saveCommonData(tag); } @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); loadCommonData(tag); } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + private void saveCommonData(CompoundTag tag) { tag.putInt("Prog", this.progress); tag.putInt("MaxProg", this.maxProgress); diff --git a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/IncubatorBlockEntity.java b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/IncubatorBlockEntity.java index 216d079..7f398f3 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/IncubatorBlockEntity.java +++ b/common/src/main/java/net/cmr/jurassicrevived/block/entity/custom/IncubatorBlockEntity.java @@ -12,6 +12,7 @@ import net.cmr.jurassicrevived.screen.custom.IncubatorMenu; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; @@ -163,7 +164,7 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - tag.put("Inventory", itemHandler.createTag()); + tag.put("Inventory", saveInventory()); tag.putInt("Prog0", this.progress[0]); tag.putInt("Prog1", this.progress[1]); tag.putInt("Prog2", this.progress[2]); @@ -176,7 +177,7 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro @Override public void load(CompoundTag tag) { super.load(tag); - itemHandler.fromTag(tag.getList("Inventory", 10)); + loadInventory(tag.getList("Inventory", 10)); if (tag.contains("Energy")) { energyStorage.loadNBT(tag.getCompound("Energy")); } @@ -189,6 +190,35 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro } //?} + private ListTag saveInventory() { + ListTag listTag = new ListTag(); + + for (int slot = 0; slot < itemHandler.getContainerSize(); slot++) { + ItemStack stack = itemHandler.getItem(slot); + if (!stack.isEmpty()) { + CompoundTag stackTag = new CompoundTag(); + stackTag.putByte("Slot", (byte) slot); + stack.save(stackTag); + listTag.add(stackTag); + } + } + + return listTag; + } + + private void loadInventory(ListTag listTag) { + itemHandler.clearContent(); + + for (int i = 0; i < listTag.size(); i++) { + CompoundTag stackTag = listTag.getCompound(i); + int slot = stackTag.getByte("Slot") & 255; + + if (slot >= 0 && slot < itemHandler.getContainerSize()) { + itemHandler.setItem(slot, ItemStack.of(stackTag)); + } + } + } + public void tick(Level level, BlockPos pos, BlockState state) { if (level.isClientSide) return; diff --git a/common/src/main/java/net/cmr/jurassicrevived/screen/custom/GeneratorScreen.java b/common/src/main/java/net/cmr/jurassicrevived/screen/custom/GeneratorScreen.java index b4cbc22..ee8f331 100644 --- a/common/src/main/java/net/cmr/jurassicrevived/screen/custom/GeneratorScreen.java +++ b/common/src/main/java/net/cmr/jurassicrevived/screen/custom/GeneratorScreen.java @@ -18,7 +18,7 @@ public class GeneratorScreen extends AbstractContainerScreen { private static final ResourceLocation GUI_TEXTURE = Constants.rl("textures/gui/generator/generator_gui.png"); private static final ResourceLocation LIT_PROGRESS_TEXTURE = - Constants.rl("container/furnace/lit_progress"); + Constants.rl("textures/gui/generator/lit_progress.png"); private EnergyDisplayTooltipArea energyInfoArea; public GeneratorScreen(GeneratorMenu pMenu, Inventory pPlayerInventory, Component pTitle) { diff --git a/common/src/main/resources/assets/jurassicrevived/textures/gui/generator/lit_progress.png b/common/src/main/resources/assets/jurassicrevived/textures/gui/generator/lit_progress.png new file mode 100644 index 0000000..aa48b4b Binary files /dev/null and b/common/src/main/resources/assets/jurassicrevived/textures/gui/generator/lit_progress.png differ diff --git a/minecraftforge/src/main/java/net/cmr/jurassicrevived/datagen/ForgeRecipeProvider.java b/minecraftforge/src/main/java/net/cmr/jurassicrevived/datagen/ForgeRecipeProvider.java index afa434a..fccedb1 100755 --- a/minecraftforge/src/main/java/net/cmr/jurassicrevived/datagen/ForgeRecipeProvider.java +++ b/minecraftforge/src/main/java/net/cmr/jurassicrevived/datagen/ForgeRecipeProvider.java @@ -55,16 +55,6 @@ public class ForgeRecipeProvider extends RecipeProvider implements ModRecipeProv builder.save(output); } - @Override - public void buildShapeless(RecipeCategory category, ItemLike result, int count, ItemLike... ingredients) { - ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(category, result, count); - for (ItemLike ingredient : ingredients) { - builder.requires(ingredient); - } - builder.unlockedBy("has_item", has(result)); - builder.save(output); - } - @Override public void buildShapeless(RecipeCategory category, ItemLike result, int count, String name, ItemLike... ingredients) { ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(category, result, count);