From 8ed9ca2f6b8de004994da62ea20e6e71c1415e64 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sat, 13 Apr 2024 19:58:24 -0700 Subject: [PATCH 01/15] JEI compat changes - Fixes issue #2369 - Made some JEI category changes to make it look a bit better --- .../compat/jei/GenfluidRecipeCategory.java | 3 ++- .../compat/jei/MelterRecipeCategory.java | 22 ++++++++++++++---- .../compat/jei/SolidifierRecipeCategory.java | 22 ++++++++++++++---- .../cyclic/textures/jei/melter_recipe.png | Bin 270 -> 396 bytes 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/GenfluidRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/GenfluidRecipeCategory.java index 8f0995dfd7..9dddf5687a 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/GenfluidRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/GenfluidRecipeCategory.java @@ -61,12 +61,13 @@ public void draw(RecipeGeneratorFluid recipe, IRecipeSlotsView recipeSlotsView, ms.drawString(font, recipe.getTicks() + " t", 60, 0, FONT); ms.drawString(font, recipe.getRfpertick() + " RF/t", 60, 10, FONT); ms.drawString(font, recipe.getRfTotal() + " RF", 60, 20, FONT); + //ms.drawString(font, recipe.fluidIng.getAmount() + " mB", 60, 30, FONT); } @Override public void setRecipe(IRecipeLayoutBuilder builder, RecipeGeneratorFluid recipe, IFocusGroup focuses) { List matchingFluids = recipe.fluidIng.getMatchingFluids(); - builder.addSlot(RecipeIngredientRole.INPUT, 6, 7).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids); + builder.addSlot(RecipeIngredientRole.INPUT, 6, 7).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16); } //keep old code for reference // diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java index dc9502e0c0..2f3aedc626 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java @@ -3,7 +3,11 @@ import java.util.List; import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.melter.RecipeMelter; +import com.lothrazar.cyclic.block.solidifier.TileSolidifier; import com.lothrazar.cyclic.registry.BlockRegistry; +import com.lothrazar.cyclic.registry.TextureRegistry; +import com.lothrazar.library.gui.EnergyBar; +import com.lothrazar.library.gui.TexturedProgress; import com.lothrazar.library.util.ChatUtil; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.forge.ForgeTypes; @@ -16,6 +20,7 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -29,10 +34,16 @@ public class MelterRecipeCategory implements IRecipeCategory { static final RecipeType TYPE = new RecipeType<>(ID, RecipeMelter.class); private IDrawable gui; private IDrawable icon; + private Font font; + private EnergyBar bar; + private TexturedProgress progress; public MelterRecipeCategory(IGuiHelper helper) { + font = Minecraft.getInstance().font; gui = helper.drawableBuilder(new ResourceLocation(ModCyclic.MODID, "textures/jei/melter_recipe.png"), 0, 0, 169, 69).setTextureSize(169, 69).build(); icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.MELTER.get())); + bar = new EnergyBar(font, TileSolidifier.MAX); + progress = new TexturedProgress(font, 80, 19, 24, 17, TextureRegistry.ARROW); } @Override @@ -57,10 +68,11 @@ public RecipeType getRecipeType() { @Override public void draw(RecipeMelter recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics ms, double mouseX, double mouseY) { - var font = Minecraft.getInstance().font; - ms.drawString(font, recipe.getEnergy().getTicks() + " t", 60, 0, FONT); - ms.drawString(font, recipe.getEnergy().getRfPertick() + " RF/t", 60, 10, FONT); - ms.drawString(font, recipe.getEnergy().getEnergyTotal() + " RF", 60, 20, FONT); + ms.drawString(font, recipe.getEnergy().getRfPertick() + " RF/t", 75, 9, FONT); + bar.draw(ms, recipe.getEnergy().getEnergyTotal()); + progress.draw(ms, 0); + bar.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.getEnergy().getEnergyTotal()); + progress.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.getEnergy().getTicks()); } @Override @@ -68,6 +80,6 @@ public void setRecipe(IRecipeLayoutBuilder builder, RecipeMelter recipe, IFocusG builder.addSlot(RecipeIngredientRole.INPUT, 4, 19).addIngredients(recipe.at(0)); builder.addSlot(RecipeIngredientRole.INPUT, 22, 19).addIngredients(recipe.at(1)); List matchingFluids = List.of(recipe.getRecipeFluid()); - builder.addSlot(RecipeIngredientRole.OUTPUT, 140, 19).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids); + builder.addSlot(RecipeIngredientRole.OUTPUT, 136, 19).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16); } } diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java index 28fdf1b4db..4d735f5011 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java @@ -3,7 +3,11 @@ import java.util.List; import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.solidifier.RecipeSolidifier; +import com.lothrazar.cyclic.block.solidifier.TileSolidifier; import com.lothrazar.cyclic.registry.BlockRegistry; +import com.lothrazar.cyclic.registry.TextureRegistry; +import com.lothrazar.library.gui.EnergyBar; +import com.lothrazar.library.gui.TexturedProgress; import com.lothrazar.library.util.ChatUtil; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.forge.ForgeTypes; @@ -16,6 +20,7 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -29,10 +34,16 @@ public class SolidifierRecipeCategory implements IRecipeCategory TYPE = new RecipeType<>(ID, RecipeSolidifier.class); private IDrawable gui; private IDrawable icon; + private Font font; + private EnergyBar bar; + private TexturedProgress progress; public SolidifierRecipeCategory(IGuiHelper helper) { + font = Minecraft.getInstance().font; gui = helper.drawableBuilder(new ResourceLocation(ModCyclic.MODID, "textures/jei/solidifier_recipe.png"), 0, 0, 169, 69).setTextureSize(169, 69).build(); icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.SOLIDIFIER.get())); + bar = new EnergyBar(font, TileSolidifier.MAX); + progress = new TexturedProgress(font, 63, 25, 24, 17, TextureRegistry.ARROW); } @Override @@ -57,10 +68,11 @@ public RecipeType getRecipeType() { @Override public void draw(RecipeSolidifier recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics ms, double mouseX, double mouseY) { - var font = Minecraft.getInstance().font; - ms.drawString(font, recipe.getEnergy().getTicks() + " t", 60, 0, FONT); - ms.drawString(font, recipe.getEnergy().getRfPertick() + " RF/t", 60, 10, FONT); - ms.drawString(font, recipe.getEnergy().getEnergyTotal() + " RF", 60, 20, FONT); + ms.drawString(font, recipe.getEnergy().getRfPertick() + " RF/t", 55, 10, FONT); + bar.draw(ms, recipe.getEnergy().getEnergyTotal()); + progress.draw(ms, 0); + bar.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.getEnergy().getEnergyTotal()); + progress.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.getEnergy().getTicks()); } @Override @@ -70,7 +82,7 @@ public void setRecipe(IRecipeLayoutBuilder builder, RecipeSolidifier recipe, IFo builder.addSlot(RecipeIngredientRole.INPUT, 34, 43).addIngredients(recipe.at(2)); builder.addSlot(RecipeIngredientRole.OUTPUT, 104, 25).addItemStack(recipe.result); List matchingFluids = recipe.fluidIngredient.getMatchingFluids(); - builder.addSlot(RecipeIngredientRole.INPUT, 4, 25).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids); + builder.addSlot(RecipeIngredientRole.INPUT, 4, 25).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16); } // @Override // public void setIngredients(RecipeSolidifier recipe, IIngredients ingredients) { diff --git a/src/main/resources/assets/cyclic/textures/jei/melter_recipe.png b/src/main/resources/assets/cyclic/textures/jei/melter_recipe.png index ec4fb473adc9c4f4e1adbf75b643d4ba6fb88319..1f501ae523b13137493e8894d8bd3efcd0c43ae1 100644 GIT binary patch literal 396 zcmeAS@N?(olHy`uVBq!ia0vp^D}mURg9%9PGYo75QY`6?zK#qG8~eHcB(eheoCO|{ z#S9F5`#_lSmD9!pKtYKT*NBqf{Irtt#G+J&g2c?c61}|C5(N`ILp>8=hm0c(42)c! zE{-7;ac{2~u4)bta0o1)`t&dB4*l&<#Xos?D6VkjxL3TP;;eze_QI$Ym-c!8)_c2q z%X_?x*LVLF-m^LXxb&ErY1pRZm{&dA;eRvspPj#H-RrF@H%^kh9eVur2JY~y|HL!z zFRh*aE%sKqZ2o_9-}C;zXItF+=lXm01&Bp`+rO_bH$Q%Re@4CVt#Xj!>)UVJubxwy uo3$q8c=@_tdH%g1-Ed>bXI$O%hdIgbQP^ht3Lap{F?hQAxvXcuTHFO?4U|n?JpYcMEGDlApagG10vj1@HF1Xad zp#=o5;#R4gez>$IVcErSTixx`x2>znTyc9vc-s0HZqtahcRy7`hQGEsW$xk%1%LOh ZGGY+QuRU7$v}P^HrJk;SF6*2UngD6pRFVJy From c77c3661c3c9745dc9d1538d8ba450b48f6b4fa6 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sat, 13 Apr 2024 20:00:38 -0700 Subject: [PATCH 02/15] Peat Fix - Fixed issue #2399 by allowing water-logged blocks to hydrate the peat --- src/main/java/com/lothrazar/cyclic/block/PeatBlock.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java b/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java index fa297e57c4..7a0e64b6f9 100644 --- a/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java +++ b/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java @@ -8,9 +8,9 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; public class PeatBlock extends BlockCyclic { @@ -32,8 +32,9 @@ public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random List waters = new ArrayList<>(); for (BlockPos p : around) { //try to bake if SOURCE water is nearby - Block bSide = world.getBlockState(p).getBlock(); - if (bSide == Blocks.WATER) { + //using FluidState instead of Block + FluidState fluid = world.getFluidState(p); + if (fluid.getType() == Fluids.WATER.getSource()) { sidesWet++; waters.add(p); } From 103be4e2f15940888872b79ea4a6917273c41fca Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sat, 13 Apr 2024 20:02:23 -0700 Subject: [PATCH 03/15] Better desync fix - Makes all of the recipe process server only instead of just part of it --- .../com/lothrazar/cyclic/block/melter/TileMelter.java | 4 +++- .../lothrazar/cyclic/block/solidifier/TileSolidifier.java | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java b/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java index a29f9bdfd2..a24368b4aa 100644 --- a/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java +++ b/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java @@ -67,6 +67,8 @@ public void tick() { if (currentRecipe == null) { return; } + //Fixes sync issue entirely + if(level.isClientSide()) return; this.timer--; if (timer < 0) { timer = 0; @@ -230,7 +232,7 @@ private boolean tryProcessRecipe() { //ok it has room for all the fluid none will be wasted inventory.getStackInSlot(0).shrink(1); inventory.getStackInSlot(1).shrink(1); - if (!level.isClientSide()) tank.fill(this.currentRecipe.getRecipeFluid(), FluidAction.EXECUTE); + tank.fill(this.currentRecipe.getRecipeFluid(), FluidAction.EXECUTE); return true; } return false; diff --git a/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java b/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java index 6226e254d6..f62a8f6753 100644 --- a/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java +++ b/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java @@ -71,6 +71,10 @@ public void tick() { this.timer = 0; return; } + //Fixes sync issue entirely + if(level.isClientSide()) return; + //Checks if there is space in the output slot + if(this.outputSlots.getStackInSlot(0).getCount() > 64 - currentRecipe.getResultItem(level.registryAccess()).getCount()) return; final int energyCost = this.currentRecipe.getEnergy().getRfPertick(); final int fluidCost = this.currentRecipe.getRecipeFluid().getAmount(); if ((energy.getEnergyStored() < energyCost && energyCost > 0) @@ -220,9 +224,9 @@ private boolean tryProcessRecipe() { inputSlots.getStackInSlot(0).shrink(1); inputSlots.getStackInSlot(1).shrink(1); inputSlots.getStackInSlot(2).shrink(1); - if (!level.isClientSide()) { // only drain serverside to avoid desync issues + // if (!level.isClientSide()) { // only drain serverside to avoid desync issues # not needed anymore with above fix tank.drain(this.currentRecipe.fluidIngredient.getAmount(), FluidAction.EXECUTE); - } + // } outputSlots.insertItem(0, currentRecipe.getResultItem(level.registryAccess()), false); return true; } From 7d0525daef7af350b24a6888b1280cefc656b170 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sat, 13 Apr 2024 20:03:56 -0700 Subject: [PATCH 04/15] Fixes to crushing macerator - Fixes issue #2343 - Player can no longer put items in the output slot --- .../cyclic/block/crusher/ContainerCrusher.java | 11 +++++++++++ .../cyclic/block/crusher/TileCrusher.java | 16 ++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/block/crusher/ContainerCrusher.java b/src/main/java/com/lothrazar/cyclic/block/crusher/ContainerCrusher.java index 6099e51337..87ef35eba0 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crusher/ContainerCrusher.java +++ b/src/main/java/com/lothrazar/cyclic/block/crusher/ContainerCrusher.java @@ -7,6 +7,7 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraftforge.items.SlotItemHandler; @@ -28,6 +29,11 @@ public void setChanged() { }); addSlot(new SlotItemHandler(tile.outputSlots, 0, 105 + 4, 21 + 4) { + @Override + public boolean mayPlace(ItemStack stack) { + return false; + } + @Override public void setChanged() { tile.setChanged(); @@ -35,6 +41,11 @@ public void setChanged() { }); addSlot(new SlotItemHandler(tile.outputSlots, 1, 109, 55) { + @Override + public boolean mayPlace(ItemStack stack) { + return false; + } + @Override public void setChanged() { tile.setChanged(); diff --git a/src/main/java/com/lothrazar/cyclic/block/crusher/TileCrusher.java b/src/main/java/com/lothrazar/cyclic/block/crusher/TileCrusher.java index ecc7ae8dd8..7961d2c9d8 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crusher/TileCrusher.java +++ b/src/main/java/com/lothrazar/cyclic/block/crusher/TileCrusher.java @@ -47,8 +47,8 @@ public TileCrusher(BlockPos pos, BlockState state) { this.needsRedstone = 0; } - public static void clientTick(Level level, BlockPos blockPos, BlockState blockState, TileCrusher tileAnvilAuto) { - tileAnvilAuto.tick(); + public static void clientTick(Level level, BlockPos blockPos, BlockState blockState, TileCrusher e) { + e.tick(); } public static void serverTick(Level level, BlockPos blockPos, BlockState blockState, TileCrusher e) { @@ -111,6 +111,14 @@ public void tick() { if (level.isClientSide) { return; } + if (currentRecipe == null) { + this.findMatchingRecipe(); + return; + } + //Checks if there is space in the output slots before processing + if(outputSlots.getStackInSlot(0).getCount() > 64 - currentRecipe.getResultItem(level.registryAccess()).copy().getCount()) return; + if(outputSlots.getStackInSlot(1).getCount() > 64 - currentRecipe.randOutput.bonus.getCount()) return; + if (this.burnTime <= 0 && this.currentRecipe != null) { this.burnTimeMax = 0; this.burnTime = 0; @@ -133,10 +141,6 @@ public void tick() { if (this.burnTime <= 0 && this.burnTimeMax == 0) { this.findMatchingRecipe(); } - if (currentRecipe == null) { - this.findMatchingRecipe(); - return; - } if (this.burnTimeMax > 0) { setLitProperty(true); // has recipe so lit int onSim = energy.extractEnergy(currentRecipe.energy.getRfPertick(), true); From 6c7c0ec96c99f9d469e7694b2218a433e9cb0732 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sun, 14 Apr 2024 19:24:08 -0700 Subject: [PATCH 05/15] - Finalizes JEI compat fixes --- .../cyclic/compat/jei/CrusherRecipeCategory.java | 16 +++++++++++++++- .../cyclic/compat/jei/MelterRecipeCategory.java | 4 +++- .../compat/jei/SolidifierRecipeCategory.java | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java index 70e144b30b..b6dc38e2a8 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java @@ -2,7 +2,11 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.crusher.RecipeCrusher; +import com.lothrazar.cyclic.block.solidifier.TileSolidifier; import com.lothrazar.cyclic.registry.BlockRegistry; +import com.lothrazar.cyclic.registry.TextureRegistry; +import com.lothrazar.library.gui.EnergyBar; +import com.lothrazar.library.gui.TexturedProgress; import com.lothrazar.library.util.ChatUtil; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; @@ -14,6 +18,7 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -26,10 +31,17 @@ public class CrusherRecipeCategory implements IRecipeCategory { static final RecipeType TYPE = new RecipeType<>(ID, RecipeCrusher.class); private IDrawable gui; private IDrawable icon; + private Font font; + private EnergyBar bar; public CrusherRecipeCategory(IGuiHelper helper) { + font = Minecraft.getInstance().font; gui = helper.drawableBuilder(new ResourceLocation(ModCyclic.MODID, "textures/jei/crusher.png"), 0, 0, 155, 49).setTextureSize(155, 49).build(); icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.CRUSHER.get())); + bar = new EnergyBar(font, TileSolidifier.MAX); + bar.setHeight(48); + bar.guiLeft = -16; + bar.guiTop = -8; } @Override @@ -55,7 +67,6 @@ public RecipeType getRecipeType() { @Override public void draw(RecipeCrusher recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics ms, double mouseX, double mouseY) { int x = 78; - var font = Minecraft.getInstance().font; if (recipe.energy.getTicks() < 40) { ms.drawString(font, recipe.energy.getTicks() + " t", x, 6, FONT); } @@ -68,6 +79,9 @@ public void draw(RecipeCrusher recipe, IRecipeSlotsView recipeSlotsView, GuiGrap if (!recipe.randOutput.bonus.isEmpty() && recipe.randOutput.percent > 0) { ms.drawString(font, recipe.randOutput.percent + "%", 56, 36, FONT); } + + bar.draw(ms, recipe.energy.getEnergyTotal()); + bar.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.energy.getEnergyTotal()); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java index 2f3aedc626..7f6b8bfe11 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java @@ -44,6 +44,8 @@ public MelterRecipeCategory(IGuiHelper helper) { icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.MELTER.get())); bar = new EnergyBar(font, TileSolidifier.MAX); progress = new TexturedProgress(font, 80, 19, 24, 17, TextureRegistry.ARROW); + bar.guiTop = -4; + bar.guiLeft = -2; } @Override @@ -80,6 +82,6 @@ public void setRecipe(IRecipeLayoutBuilder builder, RecipeMelter recipe, IFocusG builder.addSlot(RecipeIngredientRole.INPUT, 4, 19).addIngredients(recipe.at(0)); builder.addSlot(RecipeIngredientRole.INPUT, 22, 19).addIngredients(recipe.at(1)); List matchingFluids = List.of(recipe.getRecipeFluid()); - builder.addSlot(RecipeIngredientRole.OUTPUT, 136, 19).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16); + builder.addSlot(RecipeIngredientRole.OUTPUT, 132, 19).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16); } } diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java index 4d735f5011..e4afc41bfa 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/SolidifierRecipeCategory.java @@ -44,6 +44,8 @@ public SolidifierRecipeCategory(IGuiHelper helper) { icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.SOLIDIFIER.get())); bar = new EnergyBar(font, TileSolidifier.MAX); progress = new TexturedProgress(font, 63, 25, 24, 17, TextureRegistry.ARROW); + bar.guiTop = -4; + bar.guiLeft = -2; } @Override From c182ad09d2d40a608c409846290b9a60999a94fc Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sun, 14 Apr 2024 19:30:57 -0700 Subject: [PATCH 06/15] - Fixes JEI click region on gui for all compatible machines --- .../cyclic/compat/jei/CyclicPluginJEI.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java b/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java index ba516064fe..2755404181 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java @@ -104,23 +104,23 @@ public void registerRecipes(IRecipeRegistration registry) { @Override public void registerGuiHandlers(IGuiHandlerRegistration registry) { registry.addRecipeClickArea(ScreenMelter.class, - 75, 20, - 40, 26, MelterRecipeCategory.TYPE); + 68, 37, + 24, 17, MelterRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenSolidifier.class, - 75, 20, - 40, 26, SolidifierRecipeCategory.TYPE); + 68, 37, + 24, 17, SolidifierRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenGeneratorDrops.class, - 10, 10, - 40, 66, GenitemRecipeCategory.TYPE); + 74, 58, + 20, 20, GenitemRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenGeneratorFluid.class, - 50, 8, + 74, 58, 20, 20, GenfluidRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenPackager.class, - 60, 0, - 60, 30, PackagerRecipeCategory.TYPE); + 60, 4, + 52, 12, PackagerRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenCrusher.class, - 50, 0, - 40, 30, CrusherRecipeCategory.TYPE); + 76, 38, + 20, 20, CrusherRecipeCategory.TYPE); } @Override From 008b8eb67517cc90ea0d56b5ef8181ef82065974 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Sun, 14 Apr 2024 19:51:03 -0700 Subject: [PATCH 07/15] Forgot to add the edited JEI melter texture. --- .../cyclic/textures/jei/melter_recipe.png | Bin 396 -> 405 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/cyclic/textures/jei/melter_recipe.png b/src/main/resources/assets/cyclic/textures/jei/melter_recipe.png index 1f501ae523b13137493e8894d8bd3efcd0c43ae1..27358156060dbd636c2f647973678ea4077143c8 100644 GIT binary patch delta 192 zcmV;x06+hX1C;}iJPN%401mwYNBfYikwzyj6G=otRCr$P*1>6nP!vGX=_=)=0Q<27 zE3h9U%x5y$sRReEz1`#UD`(A$WnFy0000O!%=kwzyg3Q0skRCr$P)-kGsP!K>-ca`P+1-LJ_ z Date: Sun, 14 Apr 2024 19:56:47 -0700 Subject: [PATCH 08/15] Forgot to remove the string for total RF --- .../com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java index b6dc38e2a8..46e76de92f 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/CrusherRecipeCategory.java @@ -75,11 +75,9 @@ public void draw(RecipeCrusher recipe, IRecipeSlotsView recipeSlotsView, GuiGrap ms.drawString(font, sec + " s", x, 6, FONT); } ms.drawString(font, recipe.energy.getRfPertick() + " RF/t", x, 16, FONT); - ms.drawString(font, recipe.energy.getEnergyTotal() + " RF", x, 26, FONT); if (!recipe.randOutput.bonus.isEmpty() && recipe.randOutput.percent > 0) { ms.drawString(font, recipe.randOutput.percent + "%", 56, 36, FONT); } - bar.draw(ms, recipe.energy.getEnergyTotal()); bar.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.energy.getEnergyTotal()); } From d25e0c022d8ed4613250a7b135fd4ed225b8a4e9 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Tue, 16 Apr 2024 14:41:02 -0700 Subject: [PATCH 09/15] Melter category change - Made the JEI category more closely resemble the Melter gui. --- .../com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java index 7f6b8bfe11..5ea2bfae9e 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/MelterRecipeCategory.java @@ -43,7 +43,7 @@ public MelterRecipeCategory(IGuiHelper helper) { gui = helper.drawableBuilder(new ResourceLocation(ModCyclic.MODID, "textures/jei/melter_recipe.png"), 0, 0, 169, 69).setTextureSize(169, 69).build(); icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.MELTER.get())); bar = new EnergyBar(font, TileSolidifier.MAX); - progress = new TexturedProgress(font, 80, 19, 24, 17, TextureRegistry.ARROW); + progress = new TexturedProgress(font, 58, 26, 24, 17, TextureRegistry.ARROW); bar.guiTop = -4; bar.guiLeft = -2; } @@ -70,7 +70,7 @@ public RecipeType getRecipeType() { @Override public void draw(RecipeMelter recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics ms, double mouseX, double mouseY) { - ms.drawString(font, recipe.getEnergy().getRfPertick() + " RF/t", 75, 9, FONT); + ms.drawString(font, recipe.getEnergy().getRfPertick() + " RF/t", 58, 9, FONT); bar.draw(ms, recipe.getEnergy().getEnergyTotal()); progress.draw(ms, 0); bar.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.getEnergy().getEnergyTotal()); From 47c9b6d5bdb0299cd611477e2b2ff26d2ed8d683 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Tue, 16 Apr 2024 14:42:16 -0700 Subject: [PATCH 10/15] Realigned JEI click area again - For some reason the time remaining tooltip and the show recipes tooltip clashed, so I moved the click area the the title string for the generators. --- .../com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java b/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java index 2755404181..7d2764eeab 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java @@ -110,11 +110,11 @@ public void registerGuiHandlers(IGuiHandlerRegistration registry) { 68, 37, 24, 17, SolidifierRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenGeneratorDrops.class, - 74, 58, - 20, 20, GenitemRecipeCategory.TYPE); + 38, 6, + 100, 10, GenitemRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenGeneratorFluid.class, - 74, 58, - 20, 20, GenfluidRecipeCategory.TYPE); + 28, 6, + 120, 10, GenfluidRecipeCategory.TYPE); registry.addRecipeClickArea(ScreenPackager.class, 60, 4, 52, 12, PackagerRecipeCategory.TYPE); From ba04e8a5a26af80bb70ff039ed15644d334ee34a Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Tue, 16 Apr 2024 14:42:52 -0700 Subject: [PATCH 11/15] Removed ghost tank from the Evaporation Generator --- .../cyclic/block/generatorfluid/ScreenGeneratorFluid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/ScreenGeneratorFluid.java b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/ScreenGeneratorFluid.java index 0c220dce0b..56ed738bb4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/ScreenGeneratorFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/ScreenGeneratorFluid.java @@ -58,7 +58,7 @@ public void render(GuiGraphics gg, int mouseX, int mouseY, float partialTicks) { this.renderTooltip(gg, mouseX, mouseY); energy.renderHoveredToolTip(gg, mouseX, mouseY, menu.tile.getEnergy()); progress.renderHoveredToolTip(gg, mouseX, mouseY, menu.tile.getField(TileGeneratorFluid.Fields.TIMER.ordinal())); - fluid.renderHoveredToolTip(gg, mouseX, mouseY, menu.tile.getFluid()); + //fluid.renderHoveredToolTip(gg, mouseX, mouseY, menu.tile.getFluid()); btnRedstone.onValueUpdate(menu.tile); var pose = gg.pose(); pose.pushPose(); From a681f8088528607e6a6e9ef92eca395f6d7d2bb5 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Fri, 19 Apr 2024 11:22:27 -0700 Subject: [PATCH 12/15] Fixed #2403 - Added the onRemove method to the Wireless Transmitter --- .../wireless/redstone/BlockWirelessTransmit.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java index a4efee3b36..284b61aea3 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.Containers; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -44,4 +45,18 @@ public BlockEntityTicker getTicker(Level world, Block protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(POWERED); } + + @Override // was onReplaced + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (state.getBlock() != newState.getBlock()) { + TileWirelessTransmit tileentity = (TileWirelessTransmit) worldIn.getBlockEntity(pos); + if (tileentity != null) { + for (int i = 0; i < tileentity.inventory.getSlots(); ++i) { + // was InventoryHelper.spawnItemStack + Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.inventory.getStackInSlot(i)); + } + } + super.onRemove(state, worldIn, pos, newState, isMoving); + } + } } From 6d792049d5519a474f1542801b3a196f0e0445c0 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Fri, 19 Apr 2024 18:33:10 -0700 Subject: [PATCH 13/15] Fixes dupe glitch in #2358 - Checks the input before any processing happens - Recipe preview now updates when recipe grid changes instead of when it's done processing --- .../cyclic/block/crafter/TileCrafter.java | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java b/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java index 3bf644120f..020f99376e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java +++ b/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java @@ -143,11 +143,6 @@ public void serverTick() { if (timer < 0) { timer = 0; } - //timer phase - if (--timer > 0) { - return; - } - //timer is out, therefore processing Recipe lastValidRecipe = findMatchingRecipe(null); if (lastValidRecipe == null) { //reset @@ -160,6 +155,13 @@ public void serverTick() { setPreviewSlot(recipeOutput); //if we have space for the output, then go ahead if (hasFreeSpace(outHandler, recipeOutput)) { + if(!checkInput(inputHandler)) { //Checks input before processing + this.timer = TIMER_FULL; + return; + } + if (--timer > 0) { //Get recipe before processing + return; + } if (doCraft(lastValidRecipe)) { //reset the timer this.timer = TIMER_FULL; @@ -211,6 +213,35 @@ private boolean hasFreeSpace(IItemHandler inv, ItemStack output) { return test.isEmpty(); //empty means all of it was allowed to go in } + // This could be done better, but it works so ¯\_(ツ)_/¯ + private boolean checkInput(IItemHandler inv) { + IItemHandler gridHandler = this.gridCap.orElse(null); + List inputStacks = new ArrayList(); + List gridStacks = new ArrayList(); + for(int i = 0; i < inv.getSlots(); i++) { + inputStacks.add(inv.getStackInSlot(i).copy()); + } + for(int i = 0; i < gridHandler.getSlots(); i++) { + gridStacks.add(gridHandler.getStackInSlot(i).copy()); + } + for(ItemStack stack : inputStacks) { + List lolbit = new ArrayList(); + boolean match = false; + for(ItemStack grid : gridStacks) { + if(stack.getItem() == grid.getItem()) { + match = true; + lolbit.add(grid); + stack.shrink(1); + } + } + if(match) { + gridStacks.removeAll(lolbit); + } + } + if(gridStacks.isEmpty()) return true; + return false; + } + //TODO:? re-write this whole thing using ASSEMBLE? //big change // for (int i = 0; i < 9; i++) { From 21a012dd310965d11998dd60b79eb6f42ffbcf16 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Fri, 19 Apr 2024 18:42:03 -0700 Subject: [PATCH 14/15] Fixes #2322 - The fluid portion of the FluidTagIngredient is empty, so I made a work around until it is fixed in FLib. --- .../block/generatorfluid/RecipeGeneratorFluid.java | 11 +++++++++++ .../block/generatorfluid/TileGeneratorFluid.java | 1 + 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/RecipeGeneratorFluid.java b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/RecipeGeneratorFluid.java index 349b6f6b43..d3be7fe184 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/RecipeGeneratorFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/RecipeGeneratorFluid.java @@ -1,5 +1,7 @@ package com.lothrazar.cyclic.block.generatorfluid; +import java.util.List; + import com.google.gson.JsonObject; import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.registry.CyclicRecipeType; @@ -10,13 +12,16 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.registries.ForgeRegistries; public class RecipeGeneratorFluid implements Recipe { @@ -61,6 +66,12 @@ public FluidStack getRecipeFluid() { return fluidIng.getFluidStack(); } + public List getFluidsFromTag() { + TagKey tag = ForgeRegistries.FLUIDS.tags().createTagKey(new ResourceLocation(this.fluidIng.getTag())); + List list = ForgeRegistries.FLUIDS.tags().getTag(tag).stream().toList(); + return list; + } + @Override public boolean matches(TileGeneratorFluid inv, Level worldIn) { try { diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/TileGeneratorFluid.java b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/TileGeneratorFluid.java index 82d952d05a..aef344fae4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/TileGeneratorFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/TileGeneratorFluid.java @@ -121,6 +121,7 @@ private ArrayList indexFluidsFromRecipes() { ArrayList fluids = new ArrayList<>(); for (RecipeGeneratorFluid recipe : recipes) { fluids.add(recipe.getRecipeFluid().getFluid()); + fluids.addAll(recipe.getFluidsFromTag()); } return fluids; } From 1ca0c86f0ec711a6c019e4ca9aef1c938065bb6c Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Fri, 19 Apr 2024 19:14:27 -0700 Subject: [PATCH 15/15] Possible memory leak fix --- .../lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java b/src/main/java/com/lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java index 446a047e1f..aefa1446f0 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java +++ b/src/main/java/com/lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java @@ -25,12 +25,14 @@ public class PackagerRecipeCategory implements IRecipeCategory { private static final ResourceLocation ID = new ResourceLocation(ModCyclic.MODID, "packager"); static final RecipeType TYPE = new RecipeType<>(ID, CraftingRecipe.class); + Minecraft instance; private IDrawable gui; private IDrawable icon; public PackagerRecipeCategory(IGuiHelper helper) { gui = helper.drawableBuilder(new ResourceLocation(ModCyclic.MODID, "textures/jei/packager.png"), 0, 0, 118, 32).setTextureSize(118, 32).build(); icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.PACKAGER.get())); + instance = Minecraft.getInstance(); } @Override @@ -55,7 +57,7 @@ public RecipeType getRecipeType() { @Override public boolean isHandled(CraftingRecipe recipe) { - return UtilPackager.isRecipeValid(recipe, Minecraft.getInstance().level.registryAccess()); + return UtilPackager.isRecipeValid(recipe, instance.level.registryAccess()); } @Override @@ -80,6 +82,6 @@ public void setRecipe(IRecipeLayoutBuilder builder, CraftingRecipe recipe, IFocu haxor.add(cpy); } builder.addSlot(RecipeIngredientRole.INPUT, 6, 7).addIngredients(VanillaTypes.ITEM_STACK, haxor); - builder.addSlot(RecipeIngredientRole.OUTPUT, 69, 8).addItemStack(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())); + builder.addSlot(RecipeIngredientRole.OUTPUT, 69, 8).addItemStack(recipe.getResultItem(instance.level.registryAccess())); } }