diff --git a/build.gradle b/build.gradle index 795870a..de6b5cd 100644 --- a/build.gradle +++ b/build.gradle @@ -61,7 +61,7 @@ dependencies { modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}") modCompileOnly "maven.modrinth:yttr:${yttr_version}" - //modLocalRuntime "maven.modrinth:yttr:${yttr_version}" + modLocalRuntime "maven.modrinth:yttr:${yttr_version}" modImplementation("com.simibubi.create:create-fabric-1.18.2:${create_version}") diff --git a/gradle.properties b/gradle.properties index 8976f80..ad171bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ org.gradle.jvmargs=-Xmx2G # Development QOL modmenu_version=3.2.5 - rei_version=8.3.588 + rei_version=8.3.594 # yttr yttr_version = 7.626+1.18.2 diff --git a/src/main/java/com/github/ethanicuss/astraladditions/AstralAdditions.java b/src/main/java/com/github/ethanicuss/astraladditions/AstralAdditions.java index c93efe2..afb8e82 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/AstralAdditions.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/AstralAdditions.java @@ -1,5 +1,6 @@ package com.github.ethanicuss.astraladditions; +import com.github.ethanicuss.astraladditions.registry.ModFanProcessingType; import com.github.ethanicuss.astraladditions.registry.ModEntities; import com.github.ethanicuss.astraladditions.registry.ModFluids; import com.github.ethanicuss.astraladditions.registry.ModParticles; @@ -28,6 +29,7 @@ public void onInitialize() { ModEffects.registerEffects(); ModParticles.registerParticles(); ModPotion.registerPotions(); + ModFanProcessingType.registerFanProcess(); LOGGER.info("Astral Additions is active!"); } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/create/ShimmerTransmuteType.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/create/ShimmerTransmuteType.java new file mode 100644 index 0000000..f4b2299 --- /dev/null +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/create/ShimmerTransmuteType.java @@ -0,0 +1,122 @@ +package com.github.ethanicuss.astraladditions.compat.create; + +import com.github.ethanicuss.astraladditions.registry.ModFluids; +import com.github.ethanicuss.astraladditions.registry.ModParticles; +import com.github.ethanicuss.astraladditions.recipes.TransmuteRecipe; +import com.jozufozu.flywheel.util.Color; +import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.fluid.FluidState; +import net.minecraft.item.ItemStack; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Random; + +public class ShimmerTransmuteType implements FanProcessingType { + + @Override + public int getPriority() { + return 450; + } + + @Override + public boolean isValidAt(World world, BlockPos pos) { + FluidState fluid = world.getFluidState(pos); + return fluid.isStill() && fluid.getFluid() == ModFluids.STILL_SHIMMER || fluid.getFluid() == ModFluids.FLOWING_SHIMMER; + } + + @Override + public boolean canProcess(ItemStack stack, World world) { + return world.getRecipeManager() + .listAllOfType(TransmuteRecipe.Type.INSTANCE) + .stream() + .map(r -> (TransmuteRecipe) r) + .anyMatch(r -> matchesRecipeInput(stack, r)); + } + + @Override + @Nullable + public List process(ItemStack stack, World world) { + Optional recipeOpt = world.getRecipeManager() + .listAllOfType(TransmuteRecipe.Type.INSTANCE) + .stream() + .map(r -> (TransmuteRecipe) r) + .filter(r -> matchesRecipeInput(stack, r)) + .findFirst(); + + if (recipeOpt.isEmpty()) return null; + + TransmuteRecipe recipe = recipeOpt.get(); + ItemStack required = recipe.getInputItem(); + + int multiplier = 1; + + if (!recipe.isIgnoreCount()) { + if (recipe.isSoftIgnoreCount()) { + multiplier = stack.getCount() / required.getCount(); + } else { + if (stack.getCount() != required.getCount()) return null; + } + } + + List result = new ArrayList<>(); + for (ItemStack output : recipe.getOutputItems()) { + ItemStack out = output.copy(); + out.setCount(out.getCount() * multiplier); + result.add(out); + } + + return result; + } + + private boolean matchesRecipeInput(ItemStack stack, TransmuteRecipe recipe) { + ItemStack required = recipe.getInputItem(); + + if (recipe.isIgnoreCount()) { + return stack.getItem() == required.getItem(); + } else if (recipe.isSoftIgnoreCount()) { + return stack.getItem() == required.getItem() + && stack.getCount() >= required.getCount(); + } else { + return stack.getItem() == required.getItem() + && stack.getCount() == required.getCount(); + } + } + + @Override + public void spawnProcessingParticles(World world, Vec3d pos) { + if (world.random.nextInt(6) != 0) return; + world.addParticle(ParticleTypes.ENCHANT, pos.x, pos.y + .3, pos.z, 0, .1, 0); + } + + + @Override + public void morphAirFlow(AirFlowParticleAccess particleAccess, Random random) { + particleAccess.setColor(Color.mixColors(0xf543bc, 0xf993c5, random.nextFloat())); + particleAccess.setAlpha(0.75f); + if (random.nextFloat() < 1 / 128f) + particleAccess.spawnExtraParticle(ModParticles.SHIMMER_BUBBLE, .125f); + if (random.nextFloat() < 1 / 128f) + particleAccess.spawnExtraParticle(ModParticles.SHIMMER_BUBBLE_POP, .125f); + } + + + @Override + public void affectEntity(Entity entity, World world) { + if (!(entity instanceof LivingEntity living)) return; + living.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 60, 0, false, false)); + living.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 330, 0, false, false)); + + + } +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/AstralAdditionsREIClientPlugin.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/AstralAdditionsREIClientPlugin.java index fc5de99..dc5cc71 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/AstralAdditionsREIClientPlugin.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/AstralAdditionsREIClientPlugin.java @@ -1,7 +1,7 @@ package com.github.ethanicuss.astraladditions.compat.rei; - import com.github.ethanicuss.astraladditions.AstralAdditions; +import com.github.ethanicuss.astraladditions.compat.rei.create.BulkShimmeringCategory; import com.github.ethanicuss.astraladditions.compat.rei.desizer.DesizerCategory; import com.github.ethanicuss.astraladditions.compat.rei.desizer.DesizerDisplay; import com.github.ethanicuss.astraladditions.compat.rei.transmute.TransmuteCategory; @@ -24,6 +24,13 @@ import com.github.ethanicuss.astraladditions.recipes.ChromaticVacuumRecipe; import com.github.ethanicuss.astraladditions.registry.ModBlocks; import com.github.ethanicuss.astraladditions.registry.ModItems; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllItems; +import com.simibubi.create.compat.rei.DoubleItemIcon; +import com.simibubi.create.compat.rei.EmptyBackground; +import com.simibubi.create.compat.rei.category.CreateRecipeCategory; +import com.simibubi.create.compat.rei.display.CreateDisplay; +import com.unascribed.yttr.crafting.*; import com.unascribed.yttr.init.YEnchantments; import com.unascribed.yttr.init.YItems; import com.unascribed.yttr.init.YRecipeTypes; @@ -33,24 +40,27 @@ import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.EntryStacks; -import net.minecraft.client.MinecraftClient; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtString; -import net.minecraft.recipe.RecipeManager; import net.minecraft.recipe.RecipeType; +import net.minecraft.recipe.StonecuttingRecipe; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; +import java.util.Collections; import java.util.List; import java.util.Map; +@Environment(EnvType.CLIENT) public class AstralAdditionsREIClientPlugin implements REIClientPlugin { public static final CategoryIdentifier DESIZER = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "desizer")); @@ -65,6 +75,9 @@ public class AstralAdditionsREIClientPlugin implements REIClientPlugin { public static final CategoryIdentifier VOID_FILTERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "void_filtering")); public static final CategoryIdentifier SHATTERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "shattering")); + //* Create + public static final CategoryIdentifier> BULK_SHIMMERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "bulk_shimmering")); + @Override public void registerCategories(CategoryRegistry registry) { registry.add(new DesizerCategory()); @@ -103,53 +116,70 @@ public void registerCategories(CategoryRegistry registry) { registry.addWorkstations(SHATTERING, EntryStacks.of(shatteringBook)); + CreateRecipeCategory.Info shimmerInfo = new CreateRecipeCategory.Info<>(BULK_SHIMMERING, new TranslatableText("category.astraladditions.bulk_shimmering"), new EmptyBackground(178, 110), + new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(ModFluids.SHIMMER_BUCKET)), + Collections::emptyList, + List.of(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(ModFluids.SHIMMER_BUCKET)), + 178, 110, recipe -> new CreateDisplay<>(recipe, BULK_SHIMMERING)); + + BulkShimmeringCategory bulkShimmeringCategory = new BulkShimmeringCategory(shimmerInfo); + registry.add(bulkShimmeringCategory); + + registry.addWorkstations(BULK_SHIMMERING, EntryStacks.of(AllBlocks.ENCASED_FAN.get())); } @Override public void registerDisplays(DisplayRegistry registry) { - RecipeManager recipeManager = MinecraftClient.getInstance().world.getRecipeManager(); + registry.registerRecipeFiller(DesizerRecipe.class, DesizerRecipe.Type.INSTANCE, DesizerDisplay::of); - List desizerRecipes = recipeManager.listAllOfType(DesizerRecipe.Type.INSTANCE).stream().map(DesizerDisplay::of).toList(); - desizerRecipes.forEach(registry::add); + registry.registerRecipeFiller(TransmuteRecipe.class, TransmuteRecipe.Type.INSTANCE, TransmuteDisplay::of); - List transmuteRecipes = recipeManager.listAllOfType(TransmuteRecipe.Type.INSTANCE).stream().map(TransmuteDisplay::of).toList(); - transmuteRecipes.forEach(registry::add); - - registry.registerFiller(ChromaticVacuumRecipe.class, VacuumDisplay::of); + registry.registerRecipeFiller(ChromaticVacuumRecipe.class, ChromaticVacuumRecipe.Type.INSTANCE, VacuumDisplay::of); //* YTTR - List centrifugeRecipes = recipeManager.listAllOfType(YRecipeTypes.CENTRIFUGING).stream().map(CentrifugeDisplay::of).toList(); - centrifugeRecipes.forEach(registry::add); - - List pistonSmashingRecipes = recipeManager.listAllOfType(YRecipeTypes.PISTON_SMASHING).stream().map(PistonSmashingDisplay::of).toList(); - pistonSmashingRecipes.forEach(registry::add); - - List soakingRecipes = recipeManager.listAllOfType(YRecipeTypes.SOAKING).stream().map(SoakingDisplay::of).toList(); - soakingRecipes.forEach(registry::add); - - List voidFilteringRecipe = recipeManager.listAllOfType(YRecipeTypes.VOID_FILTERING).stream().map(VoidFilteringDisplay::of).toList(); - voidFilteringRecipe.forEach(registry::add); - - //Shattering stuff - List shatteringRecipes = recipeManager.listAllOfType(YRecipeTypes.SHATTERING).stream() - .map(ShatteringDisplay::of) - .toList(); - shatteringRecipes.forEach(registry::add); - - List shatteringstonecuttingRecipes = recipeManager.listAllOfType(RecipeType.STONECUTTING).stream() - .filter(r -> r.getOutput().getCount() == 1 && !r.getIngredients().isEmpty()) - .map(ShatteringDisplay::of) - .toList(); - shatteringstonecuttingRecipes.forEach(registry::add); - - List shatteringoneByOneCraftingRecipes = recipeManager.listAllOfType(RecipeType.CRAFTING).stream() - .filter(r -> r.fits(1, 1) && !r.getIngredients().isEmpty()) - .map(ShatteringDisplay::of) - .toList(); - shatteringoneByOneCraftingRecipes.forEach(registry::add); + registry.registerRecipeFiller(CentrifugingRecipe.class, YRecipeTypes.CENTRIFUGING, CentrifugeDisplay::of); + + registry.registerRecipeFiller(PistonSmashingRecipe.class, YRecipeTypes.PISTON_SMASHING, PistonSmashingDisplay::of); + + registry.registerRecipeFiller(SoakingRecipe.class, YRecipeTypes.SOAKING, SoakingDisplay::of); + + registry.registerRecipeFiller(VoidFilteringRecipe.class, YRecipeTypes.VOID_FILTERING, VoidFilteringDisplay::of); + + registry.registerRecipeFiller(ShatteringRecipe.class, YRecipeTypes.SHATTERING, ShatteringDisplay::of); + + registry.registerRecipeFiller(StonecuttingRecipe.class, RecipeType.STONECUTTING, ShatteringDisplay::ofStonecutting); + + registry.registerRecipeFiller( + net.minecraft.recipe.CraftingRecipe.class, + RecipeType.CRAFTING, + recipe -> { + if (recipe instanceof ShatteringRecipe) return null; + + if (recipe.getIngredients().size() != 1) return null; + if (recipe.getIngredients().get(0).isEmpty()) return null; + + ItemStack out = recipe.getOutput(); + if (out.isEmpty()) return null; + + return ShatteringDisplay.ofWrappedCrafting(recipe); + } + ); + + registry.registerRecipeFiller( + TransmuteRecipe.class, + TransmuteRecipe.Type.INSTANCE, + recipe -> { + ItemStack out = recipe.getOutput(); + if (out == null || out.isEmpty()) { + return null; + } + return new CreateDisplay<>(recipe, BULK_SHIMMERING); + } + ); } + @Override public void registerScreens(ScreenRegistry registry) { REIClientPlugin.super.registerScreens(registry); diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/create/BulkShimmeringCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/create/BulkShimmeringCategory.java new file mode 100644 index 0000000..720cc35 --- /dev/null +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/create/BulkShimmeringCategory.java @@ -0,0 +1,155 @@ +package com.github.ethanicuss.astraladditions.compat.rei.create; + +import com.github.ethanicuss.astraladditions.recipes.TransmuteRecipe; +import com.github.ethanicuss.astraladditions.registry.ModFluids; +import com.simibubi.create.compat.rei.category.ProcessingViaFanCategory; +import com.simibubi.create.compat.rei.category.animations.AnimatedKinetics; +import com.simibubi.create.compat.rei.display.CreateDisplay; +import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.gui.element.GuiGameElement; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.widgets.Slot; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; + +import java.util.ArrayList; +import java.util.List; + +public class BulkShimmeringCategory extends ProcessingViaFanCategory { + + public BulkShimmeringCategory(Info info) { + super(info); + } + + @Override + protected void renderAttachedBlock(MatrixStack matrices) { + GuiGameElement.of(ModFluids.STILL_SHIMMER) + .scale(SCALE) + .atLocal(0, 0, 2) + .lighting(AnimatedKinetics.DEFAULT_LIGHTING) + .render(matrices); + } + + @Override + public void addWidgets(CreateDisplay display, List widgets, Point origin) { + List outputs = display.getRecipe().getOutputItems(); + if (outputs == null || outputs.isEmpty()) { + super.addWidgets(display, widgets, origin); + return; + } + + final int pageSize = 4; + final int total = outputs.size(); + final int pageCount = (total + pageSize - 1) / pageSize; + final int[] page = {0}; + + widgets.add(Widgets.createSlot(new Point(origin.x + 21, origin.y + 48)).entries(display.getInputEntries().get(0)).markInput()); + + final int baseXLocal = 130; + final int baseYLocal = 48; + final int cell = 19; + + List pageSlots = new ArrayList<>(); + Widget[] pageLabel = new Widget[1]; + + Runnable reloadPage = () -> { + widgets.removeAll(pageSlots); + pageSlots.clear(); + + if (pageLabel[0] != null) { + widgets.remove(pageLabel[0]); + pageLabel[0] = null; + } + + int baseIndex = page[0] * pageSize; + int countOnPage = Math.min(pageSize, total - baseIndex); + + for (int index = 0; index < countOnPage; index++) { + int outIndex = baseIndex + index; + + int col = index % 2; + int row = index / 2; + + int xLocal = baseXLocal + col * cell; + int yLocal = baseYLocal + row * cell; + + Slot slot = Widgets.createSlot(new Point(origin.x + xLocal, origin.y + yLocal)) + .entries(EntryIngredients.of(outputs.get(outIndex))) + .markOutput(); + + pageSlots.add(slot); + widgets.add(slot); + } + + if (pageCount > 1) { + int labelX = origin.x + baseXLocal + cell; + int labelY = origin.y + 33; + + Text text = Text.of((page[0] + 1) + "/" + pageCount); + pageLabel[0] = Widgets.createLabel(new Point(labelX, labelY), text) + .noShadow() + .color(0xFFFFFF, 0xAAAAAA) + .centered(); + + widgets.add(pageLabel[0]); + } + }; + + reloadPage.run(); + + if (pageCount > 1) { + int labelX = origin.x + baseXLocal + cell; + int buttonY = origin.y + 30; + + Rectangle backBounds = new Rectangle(labelX - 24, buttonY, 12, 12); + Widget backButton = Widgets.createButton(backBounds, Text.of("<")).onClick(btn -> { + page[0] = (page[0] - 1 + pageCount) % pageCount; + reloadPage.run(); + }); + widgets.add(backButton); + + Rectangle nextBounds = new Rectangle(labelX + 12, buttonY, 12, 12); + Widget nextButton = Widgets.createButton(nextBounds, Text.of(">")).onClick(btn -> { + page[0] = (page[0] + 1) % pageCount; + reloadPage.run(); + }); + widgets.add(nextButton); + } + } + + @Override + public void addWidgets(CreateDisplay display, List widgets, Point origin, Rectangle bounds) { + TransmuteRecipe recipe = display.getRecipe(); + Text hint = getHintText(recipe); + + int centerX = bounds.getCenterX(); + int centerY = bounds.getCenterY(); + + widgets.add(Widgets.createLabel(new Point(centerX - 75, centerY + 42), hint).leftAligned()); + } + + + @Override + protected void renderWidgets(MatrixStack matrices, TransmuteRecipe recipe, double mouseX, double mouseY) { + AllGuiTextures.JEI_SHADOW.render(matrices, 46, 29); + getBlockShadow().render(matrices, 65, 39); + AllGuiTextures.JEI_LONG_ARROW.render(matrices, 54, 51); + } + + private Text getHintText(TransmuteRecipe recipe) { + int count = recipe.getInputItem().getCount(); + if (recipe.isIgnoreCount()) { + return new TranslatableText("label.astraladditions.transmute_hint_any"); + } else if (recipe.isSoftIgnoreCount()) { + return new TranslatableText("label.astraladditions.transmute_hint_least", count); + } else { + return new TranslatableText("label.astraladditions.transmute_hint_exactly", count); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/desizer/DesizerCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/desizer/DesizerCategory.java index 0b9c2e8..64e962b 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/desizer/DesizerCategory.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/desizer/DesizerCategory.java @@ -117,7 +117,7 @@ public List setupDisplay(DesizerDisplay display, Rectangle bounds) { private void updateLayerLabelAndGrid(int newLayer, List inputs, Widget[] layerLabel, List gridWidgets, List widgets, int startX, int startY, int buttonY) { - + widgets.remove(layerLabel[0]); layerLabel[0] = createLayerLabel(startX, buttonY, newLayer); widgets.add(layerLabel[0]); @@ -138,4 +138,4 @@ private Widget createLayerLabel(int startX, int buttonY, int layer) { public int getDisplayHeight() { return 90; } -} +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumCategory.java index 48da339..38e087c 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumCategory.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumCategory.java @@ -13,6 +13,7 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; @@ -23,7 +24,6 @@ import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; -import java.util.Collections; import java.util.List; public class VacuumCategory implements DisplayCategory { @@ -54,9 +54,8 @@ public List setupDisplay(VacuumDisplay display, Rectangle bounds) { int centerX = bounds.getCenterX(); int centerY = bounds.getCenterY(); - widgets.add(Widgets.createSlot(new Point(centerX - 8, centerY - 43)) - .entries(Collections.singletonList(EntryStacks.of(ModItems.CHROMATIC_VACUUM)))); + .entries(EntryIngredients.of(ModItems.CHROMATIC_VACUUM))); widgets.add(new RotatedArrowWidget(new Point(centerX - 11, centerY - 20), 90)); @@ -64,37 +63,29 @@ public List setupDisplay(VacuumDisplay display, Rectangle bounds) { .entries(inputs.get(0)) .markInput()); - widgets.add(CurvedArrowWidget.of(new Point(centerX + 11, centerY + 9), 90, false)); if (!display.getRemainderEntries().isEmpty()) { widgets.add(CurvedArrowWidget.of(new Point(centerX - 27, centerY + 9), -90, true)); - ItemStack outputRemainder = (ItemStack) display.getRemainderEntries().get(0).get(0).getValue(); + ItemStack outputRemainder = ((ItemStack) display.getRemainderEntries().get(0).get(0).getValue()).copy(); - if (!outputRemainder.hasNbt()) { - outputRemainder.setNbt(new NbtCompound()); - } NbtCompound displayTag = outputRemainder.getOrCreateSubNbt("display"); - NbtList lore = new NbtList(); - lore.add(NbtString.of(Text.Serializer.toJson( - new TranslatableText("category.astraladditions.vacuum.remainder_hint") - .setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.YELLOW)) + lore.add(NbtString.of(Text.Serializer.toJson(new TranslatableText("category.astraladditions.vacuum.remainder_hint") + .setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.YELLOW)) ))); displayTag.put("Lore", lore); widgets.add(Widgets.createSlot(new Point(centerX - 28, centerY + 28)) - .entries(Collections.singletonList(EntryStacks.of(outputRemainder))) + .entries(EntryIngredients.of(outputRemainder)) .markOutput()); - - } + widgets.add(Widgets.createSlot(new Point(centerX + 13, centerY + 28)) .entries(outputs.get(0)) .markOutput()); - return widgets; } diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumDisplay.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumDisplay.java index e40e007..97dcb11 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumDisplay.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/vacuum/VacuumDisplay.java @@ -8,7 +8,6 @@ import me.shedaniel.rei.api.common.util.EntryIngredients; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; import net.minecraft.util.Identifier; import java.util.Collections; @@ -23,7 +22,7 @@ public VacuumDisplay(Identifier id, List inputs, List outputs, List remainder) { - super(inputs, outputs, Optional.ofNullable(id)); // REI 8.x ctor + super(inputs, outputs, Optional.ofNullable(id)); this.remainderEntries = (remainder == null) ? Collections.emptyList() : remainder; } @@ -36,23 +35,22 @@ public List getRemainderEntries() { return remainderEntries; } - /** Return null to let REI skip invalid/unsynced recipes. */ - public static VacuumDisplay of(Recipe recipe) { - if (!(recipe instanceof ChromaticVacuumRecipe chromatic)) return null; - - ItemStack ing = chromatic.getIngredient(); // if yours actually returns Ingredient, change type + EntryIngredients.of(ing) - if (ing == null || ing.isEmpty()) return null; + public static VacuumDisplay of(ChromaticVacuumRecipe chromatic) { + Ingredient ing = chromatic.getIngredients().isEmpty() ? Ingredient.EMPTY : chromatic.getIngredients().get(0); + if (ing.isEmpty()) return null; ItemStack out = chromatic.getOutput(); - if (out == null || out.isEmpty()) return null; + if (out.isEmpty()) return null; + + List inputs = Collections.singletonList(EntryIngredients.ofIngredient(ing)); + List outputs = Collections.singletonList(EntryIngredients.of(out.copy())); - List inputs = Collections.singletonList(EntryIngredients.of(ing)); - List outputs = Collections.singletonList(EntryIngredients.of(out)); + ItemStack rem = chromatic.getRemainder(); List remainders = - chromatic.hasRemainder() && chromatic.getRemainder() != null && !chromatic.getRemainder().isEmpty() - ? Collections.singletonList(EntryIngredients.of(chromatic.getRemainder())) + chromatic.hasRemainder() && !rem.isEmpty() + ? Collections.singletonList(EntryIngredients.of(rem.copy())) : Collections.emptyList(); - return new VacuumDisplay(recipe.getId(), inputs, outputs, remainders); + return new VacuumDisplay(chromatic.getId(), inputs, outputs, remainders); } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/widgets/BlockFaceWidget.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/widgets/BlockFaceWidget.java index 46ef135..07c85d8 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/widgets/BlockFaceWidget.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/widgets/BlockFaceWidget.java @@ -23,7 +23,7 @@ public class BlockFaceWidget extends WidgetWithBounds { private final Supplier blockSupplier; private final Point position; - private final Direction side; //kinda forgot about this part + private final Direction side; private final int rotationDegrees; private final boolean showTooltip; diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/centrifuging/CentrifugeDisplay.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/centrifuging/CentrifugeDisplay.java index 3aa02c8..284f85d 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/centrifuging/CentrifugeDisplay.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/centrifuging/CentrifugeDisplay.java @@ -6,8 +6,8 @@ import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; import net.minecraft.util.Identifier; import java.util.Arrays; @@ -27,23 +27,23 @@ public CategoryIdentifier getCategoryIdentifier() { return AstralAdditionsREIClientPlugin.CENTRIFUGE; } - public static CentrifugeDisplay of(Recipe recipe) { - CentrifugingRecipe centrifugingRecipe = (CentrifugingRecipe) recipe; - - Ingredient ingredient = centrifugingRecipe.getInput(); + public static CentrifugeDisplay of(CentrifugingRecipe recipe) { + Ingredient ingredient = recipe.getInput(); + int count = recipe.getInputCount(); List inputs = Collections.singletonList( EntryIngredient.of( - Arrays.stream(ingredient.getMatchingStacks()) - .map(EntryStacks::of) - .toList() + Arrays.stream(ingredient.getMatchingStacks()).map(stack -> { + ItemStack copy = stack.copy(); + copy.setCount(count); + return EntryStacks.of(copy);}).toList() ) ); - List outputs = centrifugingRecipe.getOutputs().stream() - .map(stack -> EntryIngredient.of(EntryStacks.of(stack))) + List outputs = recipe.getOutputs().stream() + .map(stack -> EntryIngredient.of(EntryStacks.of(stack.copy()))) .toList(); return new CentrifugeDisplay(recipe.getId(), inputs, outputs); } -} +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingCategory.java index 0843bd8..becc887 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingCategory.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingCategory.java @@ -7,7 +7,6 @@ import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.item.TooltipContext; import me.shedaniel.rei.api.client.gui.widgets.Widget; diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingDisplay.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingDisplay.java index 3457c55..88922ce 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingDisplay.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/pistonsmashing/PistonSmashingDisplay.java @@ -12,7 +12,6 @@ import net.minecraft.block.Blocks; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Recipe; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -20,10 +19,8 @@ import java.util.List; public class PistonSmashingDisplay extends BasicDisplay { - private final PistonSmashingRecipe recipe; - private final Identifier id; private final boolean hasCloud; private final int cloudColor; @@ -31,12 +28,10 @@ public class PistonSmashingDisplay extends BasicDisplay { private final EntryStack cloudOutput; private final List cloudEffects; - private final Block inputBlock; - private final Block catalystBlock; + private final List inputMatches; + private final List catalystMatches; - public PistonSmashingDisplay(Identifier id, List inputs, List outputs, - boolean hasCloud, int cloudColor, int cloudSize, EntryStack cloudOutput, List cloudEffects, - Block inputBlock, Block catalystBlock, PistonSmashingRecipe recipe) { + public PistonSmashingDisplay(Identifier id, List inputs, List outputs, boolean hasCloud, int cloudColor, int cloudSize, EntryStack cloudOutput, List cloudEffects, List inputMatches, List catalystMatches, PistonSmashingRecipe recipe) { super(inputs, outputs); this.id = id; this.hasCloud = hasCloud; @@ -44,92 +39,75 @@ public PistonSmashingDisplay(Identifier id, List inputs, List matching = Registry.BLOCK.stream() - .filter(block -> recipe.getInput().test(block.getDefaultState().getBlock())) - .toList(); - if (matching.isEmpty()) return Blocks.AIR; - int index = (int) ((System.currentTimeMillis() / 1000) % matching.size()); - return matching.get(index); + if (inputMatches.isEmpty()) return Blocks.AIR; + int index = (int) ((System.currentTimeMillis() / 1000) % inputMatches.size()); + return inputMatches.get(index); } public Block getCatalystBlock() { - List matching = Registry.BLOCK.stream() - .filter(block -> recipe.getCatalyst().test(block.getDefaultState().getBlock())) - .toList(); - if (matching.isEmpty()) return Blocks.AIR; - int index = (int) ((System.currentTimeMillis() / 1000) % matching.size()); - return matching.get(index); - } - - public boolean hasCloud() { - return hasCloud; + if (catalystMatches.isEmpty()) return Blocks.AIR; + int index = (int) ((System.currentTimeMillis() / 1000) % catalystMatches.size()); + return catalystMatches.get(index); } - public int getCloudColor() { - return cloudColor; - } - - public int getCloudSize() { - return cloudSize; - } - - public EntryStack getCloudOutput() { - return cloudOutput; - } - - public List getCloudEffects() { - return cloudEffects; - } + public boolean hasCloud() { return hasCloud; } + public int getCloudColor() { return cloudColor; } + public int getCloudSize() { return cloudSize; } + public EntryStack getCloudOutput() { return cloudOutput; } + public List getCloudEffects() { return cloudEffects; } @Override public CategoryIdentifier getCategoryIdentifier() { return AstralAdditionsREIClientPlugin.PISTON_SMASHING; } - public static PistonSmashingDisplay of(Recipe recipe) { - PistonSmashingRecipe pistonRecipe = (PistonSmashingRecipe) recipe; + public static PistonSmashingDisplay of(PistonSmashingRecipe recipe) { + List inputBlocks = Registry.BLOCK.stream() + .filter(block -> recipe.getInput().test(block)) + .toList(); - List input = Collections.singletonList( - EntryIngredient.of( - Registry.BLOCK.stream() - .filter(block -> pistonRecipe.getInput().test(block.getDefaultState().getBlock())) - .map(block -> EntryStacks.of(new ItemStack(block))) - .toList() - ) + List catalystBlocks = Registry.BLOCK.stream() + .filter(block -> recipe.getCatalyst().test(block)) + .toList(); + + EntryIngredient catalystIng = EntryIngredient.of( + catalystBlocks.stream() + .map(block -> EntryStacks.of(new ItemStack(block))) + .toList() + ); + + EntryIngredient inputIng = EntryIngredient.of( + inputBlocks.stream() + .map(block -> EntryStacks.of(new ItemStack(block))) + .toList() ); - List output = Collections.singletonList( - EntryIngredients.of(pistonRecipe.getOutput()) + List inputs = List.of(catalystIng, inputIng); + + List outputs = Collections.singletonList( + EntryIngredients.of(recipe.getOutput()) ); - EntryStack cloudOutput = EntryStacks.of(pistonRecipe.getCloudOutput()); - - Block inputBlock = Registry.BLOCK.stream() - .filter(block -> pistonRecipe.getInput().test(block.getDefaultState().getBlock())) - .findFirst() - .orElse(Blocks.AIR); - - Block catalystBlock = Registry.BLOCK.stream() - .filter(block -> pistonRecipe.getCatalyst().test(block.getDefaultState().getBlock())) - .findFirst() - .orElse(Blocks.AIR); - - return new PistonSmashingDisplay(recipe.getId(), input, - output, - pistonRecipe.hasCloud(), - pistonRecipe.getCloudColor(), - pistonRecipe.getCloudSize(), - cloudOutput, - pistonRecipe.getCloudEffects(), - inputBlock, - catalystBlock, - (PistonSmashingRecipe) recipe + EntryStack cloudOut = EntryStacks.of(recipe.getCloudOutput()); + + return new PistonSmashingDisplay( + recipe.getId(), + inputs, + outputs, + recipe.hasCloud(), + recipe.getCloudColor(), + recipe.getCloudSize(), + cloudOut, + recipe.getCloudEffects(), + inputBlocks, + catalystBlocks, + recipe ); } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringCategory.java index 2ebe3b4..5bac18c 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringCategory.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringCategory.java @@ -1,9 +1,6 @@ package com.github.ethanicuss.astraladditions.compat.rei.yttr.shattering; -import com.github.ethanicuss.astraladditions.AstralAdditions; import com.github.ethanicuss.astraladditions.compat.rei.AstralAdditionsREIClientPlugin; -import com.github.ethanicuss.astraladditions.compat.rei.transmute.TransmuteDisplay; -import com.github.ethanicuss.astraladditions.compat.rei.vacuum.VacuumDisplay; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; @@ -31,7 +28,6 @@ public class ShatteringCategory implements DisplayCategory { - @Override public Text getTitle() { return new TranslatableText("category.astraladditions.shattering"); @@ -58,7 +54,7 @@ public List setupDisplay(ShatteringDisplay display, Rectangle bounds) { Point startPoint = new Point(bounds.getCenterX() - 40, bounds.getCenterY() - 9); if (display.isExclusive()) { widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { - int v = ConfigObject.getInstance().isUsingDarkTheme() ? 17 : 0; + int v = ConfigObject.getInstance().isUsingDarkTheme() ? 18 : 0; Identifier texture = Yttr.id("textures/gui/shattering.png"); diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringDisplay.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringDisplay.java index 98936e9..8962033 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringDisplay.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/shattering/ShatteringDisplay.java @@ -7,50 +7,68 @@ import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.item.ItemStack; import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.StonecuttingRecipe; import net.minecraft.util.Identifier; -import java.util.Collections; import java.util.List; public class ShatteringDisplay extends BasicDisplay { private final Identifier id; private final boolean exclusive; - public ShatteringDisplay(Identifier id, List inputs, List outputs, boolean exclusive) { - super(inputs, outputs); + private ShatteringDisplay(Identifier id, EntryIngredient input, EntryIngredient output, boolean exclusive) { + super(List.of(input), List.of(output)); this.id = id; this.exclusive = exclusive; } - public boolean isExclusive() { - return exclusive; + public static ShatteringDisplay of(ShatteringRecipe recipe) { + EntryIngredient input = EntryIngredients.ofIngredient(recipe.getIngredients().get(0)); + EntryIngredient output = EntryIngredients.of(recipe.getOutput().copy()); + return new ShatteringDisplay(recipe.getId(), input, output, true); } - @Override - public CategoryIdentifier getCategoryIdentifier() { - return AstralAdditionsREIClientPlugin.SHATTERING; + public static ShatteringDisplay ofWrappedCrafting(Recipe recipe) { + Identifier id = Yttr.id("shattering/" + recipe.getId().getNamespace() + "/" + recipe.getId().getPath()); + + if (recipe.getIngredients().isEmpty() || recipe.getIngredients().get(0).isEmpty()) return null; + + ItemStack out = recipe.getOutput(); + if (out.isEmpty()) return null; + + EntryIngredient input = EntryIngredients.ofIngredient(recipe.getIngredients().get(0)); + EntryIngredient output = EntryIngredients.of(out.copy()); + return new ShatteringDisplay(id, input, output, false); } - public static ShatteringDisplay of(Recipe recipe) { - List inputs = recipe.getIngredients().stream() - .map(EntryIngredients::ofIngredient) - .toList(); + public static ShatteringDisplay ofStonecutting(StonecuttingRecipe recipe) { + Identifier id = Yttr.id("shattering/" + recipe.getId().getNamespace() + "/" + recipe.getId().getPath()); + + if (recipe.getIngredients().isEmpty() || recipe.getIngredients().get(0).isEmpty()) return null; - List outputs = Collections.singletonList( - EntryIngredients.of(recipe.getOutput()) - ); + ItemStack stonecutOut = recipe.getOutput(); + if (stonecutOut.isEmpty()) return null; - Identifier id; - boolean exclusive = recipe instanceof ShatteringRecipe; + EntryIngredient input = EntryIngredient.of(EntryStacks.of(stonecutOut.copy())); - if (exclusive) { - id = recipe.getId(); - } else { - id = Yttr.id("shattering/" + recipe.getId().getNamespace() + "/" + recipe.getId().getPath()); - } + ItemStack[] matches = recipe.getIngredients().get(0).getMatchingStacks(); + if (matches.length == 0) return null; - return new ShatteringDisplay(id, inputs, outputs, exclusive); + EntryIngredient output = EntryIngredient.of(EntryStacks.of(matches[0].copy())); + return new ShatteringDisplay(id, input, output, true); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return AstralAdditionsREIClientPlugin.SHATTERING; + } + + public boolean isExclusive() { + return exclusive; } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingCategory.java index 642c358..1d5704f 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingCategory.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingCategory.java @@ -24,7 +24,6 @@ public class SoakingCategory implements DisplayCategory { @Override public Text getTitle() { return new TranslatableText("category.astraladditions.soaking"); - } @Override diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingDisplay.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingDisplay.java index f7912c5..ae1e4bf 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingDisplay.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/soaking/SoakingDisplay.java @@ -1,79 +1,56 @@ package com.github.ethanicuss.astraladditions.compat.rei.yttr.soaking; import com.github.ethanicuss.astraladditions.compat.rei.AstralAdditionsREIClientPlugin; -import com.mojang.datafixers.util.Either; import com.unascribed.yttr.crafting.SoakingRecipe; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; import net.minecraft.util.Identifier; -import net.minecraft.util.collection.DefaultedList; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class SoakingDisplay extends BasicDisplay { private final Identifier id; private final List catalystEntries; - public SoakingDisplay(Identifier id, List inputs, List outputs, List catalystEntries) { + private SoakingDisplay(Identifier id, List inputs, List outputs, List catalystEntries) { super(inputs, outputs); this.id = id; this.catalystEntries = catalystEntries; } + public static SoakingDisplay of(SoakingRecipe recipe) { + List inputs = new ArrayList<>(); - public List getCatalystEntries() { - return catalystEntries; - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return AstralAdditionsREIClientPlugin.SOAKING; - } - - public static SoakingDisplay of(Recipe recipe) { - SoakingRecipe soakingRecipe = (SoakingRecipe) recipe; + recipe.getSoakingIngredients() + .ifLeft(stack -> inputs.add(EntryIngredients.of(stack))) + .ifRight(list -> { + for (Ingredient ingredient : list) { + inputs.add(EntryIngredients.ofIngredient(ingredient)); + } + }); - List inputs; - Either> soakingIngredients = soakingRecipe.getSoakingIngredients(); + ItemStack output = recipe.getOutput().copy(); + List outputs = Collections.singletonList(EntryIngredients.of(output)); - if (soakingIngredients.left().isPresent()) { - ItemStack stack = soakingIngredients.left().get(); - inputs = List.of(EntryIngredients.of(stack)); - } else { - DefaultedList ingredientList = soakingIngredients.right().orElse(DefaultedList.of()); - if (!ingredientList.isEmpty()) { - Ingredient ingredient = ingredientList.get(0); - ItemStack[] matchingStacks = ingredient.getMatchingStacks(); - if (matchingStacks.length > 0) { - ItemStack stack = matchingStacks[0].copy(); - inputs = List.of(EntryIngredients.of(stack)); - } else { - inputs = List.of(); - } - } else { - inputs = List.of(); - } - } - - ItemStack outputStack = soakingRecipe.getResult().map( - itemStack -> itemStack, - blockState -> new ItemStack(blockState.getBlock()) + List catalystEntries = Collections.singletonList( + EntryIngredient.of(recipe.getCatalyst().getMatchingFluids().stream().map(EntryStacks::of).toList()) ); - List outputs = List.of( - EntryIngredients.of(outputStack) - ); + return new SoakingDisplay(recipe.getId(), inputs, outputs, catalystEntries); + } - List catalystEntries = List.of( - EntryIngredient.of(EntryStacks.of(soakingRecipe.getCatalyst().getMatchingFluids().get(0))) - ); + @Override + public me.shedaniel.rei.api.common.category.CategoryIdentifier getCategoryIdentifier() { + return AstralAdditionsREIClientPlugin.SOAKING; + } - return new SoakingDisplay(recipe.getId(), inputs, outputs, catalystEntries); + public List getCatalystEntries() { + return catalystEntries; } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringCategory.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringCategory.java index fd8cbfb..4964b8b 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringCategory.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringCategory.java @@ -1,9 +1,6 @@ package com.github.ethanicuss.astraladditions.compat.rei.yttr.voidfiltering; import com.github.ethanicuss.astraladditions.compat.rei.AstralAdditionsREIClientPlugin; -import com.github.ethanicuss.astraladditions.compat.rei.transmute.TransmuteDisplay; -import com.github.ethanicuss.astraladditions.compat.rei.vacuum.VacuumDisplay; -import com.github.ethanicuss.astraladditions.compat.rei.yttr.soaking.SoakingDisplay; import com.unascribed.yttr.init.YBlocks; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -50,9 +47,7 @@ public List setupDisplay(VoidFilteringDisplay display, Rectangle bounds) .entries(outputs.get(0)) .markOutput()); - widgets.add(Widgets.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 17), - new TranslatableText("category.astraladditions.void_filtering.chance", display.getChance())) - .leftAligned()); + widgets.add(Widgets.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 17), new TranslatableText("category.astraladditions.void_filtering.chance", display.getChance())).leftAligned()); return widgets; } diff --git a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringDisplay.java b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringDisplay.java index 92e42d0..e0cd472 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringDisplay.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/compat/rei/yttr/voidfiltering/VoidFilteringDisplay.java @@ -5,9 +5,7 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.EntryIngredients; -import net.minecraft.recipe.Recipe; import net.minecraft.util.Identifier; import java.util.Collections; @@ -16,24 +14,36 @@ public class VoidFilteringDisplay extends BasicDisplay { private final Identifier id; private final float chance; + private final boolean hidden; - public VoidFilteringDisplay(Identifier id, List outputs, float chance) { - super(Collections.emptyList(), outputs); + private VoidFilteringDisplay(Identifier id, List inputs, List outputs, float chance, boolean hidden) { + super(inputs, outputs); this.id = id; this.chance = chance; + this.hidden = hidden; } - public float getChance() { - return chance; + public static VoidFilteringDisplay of(VoidFilteringRecipe recipe) { + List inputs = Collections.emptyList(); + + List outputs = Collections.singletonList( + EntryIngredients.of(recipe.getOutput().copy()) + ); + + return new VoidFilteringDisplay(recipe.getId(), inputs, outputs, recipe.getChance(), recipe.isHidden()); } + @Override public CategoryIdentifier getCategoryIdentifier() { return AstralAdditionsREIClientPlugin.VOID_FILTERING; } - public static VoidFilteringDisplay of(VoidFilteringRecipe recipe) { - EntryIngredient output = EntryIngredients.of(recipe.getOutput()); - return new VoidFilteringDisplay(recipe.getId(), Collections.singletonList(output), recipe.getChance()); + public float getChance() { + return chance; + } + + public boolean isHidden() { + return hidden; } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/entities/shimmerfishingrod/ShimmerFishingBobberEntity.java b/src/main/java/com/github/ethanicuss/astraladditions/entities/shimmerfishingrod/ShimmerFishingBobberEntity.java index 17c6b12..8cc9f7b 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/entities/shimmerfishingrod/ShimmerFishingBobberEntity.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/entities/shimmerfishingrod/ShimmerFishingBobberEntity.java @@ -45,8 +45,8 @@ public ShimmerFishingBobberEntity(PlayerEntity player, World world, int luckOfTh this.setOwner(player); - ((FishingBobberEntityAccessor)(Object)this).setLuckOfTheSeaLevel(Math.max(0, luckOfTheSeaLevel)); - ((FishingBobberEntityAccessor)(Object)this).setLureLevel(Math.max(0, lureLevel)); + ((FishingBobberEntityAccessor) this).setLuckOfTheSeaLevel(Math.max(0, luckOfTheSeaLevel)); + ((FishingBobberEntityAccessor) this).setLureLevel(Math.max(0, lureLevel)); float f = player.getPitch(); float g = player.getYaw(); @@ -58,7 +58,7 @@ public ShimmerFishingBobberEntity(PlayerEntity player, World world, int luckOfTh double e = player.getEyeY(); double l = player.getZ() - (double)h * 0.3; this.refreshPositionAndAngles(d, e, l, g, f); - Vec3d vec3d = new Vec3d((double)(-i), (double)MathHelper.clamp(-(k / j), -5.0F, 5.0F), (double)(-h)); + Vec3d vec3d = new Vec3d(-i, MathHelper.clamp(-(k / j), -5.0F, 5.0F), -h); double m = vec3d.length(); vec3d = vec3d.multiply(0.6 / m + (double)0.5F + this.random.nextGaussian() * 0.0045, 0.6 / m + (double)0.5F + this.random.nextGaussian() * 0.0045, 0.6 / m + (double)0.5F + this.random.nextGaussian() * 0.0045); this.setVelocity(vec3d); @@ -85,7 +85,7 @@ public void tick() { return; } - FishingBobberEntityAccessor accessor = (FishingBobberEntityAccessor)(Object)this; + FishingBobberEntityAccessor accessor = (FishingBobberEntityAccessor) this; Object currentState = FishingBobberStateHelper.getState(this); String stateName = ((Enum)currentState).name(); @@ -109,57 +109,61 @@ public void tick() { boolean isInWater = fluidHeight > 0.0F; - if (stateName.equals("FLYING")) { - if (accessor.getHookedEntity() != null) { - this.setVelocity(Vec3d.ZERO); - FishingBobberStateHelper.setState(this, getEnumStateByName("HOOKED_IN_ENTITY")); - return; - } - - if (isInWater) { - this.setVelocity(this.getVelocity().multiply(0.3, 0.2, 0.3)); - FishingBobberStateHelper.setState(this, getEnumStateByName("BOBBING")); - return; - } + switch (stateName) { + case "FLYING" -> { + if (accessor.getHookedEntity() != null) { + this.setVelocity(Vec3d.ZERO); + FishingBobberStateHelper.setState(this, getEnumStateByName("HOOKED_IN_ENTITY")); + return; + } - accessor.callCheckForCollision(); - } else if (stateName.equals("HOOKED_IN_ENTITY")) { - if (accessor.getHookedEntity() != null) { - if (!accessor.getHookedEntity().isRemoved() && accessor.getHookedEntity().world.getRegistryKey() == this.world.getRegistryKey()) { - this.setPosition(accessor.getHookedEntity().getX(), accessor.getHookedEntity().getBodyY(0.8), accessor.getHookedEntity().getZ()); - } else { - accessor.callUpdateHookedEntityId(null); - FishingBobberStateHelper.setState(this, getEnumStateByName("FLYING")); + if (isInWater) { + this.setVelocity(this.getVelocity().multiply(0.3, 0.2, 0.3)); + FishingBobberStateHelper.setState(this, getEnumStateByName("BOBBING")); + return; } - } - return; - } else if (stateName.equals("BOBBING")) { - Vec3d vec3d = this.getVelocity(); - double dy = this.getY() + vec3d.y - (double)blockPos.getY() - (double)fluidHeight; - if (Math.abs(dy) < 0.01) { - dy += Math.signum(dy) * 0.1; + accessor.callCheckForCollision(); } + case "HOOKED_IN_ENTITY" -> { + if (accessor.getHookedEntity() != null) { + if (!accessor.getHookedEntity().isRemoved() && accessor.getHookedEntity().world.getRegistryKey() == this.world.getRegistryKey()) { + this.setPosition(accessor.getHookedEntity().getX(), accessor.getHookedEntity().getBodyY(0.8), accessor.getHookedEntity().getZ()); + } else { + accessor.callUpdateHookedEntityId(null); + FishingBobberStateHelper.setState(this, getEnumStateByName("FLYING")); + } + } + return; + } + case "BOBBING" -> { + Vec3d vec3d = this.getVelocity(); + double dy = this.getY() + vec3d.y - (double) blockPos.getY() - (double) fluidHeight; - this.setVelocity(vec3d.x * 0.9, vec3d.y - dy * (double)this.random.nextFloat() * 0.2, vec3d.z * 0.9); + if (Math.abs(dy) < 0.01) { + dy += Math.signum(dy) * 0.1; + } - if (accessor.getHookCountdown() <= 0 && accessor.getFishTravelCountdown() <= 0) { - accessor.setInOpenWater(true); - } else { - accessor.setInOpenWater(accessor.isInOpenWater() && accessor.getOutOfOpenWaterTicks() < 10 && accessor.callIsOpenOrWaterAround(blockPos)); - } + this.setVelocity(vec3d.x * 0.9, vec3d.y - dy * (double) this.random.nextFloat() * 0.2, vec3d.z * 0.9); - if (isInWater) { - accessor.setOutOfOpenWaterTicks(Math.max(0, accessor.getOutOfOpenWaterTicks() - 1)); - if (accessor.isCaughtFish()) { - this.setVelocity(this.getVelocity().add(0.0, -0.1 * (double)this.velocityRandom.nextFloat() * (double)this.velocityRandom.nextFloat(), 0.0)); + if (accessor.getHookCountdown() <= 0 && accessor.getFishTravelCountdown() <= 0) { + accessor.setInOpenWater(true); + } else { + accessor.setInOpenWater(accessor.isInOpenWater() && accessor.getOutOfOpenWaterTicks() < 10 && accessor.callIsOpenOrWaterAround(blockPos)); } - if (!this.world.isClient) { - accessor.callTickFishingLogic(blockPos); + if (isInWater) { + accessor.setOutOfOpenWaterTicks(Math.max(0, accessor.getOutOfOpenWaterTicks() - 1)); + if (accessor.isCaughtFish()) { + this.setVelocity(this.getVelocity().add(0.0, -0.1 * (double) this.velocityRandom.nextFloat() * (double) this.velocityRandom.nextFloat(), 0.0)); + } + + if (!this.world.isClient) { + accessor.callTickFishingLogic(blockPos); + } + } else { + accessor.setOutOfOpenWaterTicks(Math.min(10, accessor.getOutOfOpenWaterTicks() + 1)); } - } else { - accessor.setOutOfOpenWaterTicks(Math.min(10, accessor.getOutOfOpenWaterTicks() + 1)); } } @@ -185,7 +189,7 @@ public int use(ItemStack usedItem) { PlayerEntity player = this.getPlayerOwner(); if (!this.world.isClient && player != null && this.isStillHoldingFishingRod(player)) { int i = 0; - FishingBobberEntityAccessor accessor = (FishingBobberEntityAccessor)(Object)this; + FishingBobberEntityAccessor accessor = (FishingBobberEntityAccessor) this; if (accessor.getHookedEntity() != null) { this.pullHookedEntity(accessor.getHookedEntity()); @@ -251,7 +255,7 @@ protected void onEntityHit(EntityHitResult entityHitResult) { super.onEntityHit(entityHitResult); if (!this.world.isClient) { - ((FishingBobberEntityAccessor)(Object)this).callUpdateHookedEntityId(entityHitResult.getEntity()); + ((FishingBobberEntityAccessor) this).callUpdateHookedEntityId(entityHitResult.getEntity()); Entity entity = entityHitResult.getEntity(); if (entity instanceof LivingEntity living) { @@ -263,7 +267,7 @@ protected void onEntityHit(EntityHitResult entityHitResult) { @Override public void remove(RemovalReason reason) { - Entity hooked = ((FishingBobberEntityAccessor)(Object)this).getHookedEntity(); + Entity hooked = ((FishingBobberEntityAccessor) this).getHookedEntity(); if (hooked instanceof LivingEntity living) { living.removeStatusEffect(StatusEffects.GLOWING); living.removeStatusEffect(StatusEffects.NIGHT_VISION); diff --git a/src/main/java/com/github/ethanicuss/astraladditions/mixin/yttr/MagtankScreenHandlerMixin.java b/src/main/java/com/github/ethanicuss/astraladditions/mixin/yttr/MagtankScreenHandlerMixin.java new file mode 100644 index 0000000..4a2da10 --- /dev/null +++ b/src/main/java/com/github/ethanicuss/astraladditions/mixin/yttr/MagtankScreenHandlerMixin.java @@ -0,0 +1,52 @@ +package com.github.ethanicuss.astraladditions.mixin.yttr; + +import com.unascribed.yttr.inventory.MagtankScreenHandler; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(MagtankScreenHandler.class) +public abstract class MagtankScreenHandlerMixin extends ScreenHandler { + + protected MagtankScreenHandlerMixin(@Nullable ScreenHandlerType type, int syncId) { + super(type, syncId); + } + + @Override + public ItemStack transferSlot(PlayerEntity player, int index) { + ItemStack newStack = ItemStack.EMPTY; + if (index < 0 || index >= this.slots.size()) { + return ItemStack.EMPTY; + } + + var slot = this.slots.get(index); + + if (slot != null && slot.hasStack()) { + ItemStack original = slot.getStack(); + newStack = original.copy(); + + if (index < 27) { + if (!this.insertItem(original, 27, 36, false)) { + return ItemStack.EMPTY; + } + } else if (index < 36) { + if (!this.insertItem(original, 0, 27, false)) { + return ItemStack.EMPTY; + } + } else { + return ItemStack.EMPTY; + } + + if (original.isEmpty()) { + slot.setStack(ItemStack.EMPTY); + } else { + slot.markDirty(); + } + } + + return newStack; + } +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/mixin/yttr/YttrEachRegisterableFieldMixin.java b/src/main/java/com/github/ethanicuss/astraladditions/mixin/yttr/YttrEachRegisterableFieldMixin.java new file mode 100644 index 0000000..21bf517 --- /dev/null +++ b/src/main/java/com/github/ethanicuss/astraladditions/mixin/yttr/YttrEachRegisterableFieldMixin.java @@ -0,0 +1,46 @@ +package com.github.ethanicuss.astraladditions.mixin.yttr; + +import com.unascribed.yttr.Yttr; +import com.unascribed.yttr.init.YHandledScreens; +import net.fabricmc.api.EnvType; +import net.fabricmc.loader.api.FabricLoader; +import org.apache.logging.log4j.util.TriConsumer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +@Mixin(value = Yttr.class, remap = false) +public abstract class YttrEachRegisterableFieldMixin { + + @Inject(method = "eachRegisterableField", at = @At("HEAD"), cancellable = true) + private static void skipScreenAnnotationsOnServer(Class holder, Class type, Class anno, TriConsumer callback, CallbackInfo callbackInfo) { + if (FabricLoader.getInstance().getEnvironmentType() != EnvType.SERVER) { + return; + } + + if (holder != YHandledScreens.class) { + return; + } + + for (Field field : holder.getDeclaredFields()) { + if (type.isAssignableFrom(field.getType()) && Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) { + try { + field.setAccessible(true); + @SuppressWarnings("unchecked") + T value = (T) field.get(null); + + callback.accept(field, value, null); + } catch (Exception error) { + throw new RuntimeException(error); + } + } + } + + callbackInfo.cancel(); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/particle/shimmer/ShimmerBubblePopParticle.java b/src/main/java/com/github/ethanicuss/astraladditions/particle/shimmer/ShimmerBubblePopParticle.java new file mode 100644 index 0000000..2a2ebca --- /dev/null +++ b/src/main/java/com/github/ethanicuss/astraladditions/particle/shimmer/ShimmerBubblePopParticle.java @@ -0,0 +1,53 @@ +package com.github.ethanicuss.astraladditions.particle.shimmer; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.particle.*; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.particle.DefaultParticleType; + +@Environment(EnvType.CLIENT) +public class ShimmerBubblePopParticle extends SpriteBillboardParticle { + private final SpriteProvider spriteProvider; + + ShimmerBubblePopParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) { + super(world, x, y, z); + this.spriteProvider = spriteProvider; + this.maxAge = 5; + this.gravityStrength = 0.008F; + this.velocityX = velocityX; + this.velocityY = velocityY; + this.velocityZ = velocityZ; + this.setSpriteForAge(spriteProvider); + } + + public void tick() { + this.prevPosX = this.x; + this.prevPosY = this.y; + this.prevPosZ = this.z; + if (this.age++ >= this.maxAge) { + this.markDead(); + } else { + this.velocityY -= this.gravityStrength; + this.move(this.velocityX, this.velocityY, this.velocityZ); + this.setSpriteForAge(this.spriteProvider); + } + } + + public ParticleTextureSheet getType() { + return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; + } + + @Environment(EnvType.CLIENT) + public static class Factory implements ParticleFactory { + private final SpriteProvider spriteProvider; + + public Factory(SpriteProvider spriteProvider) { + this.spriteProvider = spriteProvider; + } + + public Particle createParticle(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i) { + return new ShimmerBubblePopParticle(clientWorld, d, e, f, g, h, i, this.spriteProvider); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/recipes/ChromaticVacuumRecipe.java b/src/main/java/com/github/ethanicuss/astraladditions/recipes/ChromaticVacuumRecipe.java index ea88736..b6580ab 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/recipes/ChromaticVacuumRecipe.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/recipes/ChromaticVacuumRecipe.java @@ -17,7 +17,7 @@ public class ChromaticVacuumRecipe implements Recipe { private final ItemStack remainder; private final DefaultedList recipeItems; - public ChromaticVacuumRecipe(Identifier id, ItemStack output, ItemStack remainder, DefaultedList recipeItems){ + public ChromaticVacuumRecipe(Identifier id, ItemStack output, ItemStack remainder, DefaultedList recipeItems) { this.id = id; this.output = output; this.remainder = remainder; @@ -63,12 +63,13 @@ public RecipeType getType() { return Type.INSTANCE; } - public boolean hasRemainder() { - return !remainder.isEmpty(); + @Override + public DefaultedList getIngredients() { + return recipeItems; } - public ItemStack getIngredient() { - return recipeItems.get(0).getMatchingStacks()[0]; + public boolean hasRemainder() { + return !remainder.isEmpty(); } public static class Type implements RecipeType { @@ -80,7 +81,6 @@ private Type() { } public static class Serializer implements RecipeSerializer { public static final Serializer INSTANCE = new Serializer(); public static final String ID = "chromatic_vacuum"; - // this is the name given in the json file @Override public ChromaticVacuumRecipe read(Identifier id, JsonObject json) { @@ -89,7 +89,6 @@ public ChromaticVacuumRecipe read(Identifier id, JsonObject json) { JsonObject ingredient = JsonHelper.getObject(json, "ingredient"); DefaultedList inputs = DefaultedList.ofSize(1, Ingredient.EMPTY); - inputs.set(0, Ingredient.fromJson(ingredient)); return new ChromaticVacuumRecipe(id, output, remainder, inputs); @@ -98,13 +97,12 @@ public ChromaticVacuumRecipe read(Identifier id, JsonObject json) { @Override public ChromaticVacuumRecipe read(Identifier id, PacketByteBuf buf) { DefaultedList inputs = DefaultedList.ofSize(buf.readInt(), Ingredient.EMPTY); - ItemStack remainder = new ItemStack(Items.DIRT); - for (int i = 0; i < inputs.size(); i++) { inputs.set(i, Ingredient.fromPacket(buf)); } ItemStack output = buf.readItemStack(); + ItemStack remainder = buf.readItemStack(); return new ChromaticVacuumRecipe(id, output, remainder, inputs); } @@ -115,6 +113,7 @@ public void write(PacketByteBuf buf, ChromaticVacuumRecipe recipe) { ing.write(buf); } buf.writeItemStack(recipe.getOutput()); + buf.writeItemStack(recipe.getRemainder()); } } } \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/recipes/DesizerRecipe.java b/src/main/java/com/github/ethanicuss/astraladditions/recipes/DesizerRecipe.java index ab98397..494b34b 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/recipes/DesizerRecipe.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/recipes/DesizerRecipe.java @@ -16,7 +16,6 @@ import org.slf4j.LoggerFactory; public class DesizerRecipe implements Recipe { - public static final Logger LOGGER = LoggerFactory.getLogger(AstralAdditions.MOD_ID); private final Identifier id; private final ItemStack output; private final DefaultedList recipeItems; @@ -85,12 +84,10 @@ public static class Serializer implements RecipeSerializer { @Override public DesizerRecipe read(Identifier id, JsonObject json) { - // Parse output ItemStack output = ShapedRecipe.outputFromJson(JsonHelper.getObject(json, "output")); - // Parse ingredients JsonArray ingredients = JsonHelper.getArray(json, "ingredients"); - DefaultedList inputs = DefaultedList.ofSize(27, Ingredient.EMPTY); // Ensure size matches grid + DefaultedList inputs = DefaultedList.ofSize(27, Ingredient.EMPTY); for (int i = 0; i < ingredients.size(); i++) { JsonElement element = ingredients.get(i); @@ -122,4 +119,4 @@ public void write(PacketByteBuf buf, DesizerRecipe recipe) { buf.writeItemStack(recipe.getOutput()); } } -} +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/recipes/TransmuteRecipe.java b/src/main/java/com/github/ethanicuss/astraladditions/recipes/TransmuteRecipe.java index 19f5e11..60aa696 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/recipes/TransmuteRecipe.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/recipes/TransmuteRecipe.java @@ -6,11 +6,13 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; +import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.RecipeType; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import java.util.ArrayList; @@ -44,24 +46,32 @@ public boolean matches(ItemStack stack) { public List getOutputItems() { return outputItems; } + public ItemStack getInputItem() { return inputItem; } + public boolean isIgnoreCount() { return ignoreCount; } - public boolean isSoftIgnoreCount(){ + + public boolean isSoftIgnoreCount() { return softIgnoreCount; } + public ItemStack getResult() { + return outputItems.isEmpty() ? ItemStack.EMPTY : outputItems.get(0); + } + @Override public boolean matches(Inventory inv, World world) { - return false; + ItemStack stack = inv.getStack(0); + return matches(stack); } @Override public ItemStack craft(Inventory inv) { - return ItemStack.EMPTY; + return getResult().copy(); } @Override @@ -71,11 +81,14 @@ public boolean fits(int width, int height) { @Override public ItemStack getOutput() { - return null; + return getResult().copy(); } - public ItemStack getResult() { - return outputItems.isEmpty() ? ItemStack.EMPTY : outputItems.get(0); + @Override + public DefaultedList getIngredients() { + DefaultedList list = DefaultedList.of(); + list.add(Ingredient.ofStacks(inputItem)); + return list; } @Override @@ -94,7 +107,7 @@ public RecipeType getType() { } public static class Type implements RecipeType { - private Type() { } + private Type() {} public static final Type INSTANCE = new Type(); public static final String ID = "shimmer_transmute"; } diff --git a/src/main/java/com/github/ethanicuss/astraladditions/registry/ModFanProcessingType.java b/src/main/java/com/github/ethanicuss/astraladditions/registry/ModFanProcessingType.java new file mode 100644 index 0000000..27a8f06 --- /dev/null +++ b/src/main/java/com/github/ethanicuss/astraladditions/registry/ModFanProcessingType.java @@ -0,0 +1,19 @@ +package com.github.ethanicuss.astraladditions.registry; + +import com.github.ethanicuss.astraladditions.AstralAdditions; +import com.github.ethanicuss.astraladditions.compat.create.ShimmerTransmuteType; +import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType; +import com.simibubi.create.content.kinetics.fan.processing.FanProcessingTypeRegistry; +import net.minecraft.util.Identifier; + +public class ModFanProcessingType { + public static final ShimmerTransmuteType SHIMMER_TRANSMUTE = + registerFanProcess("shimmer_transmute", new ShimmerTransmuteType()); + + private static T registerFanProcess(String name, T type) { + FanProcessingTypeRegistry.register(new Identifier(AstralAdditions.MOD_ID, name), type); + return type; + } + + public static void registerFanProcess() {} +} \ No newline at end of file diff --git a/src/main/java/com/github/ethanicuss/astraladditions/registry/ModParticles.java b/src/main/java/com/github/ethanicuss/astraladditions/registry/ModParticles.java index 5b14f43..96cc2eb 100644 --- a/src/main/java/com/github/ethanicuss/astraladditions/registry/ModParticles.java +++ b/src/main/java/com/github/ethanicuss/astraladditions/registry/ModParticles.java @@ -2,6 +2,7 @@ import com.github.ethanicuss.astraladditions.AstralAdditions; import com.github.ethanicuss.astraladditions.particle.shimmer.ShimmerBubbleParticle; +import com.github.ethanicuss.astraladditions.particle.shimmer.ShimmerBubblePopParticle; import com.github.ethanicuss.astraladditions.particle.shimmer.ShimmerSplashParticle; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; @@ -13,14 +14,17 @@ public class ModParticles { public static final DefaultParticleType SHIMMER_BUBBLE = FabricParticleTypes.simple(); public static final DefaultParticleType SHIMMER_SPLASH = FabricParticleTypes.simple(); + public static final DefaultParticleType SHIMMER_BUBBLE_POP = FabricParticleTypes.simple(); public static void registerParticles() { Registry.register(Registry.PARTICLE_TYPE, new Identifier(AstralAdditions.MOD_ID, "shimmer_bubble"), SHIMMER_BUBBLE); Registry.register(Registry.PARTICLE_TYPE, new Identifier(AstralAdditions.MOD_ID, "shimmer_splash"), SHIMMER_SPLASH); + Registry.register(Registry.PARTICLE_TYPE, new Identifier(AstralAdditions.MOD_ID, "shimmer_bubble_pop"), SHIMMER_BUBBLE_POP); } public static void registerClient() { ParticleFactoryRegistry.getInstance().register(ModParticles.SHIMMER_BUBBLE, ShimmerBubbleParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(ModParticles.SHIMMER_SPLASH, ShimmerSplashParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(ModParticles.SHIMMER_BUBBLE_POP, ShimmerBubblePopParticle.Factory::new); } } \ No newline at end of file diff --git a/src/main/resources/assets/astraladditions/lang/en_us.json b/src/main/resources/assets/astraladditions/lang/en_us.json index 9ce4442..8f2d4a7 100644 --- a/src/main/resources/assets/astraladditions/lang/en_us.json +++ b/src/main/resources/assets/astraladditions/lang/en_us.json @@ -113,6 +113,8 @@ "category.astraladditions.shattering": "Shattering", "category.astraladditions.shattering.workstations": "Any tool with this enchantment", + "category.astraladditions.bulk_shimmering": "Bulk Shimmering", + "effect.astraladditions.sink": "Sinking", "effect.astraladditions.parry": "Parry", "effect.astraladditions.frost": "Frost", diff --git a/src/main/resources/assets/astraladditions/models/item/shimmer_blower.json b/src/main/resources/assets/astraladditions/models/item/shimmer_blower.json index b3e669f..efc435b 100644 --- a/src/main/resources/assets/astraladditions/models/item/shimmer_blower.json +++ b/src/main/resources/assets/astraladditions/models/item/shimmer_blower.json @@ -1,6 +1,11 @@ { - "parent": "minecraft:item/handheld", + "parent": "item/generated", "textures": { "layer0": "astraladditions:item/shimmer_blower" - } + }, + "overrides": [ + { "predicate": { "variant": 0.65 }, "model": "astraladditions:item/shimmer_blower_pin_point" }, + { "predicate": { "variant": 0.95 }, "model": "astraladditions:item/shimmer_blower_fuming" }, + { "predicate": { "variant": 1.0 }, "model": "astraladditions:item/shimmer_blower_zooming" } + ] } \ No newline at end of file diff --git a/src/main/resources/assets/astraladditions/models/item/shimmer_blower_fuming.json b/src/main/resources/assets/astraladditions/models/item/shimmer_blower_fuming.json new file mode 100644 index 0000000..371103c --- /dev/null +++ b/src/main/resources/assets/astraladditions/models/item/shimmer_blower_fuming.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "astraladditions:item/shimmer_blower_fuming" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/astraladditions/models/item/shimmer_blower_pin_point.json b/src/main/resources/assets/astraladditions/models/item/shimmer_blower_pin_point.json new file mode 100644 index 0000000..95bd805 --- /dev/null +++ b/src/main/resources/assets/astraladditions/models/item/shimmer_blower_pin_point.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "astraladditions:item/shimmer_blower_pin_point" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/astraladditions/models/item/shimmer_blower_zooming.json b/src/main/resources/assets/astraladditions/models/item/shimmer_blower_zooming.json new file mode 100644 index 0000000..ec75193 --- /dev/null +++ b/src/main/resources/assets/astraladditions/models/item/shimmer_blower_zooming.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "astraladditions:item/shimmer_blower_zooming" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/astraladditions/particles/shimmer_bubble_pop.json b/src/main/resources/assets/astraladditions/particles/shimmer_bubble_pop.json new file mode 100644 index 0000000..e884615 --- /dev/null +++ b/src/main/resources/assets/astraladditions/particles/shimmer_bubble_pop.json @@ -0,0 +1,10 @@ +{ + "textures": [ + "astraladditions:shimmer_bubble_pop_0", + "astraladditions:shimmer_bubble_pop_1", + "astraladditions:shimmer_bubble_pop_2", + "astraladditions:shimmer_bubble_pop_3", + "astraladditions:shimmer_bubble_pop_4" + ], + "type": "minecraft:particle" +} \ No newline at end of file diff --git a/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_fuming.png b/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_fuming.png new file mode 100644 index 0000000..3f49b81 Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_fuming.png differ diff --git a/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_pin_point.png b/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_pin_point.png new file mode 100644 index 0000000..fafaa6e Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_pin_point.png differ diff --git a/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_zooming.png b/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_zooming.png new file mode 100644 index 0000000..88cc576 Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/item/shimmer_blower_zooming.png differ diff --git a/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_0.png b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_0.png new file mode 100644 index 0000000..7bca84b Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_0.png differ diff --git a/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_1.png b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_1.png new file mode 100644 index 0000000..f2ac615 Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_1.png differ diff --git a/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_2.png b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_2.png new file mode 100644 index 0000000..cf24b8b Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_2.png differ diff --git a/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_3.png b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_3.png new file mode 100644 index 0000000..01ee920 Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_3.png differ diff --git a/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_4.png b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_4.png new file mode 100644 index 0000000..a1ff43b Binary files /dev/null and b/src/main/resources/assets/astraladditions/textures/particle/shimmer_bubble_pop_4.png differ diff --git a/src/main/resources/astraladditions.mixins.json b/src/main/resources/astraladditions.mixins.json index c61d9f0..532840b 100644 --- a/src/main/resources/astraladditions.mixins.json +++ b/src/main/resources/astraladditions.mixins.json @@ -4,12 +4,15 @@ "package": "com.github.ethanicuss.astraladditions.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ + "yttr.YttrEachRegisterableFieldMixin", + "yttr.MagtankScreenHandlerMixin", + "ParryEffectMixin", "ShimmerEffectMixin", "EntityAccessor", "ItemEntityMixin", "NerfedShulkers", - "ParticleRecolourMixin", + "betterdragon.AbstractPhaseAccessor", "betterdragon.DragonAccessor", "betterdragon.HoverPhaseAccessor", @@ -32,7 +35,8 @@ "client": [ "SpaceMusicMixin", "ParticleRecolourMixin", - "InGameHudMixin" + "InGameHudMixin", + "ParticleRecolourMixin" ], "injectors": { "defaultRequire": 1