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:
@@ -111,8 +111,21 @@ public class CommonClientClass {
|
|||||||
EntityRendererRegistry.register(ModEntities.TROODON, TroodonRenderer::new);
|
EntityRendererRegistry.register(ModEntities.TROODON, TroodonRenderer::new);
|
||||||
EntityRendererRegistry.register(ModEntities.UTAHRAPTOR, UtahraptorRenderer::new);
|
EntityRendererRegistry.register(ModEntities.UTAHRAPTOR, UtahraptorRenderer::new);
|
||||||
|
|
||||||
|
if (Platform.isFabric()) {
|
||||||
|
registerSpawnEggColors();
|
||||||
|
registerRenderTypes();
|
||||||
|
} else {
|
||||||
|
ClientLifecycleEvent.CLIENT_SETUP.register(mc -> registerSpawnEggColors());
|
||||||
|
ClientLifecycleEvent.CLIENT_SETUP.register(mc -> registerRenderTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
LifecycleEvent.SETUP.register(() -> {
|
||||||
|
BlockEntityRendererRegistry.register(ModBlockEntities.TANK_BE.get(), TankBlockEntityRenderer::new);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//? if <=1.20.1 {
|
//? if <=1.20.1 {
|
||||||
ClientLifecycleEvent.CLIENT_SETUP.register(minecraft -> {
|
public static void registerScreens() {
|
||||||
MenuRegistry.registerScreenFactory(ModMenuTypes.GENERATOR_MENU.get(), GeneratorScreen::new);
|
MenuRegistry.registerScreenFactory(ModMenuTypes.GENERATOR_MENU.get(), GeneratorScreen::new);
|
||||||
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_EXTRACTOR_MENU.get(), DNAExtractorScreen::new);
|
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_EXTRACTOR_MENU.get(), DNAExtractorScreen::new);
|
||||||
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_ANALYZER_MENU.get(), DNAAnalyzerScreen::new);
|
MenuRegistry.registerScreenFactory(ModMenuTypes.DNA_ANALYZER_MENU.get(), DNAAnalyzerScreen::new);
|
||||||
@@ -126,22 +139,9 @@ public class CommonClientClass {
|
|||||||
MenuRegistry.registerScreenFactory(ModMenuTypes.POWER_CELL_MENU.get(), PowerCellScreen::new);
|
MenuRegistry.registerScreenFactory(ModMenuTypes.POWER_CELL_MENU.get(), PowerCellScreen::new);
|
||||||
MenuRegistry.registerScreenFactory(ModMenuTypes.WOOD_CRATE_MENU.get(), CrateScreen::new);
|
MenuRegistry.registerScreenFactory(ModMenuTypes.WOOD_CRATE_MENU.get(), CrateScreen::new);
|
||||||
MenuRegistry.registerScreenFactory(ModMenuTypes.IRON_CRATE_MENU.get(), CrateScreen::new);
|
MenuRegistry.registerScreenFactory(ModMenuTypes.IRON_CRATE_MENU.get(), CrateScreen::new);
|
||||||
});
|
}
|
||||||
//?}
|
//?}
|
||||||
|
|
||||||
if (Platform.isFabric()) {
|
|
||||||
registerSpawnEggColors();
|
|
||||||
registerRenderTypes();
|
|
||||||
} else {
|
|
||||||
ClientLifecycleEvent.CLIENT_SETUP.register(mc -> registerSpawnEggColors());
|
|
||||||
ClientLifecycleEvent.CLIENT_SETUP.register(mc -> registerRenderTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
LifecycleEvent.SETUP.register(() -> {
|
|
||||||
BlockEntityRendererRegistry.register(ModBlockEntities.TANK_BE.get(), TankBlockEntityRenderer::new);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void registerSpawnEggColors() {
|
private static void registerSpawnEggColors() {
|
||||||
ModItems.ITEMS.forEach(itemSupplier -> {
|
ModItems.ITEMS.forEach(itemSupplier -> {
|
||||||
Item item = itemSupplier.get();
|
Item item = itemSupplier.get();
|
||||||
|
|||||||
@@ -677,7 +677,16 @@ public class ModBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends Block> void registerBlockItem(String name, RegistrySupplier<T> block) {
|
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() {
|
public static void register() {
|
||||||
|
|||||||
+31
-2
@@ -138,7 +138,7 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
tag.putInt("Prog", this.progress);
|
tag.putInt("Prog", this.progress);
|
||||||
tag.putInt("MaxProg", this.maxProgress);
|
tag.putInt("MaxProg", this.maxProgress);
|
||||||
tag.put("Energy", energyStorage.saveNBT());
|
tag.put("Energy", energyStorage.saveNBT());
|
||||||
@@ -147,13 +147,42 @@ public class DNAAnalyzerBlockEntity extends BlockEntity implements ExtendedMenuP
|
|||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
progress = tag.getInt("Prog");
|
progress = tag.getInt("Prog");
|
||||||
maxProgress = tag.getInt("MaxProg");
|
maxProgress = tag.getInt("MaxProg");
|
||||||
if (tag.contains("Energy")) {
|
if (tag.contains("Energy")) {
|
||||||
energyStorage.loadNBT(tag.getCompound("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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+29
-2
@@ -138,7 +138,7 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
tag.putInt("Prog", this.progress);
|
tag.putInt("Prog", this.progress);
|
||||||
tag.putInt("MaxProg", this.maxProgress);
|
tag.putInt("MaxProg", this.maxProgress);
|
||||||
tag.put("Energy", energyStorage.saveNBT());
|
tag.put("Energy", energyStorage.saveNBT());
|
||||||
@@ -147,13 +147,40 @@ public class DNAExtractorBlockEntity extends BlockEntity implements ExtendedMenu
|
|||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
progress = tag.getInt("Prog");
|
progress = tag.getInt("Prog");
|
||||||
maxProgress = tag.getInt("MaxProg");
|
maxProgress = tag.getInt("MaxProg");
|
||||||
if (tag.contains("Energy")) {
|
if (tag.contains("Energy")) {
|
||||||
energyStorage.loadNBT(tag.getCompound("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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+29
-2
@@ -138,16 +138,43 @@ public class DNAHybridizerBlockEntity extends BlockEntity implements ExtendedMen
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
saveCommonData(tag);
|
saveCommonData(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
loadCommonData(tag);
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+31
-2
@@ -135,16 +135,45 @@ public class EmbryoCalcificationMachineBlockEntity extends BlockEntity implement
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
saveCommonData(tag);
|
saveCommonData(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
loadCommonData(tag);
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+31
-2
@@ -139,16 +139,45 @@ public class EmbryonicMachineBlockEntity extends BlockEntity implements Extended
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
saveCommonData(tag);
|
saveCommonData(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
loadCommonData(tag);
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+31
-2
@@ -151,7 +151,7 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
tag.putInt("Prog", this.progress);
|
tag.putInt("Prog", this.progress);
|
||||||
tag.putInt("MaxProg", this.maxProgress);
|
tag.putInt("MaxProg", this.maxProgress);
|
||||||
tag.put("Energy", energyStorage.saveNBT());
|
tag.put("Energy", energyStorage.saveNBT());
|
||||||
@@ -163,7 +163,7 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
|
|||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
progress = tag.getInt("Prog");
|
progress = tag.getInt("Prog");
|
||||||
maxProgress = tag.getInt("MaxProg");
|
maxProgress = tag.getInt("MaxProg");
|
||||||
if (tag.contains("Energy")) energyStorage.loadNBT(tag.getCompound("Energy"));
|
if (tag.contains("Energy")) energyStorage.loadNBT(tag.getCompound("Energy"));
|
||||||
@@ -178,6 +178,35 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
|
|||||||
fluidStack = FluidStack.empty();
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+31
-2
@@ -135,16 +135,45 @@ public class FossilGrinderBlockEntity extends BlockEntity implements ExtendedMen
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
saveCommonData(tag);
|
saveCommonData(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
loadCommonData(tag);
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+31
-2
@@ -136,7 +136,7 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
tag.put("Inventory", itemHandler.createTag(registries));
|
tag.put("Inventory", saveInventory(registries));
|
||||||
tag.putInt("Prog0", this.progress[0]);
|
tag.putInt("Prog0", this.progress[0]);
|
||||||
tag.putInt("Prog1", this.progress[1]);
|
tag.putInt("Prog1", this.progress[1]);
|
||||||
tag.putInt("Prog2", this.progress[2]);
|
tag.putInt("Prog2", this.progress[2]);
|
||||||
@@ -149,7 +149,7 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro
|
|||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, registries);
|
||||||
itemHandler.fromTag(tag.getList("Inventory", 10), registries);
|
loadInventory(tag.getList("Inventory", 10), registries);
|
||||||
if (tag.contains("Energy")) {
|
if (tag.contains("Energy")) {
|
||||||
energyStorage.loadNBT(tag.getCompound("Energy"));
|
energyStorage.loadNBT(tag.getCompound("Energy"));
|
||||||
}
|
}
|
||||||
@@ -160,6 +160,35 @@ public class IncubatorBlockEntity extends BlockEntity implements ExtendedMenuPro
|
|||||||
maxProgress[1] = tag.getInt("Max1");
|
maxProgress[1] = tag.getInt("Max1");
|
||||||
maxProgress[2] = tag.getInt("Max2");
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
|||||||
+31
-2
@@ -270,7 +270,7 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
|
|||||||
/*@Override
|
/*@Override
|
||||||
protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
|
protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
|
||||||
super.saveAdditional(pTag, pRegistries);
|
super.saveAdditional(pTag, pRegistries);
|
||||||
pTag.put("Inventory", itemHandler.createTag(pRegistries));
|
pTag.put("Inventory", saveInventory(pRegistries));
|
||||||
if (!fluidStack.isEmpty()) {
|
if (!fluidStack.isEmpty()) {
|
||||||
pTag.put("Fluid", fluidStack.write(pRegistries, new CompoundTag()));
|
pTag.put("Fluid", fluidStack.write(pRegistries, new CompoundTag()));
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
|
|||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
|
protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
|
||||||
super.loadAdditional(pTag, pRegistries);
|
super.loadAdditional(pTag, pRegistries);
|
||||||
itemHandler.fromTag(pTag.getList("Inventory", 10), pRegistries);
|
loadInventory(pTag.getList("Inventory", 10), pRegistries);
|
||||||
if (pTag.contains("Fluid", 10)) {
|
if (pTag.contains("Fluid", 10)) {
|
||||||
CompoundTag fluidTag = pTag.getCompound("Fluid");
|
CompoundTag fluidTag = pTag.getCompound("Fluid");
|
||||||
if (fluidTag.contains("id") && fluidTag.contains("amount")) {
|
if (fluidTag.contains("id") && fluidTag.contains("amount")) {
|
||||||
@@ -291,6 +291,35 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
|
|||||||
this.fluidStack = FluidStack.empty();
|
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 {
|
*///?} else {
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag pTag) {
|
protected void saveAdditional(CompoundTag pTag) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class ModRecipeProvider {
|
|||||||
// Custom
|
// Custom
|
||||||
void dnaExtracting(ItemLike testTube, ItemLike tissue, ItemLike dna, int count);
|
void dnaExtracting(ItemLike testTube, ItemLike tissue, ItemLike dna, int count);
|
||||||
void dnaAnalyzing(ItemLike testTube, ItemLike material, 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 embryonicMachine(ItemLike syringe, ItemLike dna, ItemLike catalyst, ItemLike result, int count);
|
||||||
void embryoCalcification(ItemLike syringe, ItemLike egg, ItemLike result, int count);
|
void embryoCalcification(ItemLike syringe, ItemLike egg, ItemLike result, int count);
|
||||||
void incubating(ItemLike egg, ItemLike result, int count);
|
void incubating(ItemLike egg, ItemLike result, int count);
|
||||||
@@ -345,8 +345,7 @@ public class ModRecipeProvider {
|
|||||||
|
|
||||||
helper.dnaAnalyzing(ModItems.TEST_TUBE.get(), ModItems.FROG_MATERIAL.get(), ModItems.FROG_DNA.get(), 1);
|
helper.dnaAnalyzing(ModItems.TEST_TUBE.get(), ModItems.FROG_MATERIAL.get(), ModItems.FROG_DNA.get(), 1);
|
||||||
|
|
||||||
|
helper.dnaHybridizing(ModItems.INDOMINUS_REX_DNA.get(), 1,
|
||||||
helper.dnaHybridizing(ModItems.INDOMINUS_REX_DNA.get(), 1, ModItems.FROG_DNA.get(),
|
|
||||||
ModItems.TYRANNOSAURUS_REX_DNA.get(),
|
ModItems.TYRANNOSAURUS_REX_DNA.get(),
|
||||||
ModItems.VELOCIRAPTOR_DNA.get(),
|
ModItems.VELOCIRAPTOR_DNA.get(),
|
||||||
ModItems.CARNOTAURUS_DNA.get(),
|
ModItems.CARNOTAURUS_DNA.get(),
|
||||||
@@ -354,13 +353,11 @@ public class ModRecipeProvider {
|
|||||||
ModItems.MAJUNGASAURUS_DNA.get(),
|
ModItems.MAJUNGASAURUS_DNA.get(),
|
||||||
ModItems.RUGOPS_DNA.get(),
|
ModItems.RUGOPS_DNA.get(),
|
||||||
ModItems.GIGANOTOSAURUS_DNA.get());
|
ModItems.GIGANOTOSAURUS_DNA.get());
|
||||||
|
helper.dnaHybridizing(ModItems.DISTORTUS_REX_DNA.get(), 1,
|
||||||
helper.dnaHybridizing(ModItems.DISTORTUS_REX_DNA.get(), 1, ModItems.FROG_DNA.get(),
|
|
||||||
ModItems.TYRANNOSAURUS_REX_DNA.get(),
|
ModItems.TYRANNOSAURUS_REX_DNA.get(),
|
||||||
ModItems.BRACHIOSAURUS_DNA.get(),
|
ModItems.BRACHIOSAURUS_DNA.get(),
|
||||||
ModItems.VELOCIRAPTOR_DNA.get());
|
ModItems.VELOCIRAPTOR_DNA.get());
|
||||||
|
helper.dnaHybridizing(ModItems.INDORAPTOR_DNA.get(), 1,
|
||||||
helper.dnaHybridizing(ModItems.INDORAPTOR_DNA.get(), 1, ModItems.FROG_DNA.get(),
|
|
||||||
ModItems.INDOMINUS_REX_DNA.get(),
|
ModItems.INDOMINUS_REX_DNA.get(),
|
||||||
ModItems.VELOCIRAPTOR_DNA.get());
|
ModItems.VELOCIRAPTOR_DNA.get());
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
package net.cmr.jurassicrevived.datagen.custom;
|
package net.cmr.jurassicrevived.datagen.custom;
|
||||||
|
|
||||||
|
import net.cmr.jurassicrevived.Constants;
|
||||||
import net.cmr.jurassicrevived.recipe.DNAAnalyzerRecipe;
|
import net.cmr.jurassicrevived.recipe.DNAAnalyzerRecipe;
|
||||||
import net.minecraft.advancements.*;
|
import net.minecraft.advancements.*;
|
||||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
||||||
@@ -77,7 +78,7 @@ public class DNAAnalyzingRecipeBuilder {
|
|||||||
inputs.add(Ingredient.of(secondItem.orElseThrow()));
|
inputs.add(Ingredient.of(secondItem.orElseThrow()));
|
||||||
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
|
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;
|
AdvancementHolder advancementHolder = null;
|
||||||
if (!this.criteria.isEmpty()) {
|
if (!this.criteria.isEmpty()) {
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
package net.cmr.jurassicrevived.datagen.custom;
|
package net.cmr.jurassicrevived.datagen.custom;
|
||||||
|
|
||||||
|
import net.cmr.jurassicrevived.Constants;
|
||||||
import net.cmr.jurassicrevived.recipe.DNAExtractorRecipe;
|
import net.cmr.jurassicrevived.recipe.DNAExtractorRecipe;
|
||||||
import net.minecraft.advancements.*;
|
import net.minecraft.advancements.*;
|
||||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
||||||
@@ -77,7 +78,7 @@ public class DNAExtractingRecipeBuilder {
|
|||||||
inputs.add(Ingredient.of(secondItem.orElseThrow()));
|
inputs.add(Ingredient.of(secondItem.orElseThrow()));
|
||||||
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
|
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;
|
AdvancementHolder advancementHolder = null;
|
||||||
if (!this.criteria.isEmpty()) {
|
if (!this.criteria.isEmpty()) {
|
||||||
|
|||||||
+6
-33
@@ -1,5 +1,6 @@
|
|||||||
package net.cmr.jurassicrevived.datagen.custom;
|
package net.cmr.jurassicrevived.datagen.custom;
|
||||||
|
|
||||||
|
import net.cmr.jurassicrevived.Constants;
|
||||||
import net.cmr.jurassicrevived.recipe.DNAHybridizerRecipe;
|
import net.cmr.jurassicrevived.recipe.DNAHybridizerRecipe;
|
||||||
import net.minecraft.advancements.*;
|
import net.minecraft.advancements.*;
|
||||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
||||||
@@ -38,7 +39,6 @@ public class DNAHybridizingRecipeBuilder {
|
|||||||
private final Map<String, InventoryChangeTrigger.TriggerInstance> criteria;
|
private final Map<String, InventoryChangeTrigger.TriggerInstance> criteria;
|
||||||
//?}
|
//?}
|
||||||
private final NonNullList<Ingredient> ingredients = NonNullList.create();
|
private final NonNullList<Ingredient> ingredients = NonNullList.create();
|
||||||
private java.util.Optional<ItemLike> catalyst = java.util.Optional.empty();
|
|
||||||
|
|
||||||
public DNAHybridizingRecipeBuilder(ItemLike result, int count) {
|
public DNAHybridizingRecipeBuilder(ItemLike result, int count) {
|
||||||
this.resultItem = java.util.Optional.of(result.asItem());
|
this.resultItem = java.util.Optional.of(result.asItem());
|
||||||
@@ -51,26 +51,21 @@ public class DNAHybridizingRecipeBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DNAHybridizingRecipeBuilder addIngredient(ItemLike item) {
|
public DNAHybridizingRecipeBuilder addIngredient(ItemLike item) {
|
||||||
if (this.ingredients.size() >= 9) {
|
if (this.ingredients.size() >= 8) {
|
||||||
throw new IllegalStateException("DNAHybridizer supports at most 9 input ingredients");
|
throw new IllegalStateException("DNAHybridizer supports at most 8 input ingredients");
|
||||||
}
|
}
|
||||||
this.ingredients.add(Ingredient.of(item));
|
this.ingredients.add(Ingredient.of(item));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DNAHybridizingRecipeBuilder addIngredient(Ingredient ingredient) {
|
public DNAHybridizingRecipeBuilder addIngredient(Ingredient ingredient) {
|
||||||
if (this.ingredients.size() >= 9) {
|
if (this.ingredients.size() >= 8) {
|
||||||
throw new IllegalStateException("DNAHybridizer supports at most 9 input ingredients");
|
throw new IllegalStateException("DNAHybridizer supports at most 8 input ingredients");
|
||||||
}
|
}
|
||||||
this.ingredients.add(ingredient);
|
this.ingredients.add(ingredient);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DNAHybridizingRecipeBuilder setCatalyst(ItemLike item) {
|
|
||||||
this.catalyst = java.util.Optional.of(item);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? if >1.20.1 {
|
//? if >1.20.1 {
|
||||||
/*public void save(RecipeOutput output) {
|
/*public void save(RecipeOutput output) {
|
||||||
ResourceLocation resultKey = BuiltInRegistries.ITEM.getKey(this.resultItem.orElseThrow());
|
ResourceLocation resultKey = BuiltInRegistries.ITEM.getKey(this.resultItem.orElseThrow());
|
||||||
@@ -88,20 +83,9 @@ public class DNAHybridizingRecipeBuilder {
|
|||||||
NonNullList<Ingredient> inputs = NonNullList.create();
|
NonNullList<Ingredient> inputs = NonNullList.create();
|
||||||
inputs.addAll(this.ingredients);
|
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);
|
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;
|
AdvancementHolder advancementHolder = null;
|
||||||
if (!this.criteria.isEmpty()) {
|
if (!this.criteria.isEmpty()) {
|
||||||
@@ -133,17 +117,6 @@ public class DNAHybridizingRecipeBuilder {
|
|||||||
NonNullList<Ingredient> inputs = NonNullList.create();
|
NonNullList<Ingredient> inputs = NonNullList.create();
|
||||||
inputs.addAll(this.ingredients);
|
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();
|
Advancement.Builder advancementBuilder = Advancement.Builder.advancement();
|
||||||
advancementBuilder.parent(new ResourceLocation("recipes/root"))
|
advancementBuilder.parent(new ResourceLocation("recipes/root"))
|
||||||
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(recipeId))
|
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(recipeId))
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
package net.cmr.jurassicrevived.datagen.custom;
|
package net.cmr.jurassicrevived.datagen.custom;
|
||||||
|
|
||||||
|
import net.cmr.jurassicrevived.Constants;
|
||||||
import net.cmr.jurassicrevived.recipe.EmbryoCalcificationMachineRecipe;
|
import net.cmr.jurassicrevived.recipe.EmbryoCalcificationMachineRecipe;
|
||||||
import net.minecraft.advancements.*;
|
import net.minecraft.advancements.*;
|
||||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
||||||
@@ -64,7 +65,7 @@ public class EmbryoCalcificationMachiningRecipeBuilder {
|
|||||||
inputs.add(Ingredient.of(secondItem.orElseThrow()));
|
inputs.add(Ingredient.of(secondItem.orElseThrow()));
|
||||||
ItemStack result = new ItemStack(resultItem.orElseThrow(), this.count);
|
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;
|
AdvancementHolder advancementHolder = null;
|
||||||
if (!this.criteria.isEmpty()) {
|
if (!this.criteria.isEmpty()) {
|
||||||
|
|||||||
@@ -14,7 +14,5 @@ public class MixinMinecraft
|
|||||||
@Inject(at = @At("TAIL"), method = "<init>")
|
@Inject(at = @At("TAIL"), method = "<init>")
|
||||||
private void init(CallbackInfo info) {
|
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),
|
).forGetter(DNAAnalyzerRecipe::inputs),
|
||||||
ItemStack.CODEC.fieldOf("result").forGetter(DNAAnalyzerRecipe::output),
|
ItemStack.CODEC.fieldOf("result").forGetter(DNAAnalyzerRecipe::output),
|
||||||
Codec.unboundedMap(ResourceLocation.CODEC, Codec.INT).optionalFieldOf("weights", java.util.Map.of()).forGetter(DNAAnalyzerRecipe::weights)
|
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(
|
public static final StreamCodec<RegistryFriendlyByteBuf, DNAAnalyzerRecipe> STREAM_CODEC = StreamCodec.of(
|
||||||
(buf, r) -> {
|
(buf, r) -> {
|
||||||
@@ -114,7 +114,13 @@ public record DNAAnalyzerRecipe(
|
|||||||
int size = buf.readVarInt();
|
int size = buf.readVarInt();
|
||||||
NonNullList<Ingredient> ins = NonNullList.create();
|
NonNullList<Ingredient> ins = NonNullList.create();
|
||||||
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
|
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),
|
).forGetter(DNAExtractorRecipe::inputs),
|
||||||
ItemStack.CODEC.fieldOf("result").forGetter(DNAExtractorRecipe::output),
|
ItemStack.CODEC.fieldOf("result").forGetter(DNAExtractorRecipe::output),
|
||||||
Codec.unboundedMap(ResourceLocation.CODEC, Codec.INT).optionalFieldOf("weights", java.util.Map.of()).forGetter(DNAExtractorRecipe::weights)
|
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(
|
public static final StreamCodec<RegistryFriendlyByteBuf, DNAExtractorRecipe> STREAM_CODEC = StreamCodec.of(
|
||||||
(buf, r) -> {
|
(buf, r) -> {
|
||||||
@@ -121,7 +121,13 @@ public record DNAExtractorRecipe(
|
|||||||
int size = buf.readVarInt();
|
int size = buf.readVarInt();
|
||||||
NonNullList<Ingredient> ins = NonNullList.create();
|
NonNullList<Ingredient> ins = NonNullList.create();
|
||||||
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
|
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; }
|
@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))
|
l -> DataResult.success(List.copyOf(l))
|
||||||
).forGetter(DNAHybridizerRecipe::inputs),
|
).forGetter(DNAHybridizerRecipe::inputs),
|
||||||
ItemStack.CODEC.fieldOf("result").forGetter(DNAHybridizerRecipe::output)
|
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(
|
public static final StreamCodec<RegistryFriendlyByteBuf, DNAHybridizerRecipe> STREAM_CODEC = StreamCodec.of(
|
||||||
(buf, r) -> {
|
(buf, r) -> {
|
||||||
@@ -106,7 +106,8 @@ public record DNAHybridizerRecipe(ResourceLocation id, NonNullList<Ingredient> i
|
|||||||
int size = buf.readVarInt();
|
int size = buf.readVarInt();
|
||||||
NonNullList<Ingredient> ins = NonNullList.create();
|
NonNullList<Ingredient> ins = NonNullList.create();
|
||||||
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
|
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; }
|
@Override public MapCodec<DNAHybridizerRecipe> codec() { return CODEC; }
|
||||||
|
|||||||
+2
-2
@@ -68,7 +68,7 @@ public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<
|
|||||||
list -> DataResult.success(List.copyOf(list))
|
list -> DataResult.success(List.copyOf(list))
|
||||||
).forGetter(EmbryoCalcificationMachineRecipe::inputs),
|
).forGetter(EmbryoCalcificationMachineRecipe::inputs),
|
||||||
ItemStack.CODEC.fieldOf("result").forGetter(EmbryoCalcificationMachineRecipe::output)
|
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(
|
public static final StreamCodec<RegistryFriendlyByteBuf, EmbryoCalcificationMachineRecipe> STREAM_CODEC = StreamCodec.of(
|
||||||
(buf, recipe) -> {
|
(buf, recipe) -> {
|
||||||
@@ -80,7 +80,7 @@ public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<
|
|||||||
int size = buf.readVarInt();
|
int size = buf.readVarInt();
|
||||||
NonNullList<Ingredient> ins = NonNullList.create();
|
NonNullList<Ingredient> ins = NonNullList.create();
|
||||||
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
|
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; }
|
@Override public MapCodec<EmbryoCalcificationMachineRecipe> codec() { return CODEC; }
|
||||||
|
|||||||
@@ -150,7 +150,11 @@ public class EmbryonicMachineRecipe implements Recipe<EmbryonicMachineRecipeInpu
|
|||||||
buf -> {
|
buf -> {
|
||||||
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
|
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
|
||||||
ItemStack output = ItemStack.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);
|
return new EmbryonicMachineRecipe(inputs, output, weights);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -180,7 +180,11 @@ public class FossilCleanerRecipe implements Recipe<FossilCleanerRecipeInput> {
|
|||||||
buf -> {
|
buf -> {
|
||||||
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
|
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
|
||||||
ItemStack output = ItemStack.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 FossilCleanerRecipe(inputs, output, weights);
|
return new FossilCleanerRecipe(inputs, output, weights);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -174,7 +174,11 @@ public class FossilGrinderRecipe implements Recipe<FossilGrinderRecipeInput> {
|
|||||||
buf -> {
|
buf -> {
|
||||||
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
|
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
|
||||||
ItemStack output = ItemStack.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);
|
return new FossilGrinderRecipe(inputs, output, weights);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -67,15 +67,7 @@ public class GeneratorScreen extends AbstractContainerScreen<GeneratorMenu> {
|
|||||||
|
|
||||||
renderFuelBurning(guiGraphics, x, y);
|
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) {
|
private void renderFuelBurning(GuiGraphics guiGraphics, int x, int y) {
|
||||||
if (this.menu.isBurning()) {
|
if (this.menu.isBurning()) {
|
||||||
float progress = Mth.clamp(this.menu.getFuelProgress(), 0.0F, 1.0F);
|
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);
|
guiGraphics.blit(LIT_PROGRESS_TEXTURE, destX, destY, srcU, srcV, width, height, texW, texH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//?}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
|
||||||
|
|||||||
@@ -75,9 +75,23 @@ public class TankScreen extends AbstractContainerScreen<TankMenu> {
|
|||||||
renderBackground(guiGraphics);
|
renderBackground(guiGraphics);
|
||||||
//?}
|
//?}
|
||||||
super.render(guiGraphics, mouseX, mouseY, delta);
|
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);
|
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) {
|
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());
|
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 |
@@ -12,6 +12,10 @@ public class JRModClient implements ClientModInitializer {
|
|||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
CommonClientClass.init();
|
CommonClientClass.init();
|
||||||
|
|
||||||
|
//? if <=1.20.1 {
|
||||||
|
CommonClientClass.registerScreens();
|
||||||
|
//?}
|
||||||
|
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.TANK.get(), RenderType.translucent());
|
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.TANK.get(), RenderType.translucent());
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.INCUBATOR.get(), RenderType.translucent());
|
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.INCUBATOR.get(), RenderType.translucent());
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.DNA_EXTRACTOR.get(), RenderType.translucent());
|
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.DNA_EXTRACTOR.get(), RenderType.translucent());
|
||||||
|
|||||||
@@ -189,22 +189,20 @@ public class FabricRecipeProvider extends net.fabricmc.fabric.api.datagen.v1.pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dnaHybridizing(ItemLike result, int count, ItemLike catalyst, ItemLike... ingredients) {
|
public void dnaHybridizing(ItemLike result, int count, ItemLike... ingredients) {
|
||||||
//? if >1.20.1 {
|
//? if >1.20.1 {
|
||||||
/*DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count)
|
/*DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count);
|
||||||
.setCatalyst(catalyst);
|
|
||||||
for (ItemLike ingredient : ingredients) {
|
for (ItemLike ingredient : ingredients) {
|
||||||
builder.addIngredient(ingredient);
|
builder.addIngredient(ingredient);
|
||||||
}
|
}
|
||||||
builder.unlockedBy("has_catalyst", has(catalyst))
|
builder.unlockedBy("has_dna", has(ingredients[0]))
|
||||||
.save(output);
|
.save(output);
|
||||||
*///?} else {
|
*///?} else {
|
||||||
DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count)
|
DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count);
|
||||||
.setCatalyst(catalyst);
|
|
||||||
for (ItemLike ingredient : ingredients) {
|
for (ItemLike ingredient : ingredients) {
|
||||||
builder.addIngredient(ingredient);
|
builder.addIngredient(ingredient);
|
||||||
}
|
}
|
||||||
builder.unlockedBy("has_catalyst", has(catalyst))
|
builder.unlockedBy("has_dna", has(ingredients[0]))
|
||||||
.save(output);
|
.save(output);
|
||||||
//?}
|
//?}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-20
@@ -3,6 +3,7 @@ package net.cmr.jurassicrevived.platform;
|
|||||||
import dev.architectury.fluid.FluidStack;
|
import dev.architectury.fluid.FluidStack;
|
||||||
import net.cmr.jurassicrevived.platform.services.IItemFluidHelper;
|
import net.cmr.jurassicrevived.platform.services.IItemFluidHelper;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
|
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
|
||||||
|
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
|
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
||||||
@@ -16,20 +17,32 @@ import net.minecraft.world.level.material.Fluids;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class FabricItemFluidHelper implements IItemFluidHelper {
|
public class FabricItemFluidHelper implements IItemFluidHelper {
|
||||||
|
private static final long MB_PER_BUCKET = 1000L;
|
||||||
|
|
||||||
|
private static long dropletsToMb(long droplets) {
|
||||||
|
if (droplets <= 0) return 0;
|
||||||
|
return Math.max(1, droplets * MB_PER_BUCKET / FluidConstants.BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long mbToDroplets(long mb) {
|
||||||
|
if (mb <= 0) return 0;
|
||||||
|
return mb * FluidConstants.BUCKET / MB_PER_BUCKET;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<FluidStack> getContainedFluid(ItemStack stack) {
|
public Optional<FluidStack> getContainedFluid(ItemStack stack) {
|
||||||
ContainerItemContext ctx = ContainerItemContext.withConstant(stack.copy());
|
|
||||||
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
|
||||||
if (storage == null) {
|
|
||||||
if (stack.is(Items.WATER_BUCKET)) return Optional.of(FluidStack.create(Fluids.WATER, 1000));
|
if (stack.is(Items.WATER_BUCKET)) return Optional.of(FluidStack.create(Fluids.WATER, 1000));
|
||||||
if (stack.is(Items.LAVA_BUCKET)) return Optional.of(FluidStack.create(Fluids.LAVA, 1000));
|
if (stack.is(Items.LAVA_BUCKET)) return Optional.of(FluidStack.create(Fluids.LAVA, 1000));
|
||||||
|
|
||||||
|
ContainerItemContext ctx = ContainerItemContext.withConstant(ItemVariant.of(stack), stack.getCount());
|
||||||
|
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
||||||
|
if (storage == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (StorageView<FluidVariant> view : storage) {
|
for (StorageView<FluidVariant> view : storage) {
|
||||||
if (!view.isResourceBlank() && view.getAmount() > 0) {
|
if (!view.isResourceBlank() && view.getAmount() > 0) {
|
||||||
return Optional.of(FluidStack.create(view.getResource().getFluid(), view.getAmount()));
|
return Optional.of(FluidStack.create(view.getResource().getFluid(), dropletsToMb(view.getAmount())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.of(FluidStack.empty());
|
return Optional.of(FluidStack.empty());
|
||||||
@@ -37,31 +50,37 @@ public class FabricItemFluidHelper implements IItemFluidHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransferResult drain(ItemStack stack, long amount, boolean simulate) {
|
public TransferResult drain(ItemStack stack, long amount, boolean simulate) {
|
||||||
ContainerItemContext ctx = ContainerItemContext.withConstant(stack.copy());
|
|
||||||
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
|
||||||
if (storage == null) {
|
|
||||||
if (stack.is(Items.WATER_BUCKET) && amount >= 1000) {
|
if (stack.is(Items.WATER_BUCKET) && amount >= 1000) {
|
||||||
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.BUCKET));
|
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.BUCKET));
|
||||||
}
|
}
|
||||||
if (stack.is(Items.LAVA_BUCKET) && amount >= 1000) {
|
if (stack.is(Items.LAVA_BUCKET) && amount >= 1000) {
|
||||||
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.BUCKET));
|
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.BUCKET));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContainerItemContext ctx = ContainerItemContext.withConstant(ItemVariant.of(stack), stack.getCount());
|
||||||
|
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
||||||
|
if (storage == null) {
|
||||||
return new TransferResult(0, stack);
|
return new TransferResult(0, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Transaction tx = Transaction.openOuter()) {
|
try (Transaction tx = Transaction.openOuter()) {
|
||||||
long extracted = 0;
|
long requestedDroplets = mbToDroplets(amount);
|
||||||
|
long extractedDroplets = 0;
|
||||||
|
|
||||||
for (StorageView<FluidVariant> view : storage) {
|
for (StorageView<FluidVariant> view : storage) {
|
||||||
if (!view.isResourceBlank()) {
|
if (!view.isResourceBlank()) {
|
||||||
extracted = storage.extract(view.getResource(), amount, tx);
|
extractedDroplets = storage.extract(view.getResource(), requestedDroplets, tx);
|
||||||
if (extracted > 0) break;
|
if (extractedDroplets > 0) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extracted > 0) {
|
if (extractedDroplets > 0) {
|
||||||
|
long extractedMb = dropletsToMb(extractedDroplets);
|
||||||
|
|
||||||
if (!simulate) tx.commit();
|
if (!simulate) tx.commit();
|
||||||
|
|
||||||
ItemStack resultStack = ctx.getItemVariant().toStack((int) ctx.getAmount());
|
ItemStack resultStack = ctx.getItemVariant().toStack((int) ctx.getAmount());
|
||||||
return new TransferResult(extracted, resultStack);
|
return new TransferResult(extractedMb, resultStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new TransferResult(0, stack);
|
return new TransferResult(0, stack);
|
||||||
@@ -69,9 +88,6 @@ public class FabricItemFluidHelper implements IItemFluidHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransferResult fill(ItemStack stack, FluidStack fluid, long amount, boolean simulate) {
|
public TransferResult fill(ItemStack stack, FluidStack fluid, long amount, boolean simulate) {
|
||||||
ContainerItemContext ctx = ContainerItemContext.withConstant(stack.copy());
|
|
||||||
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
|
||||||
if (storage == null) {
|
|
||||||
if (stack.is(Items.BUCKET) && amount >= 1000) {
|
if (stack.is(Items.BUCKET) && amount >= 1000) {
|
||||||
if (fluid.getFluid().isSame(Fluids.WATER)) {
|
if (fluid.getFluid().isSame(Fluids.WATER)) {
|
||||||
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.WATER_BUCKET));
|
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.WATER_BUCKET));
|
||||||
@@ -80,15 +96,24 @@ public class FabricItemFluidHelper implements IItemFluidHelper {
|
|||||||
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.LAVA_BUCKET));
|
return new TransferResult(1000, simulate ? stack : new ItemStack(Items.LAVA_BUCKET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContainerItemContext ctx = ContainerItemContext.withConstant(ItemVariant.of(stack), stack.getCount());
|
||||||
|
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
||||||
|
if (storage == null) {
|
||||||
return new TransferResult(0, stack);
|
return new TransferResult(0, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Transaction tx = Transaction.openOuter()) {
|
try (Transaction tx = Transaction.openOuter()) {
|
||||||
long inserted = storage.insert(FluidVariant.of(fluid.getFluid()), amount, tx);
|
long requestedDroplets = mbToDroplets(amount);
|
||||||
if (inserted > 0) {
|
long insertedDroplets = storage.insert(FluidVariant.of(fluid.getFluid()), requestedDroplets, tx);
|
||||||
|
|
||||||
|
if (insertedDroplets > 0) {
|
||||||
|
long insertedMb = dropletsToMb(insertedDroplets);
|
||||||
|
|
||||||
if (!simulate) tx.commit();
|
if (!simulate) tx.commit();
|
||||||
|
|
||||||
ItemStack resultStack = ctx.getItemVariant().toStack((int) ctx.getAmount());
|
ItemStack resultStack = ctx.getItemVariant().toStack((int) ctx.getAmount());
|
||||||
return new TransferResult(inserted, resultStack);
|
return new TransferResult(insertedMb, resultStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new TransferResult(0, stack);
|
return new TransferResult(0, stack);
|
||||||
@@ -96,8 +121,12 @@ public class FabricItemFluidHelper implements IItemFluidHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFluidHandler(ItemStack stack) {
|
public boolean isFluidHandler(ItemStack stack) {
|
||||||
ContainerItemContext ctx = ContainerItemContext.withConstant(stack);
|
if (stack.is(Items.BUCKET) || stack.is(Items.WATER_BUCKET) || stack.is(Items.LAVA_BUCKET)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContainerItemContext ctx = ContainerItemContext.withConstant(ItemVariant.of(stack), stack.getCount());
|
||||||
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
Storage<FluidVariant> storage = ctx.find(FluidStorage.ITEM);
|
||||||
return storage != null || stack.is(Items.BUCKET) || stack.is(Items.WATER_BUCKET) || stack.is(Items.LAVA_BUCKET);
|
return storage != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+103
-23
@@ -12,18 +12,16 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
|
|
||||||
import dev.architectury.fluid.FluidStack;
|
import dev.architectury.fluid.FluidStack;
|
||||||
|
import net.cmr.jurassicrevived.platform.transfer.InternalFluidHandler;
|
||||||
|
import net.cmr.jurassicrevived.platform.transfer.InternalFluidProvider;
|
||||||
import team.reborn.energy.api.EnergyStorage;
|
import team.reborn.energy.api.EnergyStorage;
|
||||||
import net.cmr.jurassicrevived.platform.transfer.PlatformEnergyHandler;
|
import net.cmr.jurassicrevived.platform.transfer.PlatformEnergyHandler;
|
||||||
import net.cmr.jurassicrevived.platform.transfer.PlatformFluidHandler;
|
import net.cmr.jurassicrevived.platform.transfer.PlatformFluidHandler;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
|
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
|
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants;
|
||||||
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
|
||||||
//import net.fabricmc.fabric.api.transfer.v1.energy.EnergyStorage;
|
|
||||||
//import team.reborn.energy.api.EnergyStorage;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -31,6 +29,17 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class FabricTransferHelper implements ITransferHelper {
|
public class FabricTransferHelper implements ITransferHelper {
|
||||||
|
private static final long MB_PER_BUCKET = 1000L;
|
||||||
|
|
||||||
|
private static long dropletsToMb(long droplets) {
|
||||||
|
if (droplets <= 0) return 0;
|
||||||
|
return Math.max(1, droplets * MB_PER_BUCKET / FluidConstants.BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long mbToDroplets(long mb) {
|
||||||
|
if (mb <= 0) return 0;
|
||||||
|
return mb * FluidConstants.BUCKET / MB_PER_BUCKET;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<PlatformItemHandler> getItemHandler(Level level, BlockPos pos, Direction side) {
|
public Optional<PlatformItemHandler> getItemHandler(Level level, BlockPos pos, Direction side) {
|
||||||
@@ -41,6 +50,13 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<PlatformFluidHandler> getFluidHandler(Level level, BlockPos pos, Direction side) {
|
public Optional<PlatformFluidHandler> getFluidHandler(Level level, BlockPos pos, Direction side) {
|
||||||
|
if (level.getBlockEntity(pos) instanceof InternalFluidProvider provider) {
|
||||||
|
InternalFluidHandler handler = provider.getFluidHandler(side);
|
||||||
|
if (handler != null) {
|
||||||
|
return Optional.of(new DirectInternalFluidHandler(handler));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var storage = FluidStorage.SIDED.find(level, pos, side);
|
var storage = FluidStorage.SIDED.find(level, pos, side);
|
||||||
if (storage == null) return Optional.empty();
|
if (storage == null) return Optional.empty();
|
||||||
return Optional.of(new FabricFluidHandler(storage));
|
return Optional.of(new FabricFluidHandler(storage));
|
||||||
@@ -49,7 +65,8 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
@Override
|
@Override
|
||||||
public Optional<PlatformEnergyHandler> getEnergyHandler(Level level, BlockPos pos, Direction side) {
|
public Optional<PlatformEnergyHandler> getEnergyHandler(Level level, BlockPos pos, Direction side) {
|
||||||
EnergyStorage storage = EnergyStorage.SIDED.find(level, pos, side);
|
EnergyStorage storage = EnergyStorage.SIDED.find(level, pos, side);
|
||||||
return Optional.empty();
|
if (storage == null) return Optional.empty();
|
||||||
|
return Optional.of(new FabricEnergyHandler(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InternalFluidStorage implements Storage<FluidVariant> {
|
public static class InternalFluidStorage implements Storage<FluidVariant> {
|
||||||
@@ -65,18 +82,19 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidStack stack = FluidStack.create(resource.getFluid(), maxAmount);
|
long maxAmountMb = dropletsToMb(maxAmount);
|
||||||
long inserted = handler.fill(stack, true);
|
FluidStack stack = FluidStack.create(resource.getFluid(), maxAmountMb);
|
||||||
|
long insertedMb = handler.fill(stack, true);
|
||||||
|
|
||||||
if (inserted > 0) {
|
if (insertedMb > 0) {
|
||||||
transaction.addCloseCallback((tx, result) -> {
|
transaction.addCloseCallback((tx, result) -> {
|
||||||
if (result.wasCommitted()) {
|
if (result.wasCommitted()) {
|
||||||
handler.fill(FluidStack.create(resource.getFluid(), inserted), false);
|
handler.fill(FluidStack.create(resource.getFluid(), insertedMb), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return inserted;
|
return Math.min(maxAmount, mbToDroplets(insertedMb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,17 +108,18 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long extracted = Math.min(maxAmount, stored.getAmount());
|
long maxAmountMb = dropletsToMb(maxAmount);
|
||||||
|
long extractedMb = Math.min(maxAmountMb, stored.getAmount());
|
||||||
|
|
||||||
if (extracted > 0) {
|
if (extractedMb > 0) {
|
||||||
transaction.addCloseCallback((tx, result) -> {
|
transaction.addCloseCallback((tx, result) -> {
|
||||||
if (result.wasCommitted()) {
|
if (result.wasCommitted()) {
|
||||||
handler.drain(extracted, false);
|
handler.drain(extractedMb, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return extracted;
|
return Math.min(maxAmount, mbToDroplets(extractedMb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,12 +133,12 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getAmount() {
|
public long getAmount() {
|
||||||
return stored.getAmount();
|
return mbToDroplets(stored.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCapacity() {
|
public long getCapacity() {
|
||||||
return handler.getCapacity();
|
return mbToDroplets(handler.getCapacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -135,6 +154,44 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class DirectInternalFluidHandler implements PlatformFluidHandler {
|
||||||
|
private final InternalFluidHandler handler;
|
||||||
|
|
||||||
|
private DirectInternalFluidHandler(InternalFluidHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<FluidStack> getExtractableFluids() {
|
||||||
|
FluidStack stored = handler.getFluid();
|
||||||
|
if (stored.isEmpty()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return List.of(stored.copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long extract(FluidStack stack, long amount, boolean simulate) {
|
||||||
|
FluidStack stored = handler.getFluid();
|
||||||
|
if (stored.isEmpty() || stored.getFluid() != stack.getFluid()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handler.drain(amount, simulate).getAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insert(FluidStack stack, long amount, boolean simulate) {
|
||||||
|
if (stack.isEmpty() || amount <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FluidStack toInsert = stack.copy();
|
||||||
|
toInsert.setAmount(amount);
|
||||||
|
return handler.fill(toInsert, simulate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class FabricFluidHandler implements PlatformFluidHandler {
|
private static class FabricFluidHandler implements PlatformFluidHandler {
|
||||||
private final Storage<FluidVariant> storage;
|
private final Storage<FluidVariant> storage;
|
||||||
|
|
||||||
@@ -148,7 +205,7 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
for (StorageView<FluidVariant> view : storage) {
|
for (StorageView<FluidVariant> view : storage) {
|
||||||
if (view.isResourceBlank()) continue;
|
if (view.isResourceBlank()) continue;
|
||||||
FluidVariant v = view.getResource();
|
FluidVariant v = view.getResource();
|
||||||
long amt = view.getAmount();
|
long amt = dropletsToMb(view.getAmount());
|
||||||
if (amt > 0) {
|
if (amt > 0) {
|
||||||
FluidStack stack = FluidStack.create(v.getFluid(), amt);
|
FluidStack stack = FluidStack.create(v.getFluid(), amt);
|
||||||
stacks.add(stack);
|
stacks.add(stack);
|
||||||
@@ -160,35 +217,58 @@ public class FabricTransferHelper implements ITransferHelper {
|
|||||||
@Override
|
@Override
|
||||||
public long extract(FluidStack stack, long amount, boolean simulate) {
|
public long extract(FluidStack stack, long amount, boolean simulate) {
|
||||||
try (Transaction tx = Transaction.openOuter()) {
|
try (Transaction tx = Transaction.openOuter()) {
|
||||||
long extracted = storage.extract(FluidVariant.of(stack.getFluid()), amount, tx);
|
long extractedDroplets = storage.extract(FluidVariant.of(stack.getFluid()), mbToDroplets(amount), tx);
|
||||||
if (!simulate) tx.commit();
|
if (!simulate) tx.commit();
|
||||||
return extracted;
|
return dropletsToMb(extractedDroplets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insert(FluidStack stack, long amount, boolean simulate) {
|
public long insert(FluidStack stack, long amount, boolean simulate) {
|
||||||
try (Transaction tx = Transaction.openOuter()) {
|
try (Transaction tx = Transaction.openOuter()) {
|
||||||
long inserted = storage.insert(FluidVariant.of(stack.getFluid()), amount, tx);
|
long insertedDroplets = storage.insert(FluidVariant.of(stack.getFluid()), mbToDroplets(amount), tx);
|
||||||
if (!simulate) tx.commit();
|
if (!simulate) tx.commit();
|
||||||
return inserted;
|
return dropletsToMb(insertedDroplets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FabricEnergyHandler implements PlatformEnergyHandler {
|
private static class FabricEnergyHandler implements PlatformEnergyHandler {
|
||||||
private FabricEnergyHandler() {
|
private final EnergyStorage storage;
|
||||||
|
|
||||||
|
private FabricEnergyHandler(EnergyStorage storage) {
|
||||||
|
this.storage = storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int extract(int amount, boolean simulate) {
|
public int extract(int amount, boolean simulate) {
|
||||||
|
if (amount <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try (Transaction tx = Transaction.openOuter()) {
|
||||||
|
long extracted = storage.extract(amount, tx);
|
||||||
|
if (!simulate) {
|
||||||
|
tx.commit();
|
||||||
|
}
|
||||||
|
return (int) Math.min(Integer.MAX_VALUE, extracted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insert(int amount, boolean simulate) {
|
public int insert(int amount, boolean simulate) {
|
||||||
|
if (amount <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try (Transaction tx = Transaction.openOuter()) {
|
||||||
|
long inserted = storage.insert(amount, tx);
|
||||||
|
if (!simulate) {
|
||||||
|
tx.commit();
|
||||||
|
}
|
||||||
|
return (int) Math.min(Integer.MAX_VALUE, inserted);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FabricItemHandler implements PlatformItemHandler {
|
private static class FabricItemHandler implements PlatformItemHandler {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.minecraftforge.client.ConfigScreenHandler;
|
|||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
@Mod(Constants.MOD_ID)
|
@Mod(Constants.MOD_ID)
|
||||||
@@ -26,6 +27,8 @@ public class JRMod {
|
|||||||
|
|
||||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> CommonClientClass::init);
|
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> CommonClientClass::init);
|
||||||
|
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
|
||||||
|
|
||||||
ModLoadingContext.get().registerExtensionPoint(
|
ModLoadingContext.get().registerExtensionPoint(
|
||||||
ConfigScreenHandler.ConfigScreenFactory.class,
|
ConfigScreenHandler.ConfigScreenFactory.class,
|
||||||
() -> new ConfigScreenHandler.ConfigScreenFactory(
|
() -> new ConfigScreenHandler.ConfigScreenFactory(
|
||||||
@@ -34,4 +37,8 @@ public class JRMod {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clientSetup(FMLClientSetupEvent event) {
|
||||||
|
event.enqueueWork(CommonClientClass::registerScreens);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-4
@@ -113,13 +113,12 @@ public class ForgeRecipeProvider extends RecipeProvider implements ModRecipeProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dnaHybridizing(ItemLike result, int count, ItemLike catalyst, ItemLike... ingredients) {
|
public void dnaHybridizing(ItemLike result, int count, ItemLike... ingredients) {
|
||||||
DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count)
|
DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count);
|
||||||
.setCatalyst(catalyst);
|
|
||||||
for (ItemLike ingredient : ingredients) {
|
for (ItemLike ingredient : ingredients) {
|
||||||
builder.addIngredient(ingredient);
|
builder.addIngredient(ingredient);
|
||||||
}
|
}
|
||||||
builder.unlockedBy("has_catalyst", has(catalyst))
|
builder.unlockedBy("has_dna", has(ingredients[0]))
|
||||||
.save(output);
|
.save(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,14 +116,13 @@ public class NeoForgeRecipeProvider extends RecipeProvider implements ModRecipeP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dnaHybridizing(ItemLike result, int count, ItemLike catalyst, ItemLike... ingredients) {
|
public void dnaHybridizing(ItemLike result, int count, ItemLike... ingredients) {
|
||||||
//? if >1.20.1 {
|
//? if >1.20.1 {
|
||||||
DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count)
|
DNAHybridizingRecipeBuilder builder = new DNAHybridizingRecipeBuilder(result, count);
|
||||||
.setCatalyst(catalyst);
|
|
||||||
for (ItemLike ingredient : ingredients) {
|
for (ItemLike ingredient : ingredients) {
|
||||||
builder.addIngredient(ingredient);
|
builder.addIngredient(ingredient);
|
||||||
}
|
}
|
||||||
builder.unlockedBy("has_catalyst", has(catalyst))
|
builder.unlockedBy("has_dna", has(ingredients[0]))
|
||||||
.save(output);
|
.save(output);
|
||||||
//?}
|
//?}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ package net.cmr.jurassicrevived.event;
|
|||||||
|
|
||||||
import net.cmr.jurassicrevived.Constants;
|
import net.cmr.jurassicrevived.Constants;
|
||||||
import net.cmr.jurassicrevived.block.entity.ModBlockEntities;
|
import net.cmr.jurassicrevived.block.entity.ModBlockEntities;
|
||||||
import net.cmr.jurassicrevived.block.entity.custom.FossilCleanerBlockEntity;
|
import net.cmr.jurassicrevived.block.entity.custom.*;
|
||||||
import net.cmr.jurassicrevived.block.entity.custom.GeneratorBlockEntity;
|
|
||||||
import net.cmr.jurassicrevived.config.JRConfigManager;
|
import net.cmr.jurassicrevived.config.JRConfigManager;
|
||||||
import net.cmr.jurassicrevived.block.entity.custom.PowerCellBlockEntity;
|
|
||||||
import net.cmr.jurassicrevived.block.entity.custom.TankBlockEntity;
|
|
||||||
import net.cmr.jurassicrevived.neoforge.capabilities.NeoForgeEnergyStorage;
|
import net.cmr.jurassicrevived.neoforge.capabilities.NeoForgeEnergyStorage;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
@@ -40,12 +37,33 @@ public class NeoForgeEvents
|
|||||||
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.GENERATOR_BE.get(),
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.GENERATOR_BE.get(),
|
||||||
(be, side) -> new NeoForgeEnergyStorage(((GeneratorBlockEntity) be).getEnergyStorage(side)));
|
(be, side) -> new NeoForgeEnergyStorage(((GeneratorBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.DNA_ANALYZER_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((DNAAnalyzerBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.DNA_EXTRACTOR_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((DNAExtractorBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.DNA_HYBRIDIZER_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((DNAHybridizerBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.EMBRYO_CALCIFICATION_MACHINE_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((EmbryoCalcificationMachineBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.EMBRYONIC_MACHINE_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((EmbryonicMachineBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.FOSSIL_CLEANER_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((FossilCleanerBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.FOSSIL_GRINDER_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((FossilGrinderBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.INCUBATOR_BE.get(),
|
||||||
|
(be, side) -> new NeoForgeEnergyStorage(((IncubatorBlockEntity) be).getEnergyStorage(side)));
|
||||||
|
|
||||||
// Fluids
|
// Fluids
|
||||||
event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, ModBlockEntities.TANK_BE.get(),
|
event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, ModBlockEntities.TANK_BE.get(),
|
||||||
(be, side) -> new TankFluidAdapter(((TankBlockEntity) be).getTank(side)));
|
(be, side) -> new TankFluidAdapter(((TankBlockEntity) be).getTank(side)));
|
||||||
|
|
||||||
//event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, ModBlockEntities.FOSSIL_CLEANER_BE.get(),
|
|
||||||
// (be, side) -> new TankFluidAdapter(((FossilCleanerBlockEntity) be).getTank(side)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private record TankFluidAdapter(TankBlockEntity.TankFluidHandler tank) implements IFluidHandler {
|
private record TankFluidAdapter(TankBlockEntity.TankFluidHandler tank) implements IFluidHandler {
|
||||||
|
|||||||
Reference in New Issue
Block a user