Moved save logic inside the 1.20 branch, as they don't compile without errors on 1.21

Change hybridizer logic to no longer require a catalyst
fix brachiosaurus_dna.png
Fix flame texture on generator for 1.21
Adds power handling for machines in NF 1.21
Adds power handling to fabric
Actually fix screen registration for Fabric 1.20
This commit is contained in:
2026-05-20 22:56:50 -04:00
parent 40292ae052
commit 05325f6008
35 changed files with 631 additions and 230 deletions
@@ -111,24 +111,6 @@ public class CommonClientClass {
EntityRendererRegistry.register(ModEntities.TROODON, TroodonRenderer::new);
EntityRendererRegistry.register(ModEntities.UTAHRAPTOR, UtahraptorRenderer::new);
//? if <=1.20.1 {
ClientLifecycleEvent.CLIENT_SETUP.register(minecraft -> {
MenuRegistry.registerScreenFactory(ModMenuTypes.GENERATOR_MENU.get(), GeneratorScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_EXTRACTOR_MENU.get(), DNAExtractorScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_ANALYZER_MENU.get(), DNAAnalyzerScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.FOSSIL_GRINDER_MENU.get(), FossilGrinderScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.FOSSIL_CLEANER_MENU.get(), FossilCleanerScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_HYBRIDIZER_MENU.get(), DNAHybridizerScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.EMBRYONIC_MACHINE_MENU.get(), EmbryonicMachineScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.EMBRYO_CALCIFICATION_MACHINE_MENU.get(), EmbryoCalcificationMachineScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.INCUBATOR_MENU.get(), IncubatorScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.TANK_MENU.get(), TankScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.POWER_CELL_MENU.get(), PowerCellScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.WOOD_CRATE_MENU.get(), CrateScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.IRON_CRATE_MENU.get(), CrateScreen::new);
});
//?}
if (Platform.isFabric()) {
registerSpawnEggColors();
registerRenderTypes();
@@ -142,6 +124,24 @@ public class CommonClientClass {
});
}
//? if <=1.20.1 {
public static void registerScreens() {
MenuRegistry.registerScreenFactory(ModMenuTypes.GENERATOR_MENU.get(), GeneratorScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_EXTRACTOR_MENU.get(), DNAExtractorScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_ANALYZER_MENU.get(), DNAAnalyzerScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.FOSSIL_GRINDER_MENU.get(), FossilGrinderScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.FOSSIL_CLEANER_MENU.get(), FossilCleanerScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_HYBRIDIZER_MENU.get(), DNAHybridizerScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.EMBRYONIC_MACHINE_MENU.get(), EmbryonicMachineScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.EMBRYO_CALCIFICATION_MACHINE_MENU.get(), EmbryoCalcificationMachineScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.INCUBATOR_MENU.get(), IncubatorScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.TANK_MENU.get(), TankScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.POWER_CELL_MENU.get(), PowerCellScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.WOOD_CRATE_MENU.get(), CrateScreen::new);
MenuRegistry.registerScreenFactory(ModMenuTypes.IRON_CRATE_MENU.get(), CrateScreen::new);
}
//?}
private static void registerSpawnEggColors() {
ModItems.ITEMS.forEach(itemSupplier -> {
Item item = itemSupplier.get();
@@ -677,7 +677,16 @@ public class ModBlocks {
}
private static <T extends Block> void registerBlockItem(String name, RegistrySupplier<T> block) {
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
ModItems.ITEMS.register(name, () -> {
T blockInstance = block.get();
Item.Properties properties = new Item.Properties();
if (blockInstance instanceof EggBlock || blockInstance instanceof IncubatedEggBlock) {
properties.stacksTo(1);
}
return new BlockItem(blockInstance, properties);
});
}
public static void register() {
@@ -138,7 +138,7 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
tag.putInt("Prog", this.progress);
tag.putInt("MaxProg", this.maxProgress);
tag.put("Energy", energyStorage.saveNBT());
@@ -147,13 +147,42 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
progress = tag.getInt("Prog");
maxProgress = tag.getInt("MaxProg");
if (tag.contains("Energy")) {
energyStorage.loadNBT(tag.getCompound("Energy"));
}
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -138,7 +138,7 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
tag.putInt("Prog", this.progress);
tag.putInt("MaxProg", this.maxProgress);
tag.put("Energy", energyStorage.saveNBT());
@@ -147,13 +147,40 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
progress = tag.getInt("Prog");
maxProgress = tag.getInt("MaxProg");
if (tag.contains("Energy")) {
energyStorage.loadNBT(tag.getCompound("Energy"));
}
}private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -138,16 +138,43 @@ public class DNAHybridizerBlockEntity extends BlockEntity implements ExtendedMen
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
saveCommonData(tag);
}
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
loadCommonData(tag);
}private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -135,16 +135,45 @@ public class EmbryoCalcificationMachineBlockEntity extends BlockEntity implement
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
saveCommonData(tag);
}
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
loadCommonData(tag);
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -139,16 +139,45 @@ public class EmbryonicMachineBlockEntity extends BlockEntity implements Extended
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
saveCommonData(tag);
}
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
loadCommonData(tag);
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -151,7 +151,7 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
tag.putInt("Prog", this.progress);
tag.putInt("MaxProg", this.maxProgress);
tag.put("Energy", energyStorage.saveNBT());
@@ -163,7 +163,7 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
progress = tag.getInt("Prog");
maxProgress = tag.getInt("MaxProg");
if (tag.contains("Energy")) energyStorage.loadNBT(tag.getCompound("Energy"));
@@ -178,6 +178,35 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
fluidStack = FluidStack.empty();
}
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -135,16 +135,45 @@ public class FossilGrinderBlockEntity extends BlockEntity implements ExtendedMen
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
saveCommonData(tag);
}
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
loadCommonData(tag);
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -136,7 +136,7 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro
/*@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.put("Inventory", itemHandler.createTag(registries));
tag.put("Inventory", saveInventory(registries));
tag.putInt("Prog0", this.progress[0]);
tag.putInt("Prog1", this.progress[1]);
tag.putInt("Prog2", this.progress[2]);
@@ -149,7 +149,7 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
loadInventory(tag.getList("Inventory", 10), registries);
if (tag.contains("Energy")) {
energyStorage.loadNBT(tag.getCompound("Energy"));
}
@@ -160,6 +160,35 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro
maxProgress[1] = tag.getInt("Max1");
maxProgress[2] = tag.getInt("Max2");
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag tag) {
@@ -270,7 +270,7 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
/*@Override
protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
super.saveAdditional(pTag, pRegistries);
pTag.put("Inventory", itemHandler.createTag(pRegistries));
pTag.put("Inventory", saveInventory(pRegistries));
if (!fluidStack.isEmpty()) {
pTag.put("Fluid", fluidStack.write(pRegistries, new CompoundTag()));
}
@@ -279,7 +279,7 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
@Override
protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
super.loadAdditional(pTag, pRegistries);
itemHandler.fromTag(pTag.getList("Inventory", 10), pRegistries);
loadInventory(pTag.getList("Inventory", 10), pRegistries);
if (pTag.contains("Fluid", 10)) {
CompoundTag fluidTag = pTag.getCompound("Fluid");
if (fluidTag.contains("id") && fluidTag.contains("amount")) {
@@ -291,6 +291,35 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
this.fluidStack = FluidStack.empty();
}
}
private ListTag saveInventory(HolderLookup.Provider registries) {
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);
listTag.add(stack.save(registries, stackTag));
}
}
return listTag;
}
private void loadInventory(ListTag listTag, HolderLookup.Provider registries) {
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.parseOptional(registries, stackTag));
}
}
}
*///?} else {
@Override
protected void saveAdditional(CompoundTag pTag) {
@@ -25,7 +25,7 @@ public class ModRecipeProvider {
// Custom
void dnaExtracting(ItemLike testTube, ItemLike tissue, ItemLike dna, int count);
void dnaAnalyzing(ItemLike testTube, ItemLike material, ItemLike dna, int count);
void dnaHybridizing(ItemLike result, int count, ItemLike catalyst, ItemLike... ingredients);
void dnaHybridizing(ItemLike result, int count, ItemLike... ingredients);
void embryonicMachine(ItemLike syringe, ItemLike dna, ItemLike catalyst, ItemLike result, int count);
void embryoCalcification(ItemLike syringe, ItemLike egg, ItemLike result, int count);
void incubating(ItemLike egg, ItemLike result, int count);
@@ -345,24 +345,21 @@ public class ModRecipeProvider {
helper.dnaAnalyzing(ModItems.TEST_TUBE.get(), ModItems.FROG_MATERIAL.get(), ModItems.FROG_DNA.get(), 1);
helper.dnaHybridizing(ModItems.INDOMINUS_REX_DNA.get(), 1, ModItems.FROG_DNA.get(),
ModItems.TYRANNOSAURUS_REX_DNA.get(),
ModItems.VELOCIRAPTOR_DNA.get(),
ModItems.CARNOTAURUS_DNA.get(),
ModItems.THERIZINOSAURUS_DNA.get(),
ModItems.MAJUNGASAURUS_DNA.get(),
ModItems.RUGOPS_DNA.get(),
ModItems.GIGANOTOSAURUS_DNA.get());
helper.dnaHybridizing(ModItems.DISTORTUS_REX_DNA.get(), 1, ModItems.FROG_DNA.get(),
ModItems.TYRANNOSAURUS_REX_DNA.get(),
ModItems.BRACHIOSAURUS_DNA.get(),
ModItems.VELOCIRAPTOR_DNA.get());
helper.dnaHybridizing(ModItems.INDORAPTOR_DNA.get(), 1, ModItems.FROG_DNA.get(),
ModItems.INDOMINUS_REX_DNA.get(),
ModItems.VELOCIRAPTOR_DNA.get());
helper.dnaHybridizing(ModItems.INDOMINUS_REX_DNA.get(), 1,
ModItems.TYRANNOSAURUS_REX_DNA.get(),
ModItems.VELOCIRAPTOR_DNA.get(),
ModItems.CARNOTAURUS_DNA.get(),
ModItems.THERIZINOSAURUS_DNA.get(),
ModItems.MAJUNGASAURUS_DNA.get(),
ModItems.RUGOPS_DNA.get(),
ModItems.GIGANOTOSAURUS_DNA.get());
helper.dnaHybridizing(ModItems.DISTORTUS_REX_DNA.get(), 1,
ModItems.TYRANNOSAURUS_REX_DNA.get(),
ModItems.BRACHIOSAURUS_DNA.get(),
ModItems.VELOCIRAPTOR_DNA.get());
helper.dnaHybridizing(ModItems.INDORAPTOR_DNA.get(), 1,
ModItems.INDOMINUS_REX_DNA.get(),
ModItems.VELOCIRAPTOR_DNA.get());
helper.embryonicMachine(ModItems.SYRINGE.get(), ModItems.APATOSAURUS_DNA.get(), ModItems.FROG_DNA.get(), ModItems.APATOSAURUS_SYRINGE.get(), 1);
helper.embryonicMachine(ModItems.SYRINGE.get(), ModItems.ALBERTOSAURUS_DNA.get(), ModItems.FROG_DNA.get(), ModItems.ALBERTOSAURUS_SYRINGE.get(), 1);
@@ -1,5 +1,6 @@
package net.cmr.jurassicrevived.datagen.custom;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.recipe.DNAAnalyzerRecipe;
import net.minecraft.advancements.*;
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
@@ -77,7 +78,7 @@ public class DNAAnalyzingRecipeBuilder {
inputs.add(Ingredient.of(secondItem.orElseThrow()));
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
DNAAnalyzerRecipe recipe = new DNAAnalyzerRecipe(inputs, result, Map.copyOf(this.weights));
DNAAnalyzerRecipe recipe = new DNAAnalyzerRecipe(Constants.rl("dna_analyzer"), inputs, result, Map.copyOf(this.weights));
AdvancementHolder advancementHolder = null;
if (!this.criteria.isEmpty()) {
@@ -1,5 +1,6 @@
package net.cmr.jurassicrevived.datagen.custom;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.recipe.DNAExtractorRecipe;
import net.minecraft.advancements.*;
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
@@ -77,7 +78,7 @@ public class DNAExtractingRecipeBuilder {
inputs.add(Ingredient.of(secondItem.orElseThrow()));
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
DNAExtractorRecipe recipe = new DNAExtractorRecipe(inputs, result, java.util.Map.copyOf(this.weights));
DNAExtractorRecipe recipe = new DNAExtractorRecipe(Constants.rl("dna_extractor"), inputs, result, java.util.Map.copyOf(this.weights));
AdvancementHolder advancementHolder = null;
if (!this.criteria.isEmpty()) {
@@ -1,5 +1,6 @@
package net.cmr.jurassicrevived.datagen.custom;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.recipe.DNAHybridizerRecipe;
import net.minecraft.advancements.*;
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
@@ -38,7 +39,6 @@ public class DNAHybridizingRecipeBuilder {
private final Map<String, InventoryChangeTrigger.TriggerInstance> criteria;
//?}
private final NonNullList<Ingredient> ingredients = NonNullList.create();
private java.util.Optional<ItemLike> catalyst = java.util.Optional.empty();
public DNAHybridizingRecipeBuilder(ItemLike result, int count) {
this.resultItem = java.util.Optional.of(result.asItem());
@@ -51,26 +51,21 @@ public class DNAHybridizingRecipeBuilder {
}
public DNAHybridizingRecipeBuilder addIngredient(ItemLike item) {
if (this.ingredients.size() >= 9) {
throw new IllegalStateException("DNAHybridizer supports at most 9 input ingredients");
if (this.ingredients.size() >= 8) {
throw new IllegalStateException("DNAHybridizer supports at most 8 input ingredients");
}
this.ingredients.add(Ingredient.of(item));
return this;
}
public DNAHybridizingRecipeBuilder addIngredient(Ingredient ingredient) {
if (this.ingredients.size() >= 9) {
throw new IllegalStateException("DNAHybridizer supports at most 9 input ingredients");
if (this.ingredients.size() >= 8) {
throw new IllegalStateException("DNAHybridizer supports at most 8 input ingredients");
}
this.ingredients.add(ingredient);
return this;
}
public DNAHybridizingRecipeBuilder setCatalyst(ItemLike item) {
this.catalyst = java.util.Optional.of(item);
return this;
}
//? if >1.20.1 {
/*public void save(RecipeOutput output) {
ResourceLocation resultKey = BuiltInRegistries.ITEM.getKey(this.resultItem.orElseThrow());
@@ -88,20 +83,9 @@ public class DNAHybridizingRecipeBuilder {
NonNullList<Ingredient> inputs = NonNullList.create();
inputs.addAll(this.ingredients);
if (inputs.size() > 8 && catalyst.isPresent()) {
throw new IllegalStateException("When a catalyst is set, at most 8 regular ingredients are allowed (slot 9 is reserved).");
}
if (catalyst.isPresent()) {
while (inputs.size() < 8) {
inputs.add(Ingredient.EMPTY);
}
inputs.add(Ingredient.of(catalyst.get()));
}
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
DNAHybridizerRecipe recipe = new DNAHybridizerRecipe(inputs, result);
DNAHybridizerRecipe recipe = new DNAHybridizerRecipe(Constants.rl("dna_hybridizer"), inputs, result);
AdvancementHolder advancementHolder = null;
if (!this.criteria.isEmpty()) {
@@ -133,17 +117,6 @@ public class DNAHybridizingRecipeBuilder {
NonNullList<Ingredient> inputs = NonNullList.create();
inputs.addAll(this.ingredients);
if (inputs.size() > 8 && catalyst.isPresent()) {
throw new IllegalStateException("When a catalyst is set, at most 8 regular ingredients are allowed (slot 9 is reserved).");
}
if (catalyst.isPresent()) {
while (inputs.size() < 8) {
inputs.add(Ingredient.EMPTY);
}
inputs.add(Ingredient.of(catalyst.get()));
}
Advancement.Builder advancementBuilder = Advancement.Builder.advancement();
advancementBuilder.parent(new ResourceLocation("recipes/root"))
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(recipeId))
@@ -1,5 +1,6 @@
package net.cmr.jurassicrevived.datagen.custom;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.recipe.EmbryoCalcificationMachineRecipe;
import net.minecraft.advancements.*;
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
@@ -64,7 +65,7 @@ public class EmbryoCalcificationMachiningRecipeBuilder {
inputs.add(Ingredient.of(secondItem.orElseThrow()));
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
EmbryoCalcificationMachineRecipe recipe = new EmbryoCalcificationMachineRecipe(inputs, result);
EmbryoCalcificationMachineRecipe recipe = new EmbryoCalcificationMachineRecipe(Constants.rl("embryo_calcification_machine"), inputs, result);
AdvancementHolder advancementHolder = null;
if (!this.criteria.isEmpty()) {
@@ -14,7 +14,5 @@ public class MixinMinecraft
@Inject(at = @At("TAIL"), method = "<init>")
private void init(CallbackInfo info) {
Constants.LOG.info("This line is printed by an example mod common mixin!");
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
}
}
@@ -101,7 +101,7 @@ public record DNAAnalyzerRecipe(
).forGetter(DNAAnalyzerRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(DNAAnalyzerRecipe::output),
Codec.unboundedMap(ResourceLocation.CODEC, Codec.INT).optionalFieldOf("weights", java.util.Map.of()).forGetter(DNAAnalyzerRecipe::weights)
).apply(inst, DNAAnalyzerRecipe::new));
).apply(inst, (inputs, output, weights) -> new DNAAnalyzerRecipe(Constants.rl("dna_analyzer"), inputs, output, weights)));
public static final StreamCodec<RegistryFriendlyByteBuf, DNAAnalyzerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, r) -> {
@@ -114,7 +114,13 @@ public record DNAAnalyzerRecipe(
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new DNAAnalyzerRecipe(ins, ItemStack.STREAM_CODEC.decode(buf), buf.readMap(m -> new java.util.HashMap<>(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT));
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
java.util.Map<ResourceLocation, Integer> weights = buf.readMap(
java.util.HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new DNAAnalyzerRecipe(Constants.rl("dna_analyzer"), ins, output, weights);
}
);
@@ -108,7 +108,7 @@ public record DNAExtractorRecipe(
).forGetter(DNAExtractorRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(DNAExtractorRecipe::output),
Codec.unboundedMap(ResourceLocation.CODEC, Codec.INT).optionalFieldOf("weights", java.util.Map.of()).forGetter(DNAExtractorRecipe::weights)
).apply(inst, DNAExtractorRecipe::new));
).apply(inst, (inputs, output, weights) -> new DNAExtractorRecipe(Constants.rl("dna_extractor"), inputs, output, weights)));
public static final StreamCodec<RegistryFriendlyByteBuf, DNAExtractorRecipe> STREAM_CODEC = StreamCodec.of(
(buf, r) -> {
@@ -121,7 +121,13 @@ public record DNAExtractorRecipe(
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new DNAExtractorRecipe(ins, ItemStack.STREAM_CODEC.decode(buf), buf.readMap(m -> new java.util.HashMap<>(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT));
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
java.util.Map<ResourceLocation, Integer> weights = buf.readMap(
java.util.HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new DNAExtractorRecipe(Constants.rl("dna_extractor"), ins, output, weights);
}
);
@Override public MapCodec<DNAExtractorRecipe> codec() { return CODEC; }
@@ -94,7 +94,7 @@ public record DNAHybridizerRecipe(ResourceLocation id, NonNullList<Ingredient> i
l -> DataResult.success(List.copyOf(l))
).forGetter(DNAHybridizerRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(DNAHybridizerRecipe::output)
).apply(inst, DNAHybridizerRecipe::new));
).apply(inst, (inputs, output) -> new DNAHybridizerRecipe(Constants.rl("dna_hybridizer"), inputs, output)));
public static final StreamCodec<RegistryFriendlyByteBuf, DNAHybridizerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, r) -> {
@@ -106,7 +106,8 @@ public record DNAHybridizerRecipe(ResourceLocation id, NonNullList<Ingredient> i
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new DNAHybridizerRecipe(ins, ItemStack.STREAM_CODEC.decode(buf));
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
return new DNAHybridizerRecipe(Constants.rl("dna_hybridizer"), ins, output);
}
);
@Override public MapCodec<DNAHybridizerRecipe> codec() { return CODEC; }
@@ -68,7 +68,7 @@ public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<
list -> DataResult.success(List.copyOf(list))
).forGetter(EmbryoCalcificationMachineRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(EmbryoCalcificationMachineRecipe::output)
).apply(instance, EmbryoCalcificationMachineRecipe::new));
).apply(instance, (inputs, output) -> new EmbryoCalcificationMachineRecipe(Constants.rl("embryo_calcification_machine"), inputs, output)));
public static final StreamCodec<RegistryFriendlyByteBuf, EmbryoCalcificationMachineRecipe> STREAM_CODEC = StreamCodec.of(
(buf, recipe) -> {
@@ -80,7 +80,7 @@ public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new EmbryoCalcificationMachineRecipe(ins, ItemStack.STREAM_CODEC.decode(buf));
return new EmbryoCalcificationMachineRecipe(Constants.rl("embryo_calcification_machine"), ins, ItemStack.STREAM_CODEC.decode(buf));
}
);
@Override public MapCodec<EmbryoCalcificationMachineRecipe> codec() { return CODEC; }
@@ -150,7 +150,11 @@ public class EmbryonicMachineRecipe implements Recipe<EmbryonicMachineRecipeInpu
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
Map<ResourceLocation, Integer> weights = buf.readMap(
HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new EmbryonicMachineRecipe(inputs, output, weights);
}
);
@@ -171,23 +171,27 @@ public class FossilCleanerRecipe implements Recipe<FossilCleanerRecipeInput> {
WEIGHTS_CODEC.optionalFieldOf("fossil_weights", Map.of()).forGetter(FossilCleanerRecipe::weights)
).apply(inst, FossilCleanerRecipe::new));
public static final StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, recipe) -> {
ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).encode(buf, recipe.inputs());
ItemStack.STREAM_CODEC.encode(buf, recipe.output());
buf.writeMap(recipe.weights(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
},
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
return new FossilCleanerRecipe(inputs, output, weights);
}
);
public static final StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, recipe) -> {
ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).encode(buf, recipe.inputs());
ItemStack.STREAM_CODEC.encode(buf, recipe.output());
buf.writeMap(recipe.weights(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
},
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(
HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new FossilCleanerRecipe(inputs, output, weights);
}
);
@Override public MapCodec<FossilCleanerRecipe> codec() { return CODEC; }
@Override public StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> streamCodec() { return STREAM_CODEC; }
*///?} else {
@Override public MapCodec<FossilCleanerRecipe> codec() { return CODEC; }
@Override public StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> streamCodec() { return STREAM_CODEC; }
*///?} else {
@Override
public FossilCleanerRecipe fromJson(ResourceLocation id, JsonObject json) {
ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"));
@@ -174,7 +174,11 @@ public class FossilGrinderRecipe implements Recipe<FossilGrinderRecipeInput> {
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
Map<ResourceLocation, Integer> weights = buf.readMap(
HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new FossilGrinderRecipe(inputs, output, weights);
}
);
@@ -67,15 +67,7 @@ public class GeneratorScreen extends AbstractContainerScreen<GeneratorMenu> {
renderFuelBurning(guiGraphics, x, y);
}
//? if >1.20.1 {
/*private void renderFuelBurning(GuiGraphics guiGraphics, int x, int y) {
if(this.menu.isBurning()) {
int l = Mth.ceil(this.menu.getFuelProgress() * 13.0F) + 1;
guiGraphics.blitSprite(LIT_PROGRESS_TEXTURE, 14, 14, 0, 14 - l,
x + 80, y + 18 + 14 - l, 14, l);
}
}
*///?} else {
private void renderFuelBurning(GuiGraphics guiGraphics, int x, int y) {
if (this.menu.isBurning()) {
float progress = Mth.clamp(this.menu.getFuelProgress(), 0.0F, 1.0F);
@@ -95,7 +87,6 @@ public class GeneratorScreen extends AbstractContainerScreen<GeneratorMenu> {
guiGraphics.blit(LIT_PROGRESS_TEXTURE, destX, destY, srcU, srcV, width, height, texW, texH);
}
}
//?}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
@@ -75,9 +75,23 @@ public class TankScreen extends AbstractContainerScreen<TankMenu> {
renderBackground(guiGraphics);
//?}
super.render(guiGraphics, mouseX, mouseY, delta);
int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2;
if (MouseUtil.isMouseOver(mouseX, mouseY, x + 80, y + 8, fluidRenderer.getWidth(), fluidRenderer.getHeight())) {
renderHoverHighlight(guiGraphics, x + 80, y + 8, fluidRenderer.getWidth(), fluidRenderer.getHeight());
}
renderTooltip(guiGraphics, mouseX, mouseY);
}
private static void renderHoverHighlight(GuiGraphics guiGraphics, int x, int y, int width, int height) {
guiGraphics.pose().pushPose();
guiGraphics.pose().translate(0, 0, 200);
guiGraphics.fillGradient(x, y, x + width, y + height, 0x80FFFFFF, 0x80FFFFFF);
guiGraphics.pose().popPose();
}
public static boolean isMouseAboveArea(int pMouseX, int pMouseY, int x, int y, int offsetX, int offsetY, FluidTankRenderer renderer) {
return MouseUtil.isMouseOver(pMouseX, pMouseY, x + offsetX, y + offsetY, renderer.getWidth(), renderer.getHeight());
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 B

After

Width:  |  Height:  |  Size: 831 B