Fix Forge 1.20.1 datagen with extra shapeless method removal

Fix generator gui flame texture by actually adding the texture and referencing it on the screen
Fix generator placement, as its placement is 180 degrees to whats expected
Changed save method for all machines in 1.20.1 to fix item placement
This commit is contained in:
2026-05-20 18:04:08 -04:00
parent 3cb4714f7a
commit d2c5ca9e21
12 changed files with 258 additions and 28 deletions
@@ -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
@@ -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;
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -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;
@@ -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);
@@ -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;
@@ -18,7 +18,7 @@ public class GeneratorScreen extends AbstractContainerScreen<GeneratorMenu> {
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) {
Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

@@ -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);