diff --git a/build.gradle b/build.gradle index 519976dba58..e7317a3848a 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,8 @@ sourceSets { main { java { srcDir 'src/main/flatbuffers/generated' + exclude "**/integration/modules/rei/**" + exclude "**/integration/modules/jei/**" } resources { srcDir 'src/generated/resources' diff --git a/src/main/java/appeng/client/gui/AEBaseScreen.java b/src/main/java/appeng/client/gui/AEBaseScreen.java index 3552af7b1ea..09d99ae1faa 100644 --- a/src/main/java/appeng/client/gui/AEBaseScreen.java +++ b/src/main/java/appeng/client/gui/AEBaseScreen.java @@ -239,7 +239,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia this.updateBeforeRender(); this.widgets.updateBeforeRender(); - super.renderBackground(guiGraphics); + super.renderBackground(guiGraphics, mouseX, mouseY, partialTicks); super.render(guiGraphics, mouseX, mouseY, partialTicks); renderTooltips(guiGraphics, mouseX, mouseY); @@ -515,8 +515,8 @@ public void setFocused(@Nullable GuiEventListener listener) { } @Override - public boolean mouseScrolled(double x, double y, double wheelDelta) { - if (wheelDelta != 0 && widgets.onMouseWheel(getMousePoint(x, y), wheelDelta)) { + public boolean mouseScrolled(double x, double y, double deltaX, double deltaY) { + if (deltaY != 0 && widgets.onMouseWheel(getMousePoint(x, y), deltaY)) { return true; } return false; diff --git a/src/main/java/appeng/client/gui/me/common/FinishedJobToast.java b/src/main/java/appeng/client/gui/me/common/FinishedJobToast.java index 741815a75ec..f0b4192dd7d 100644 --- a/src/main/java/appeng/client/gui/me/common/FinishedJobToast.java +++ b/src/main/java/appeng/client/gui/me/common/FinishedJobToast.java @@ -18,6 +18,8 @@ * A Minecraft toast for a finished crafting job. */ public class FinishedJobToast implements Toast { + private static final ResourceLocation BACKGROUND_SPRITE = new ResourceLocation("toast/recipe"); + private static final long TIME_VISIBLE = 2500; private static final int TITLE_COLOR = 0xFF500050; private static final int TEXT_COLOR = 0xFF000000; @@ -45,13 +47,13 @@ public Visibility render(GuiGraphics guiGraphics, ToastComponent toastComponent, var font = minecraft.font; // stretch the middle - guiGraphics.blit(TEXTURE, 0, 0, 0, 32, this.width(), 8); + guiGraphics.blit(BACKGROUND_SPRITE, 0, 0, 0, 32, this.width(), 8); int middleHeight = height - 16; for (var middleY = 0; middleY < middleHeight; middleY += 16) { var tileHeight = Math.min(middleHeight - middleY, 16); - guiGraphics.blit(TEXTURE, 0, 8 + middleY, 0, 32 + 8, this.width(), tileHeight); + guiGraphics.blit(BACKGROUND_SPRITE, 0, 8 + middleY, 0, 32 + 8, this.width(), tileHeight); } - guiGraphics.blit(TEXTURE, 0, height - 8, 0, 32 + 32 - 8, this.width(), 8); + guiGraphics.blit(BACKGROUND_SPRITE, 0, height - 8, 0, 32 + 32 - 8, this.width(), 8); guiGraphics.drawString(toastComponent.getMinecraft().font, GuiText.ToastCraftingJobFinishedTitle.text(), 30, 7, TITLE_COLOR, false); var lineY = 18; diff --git a/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java b/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java index 20e2ab7e390..4789abe3ee2 100644 --- a/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java +++ b/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java @@ -470,14 +470,14 @@ public boolean mouseClicked(double xCoord, double yCoord, int btn) { } @Override - public boolean mouseScrolled(double x, double y, double wheelDelta) { - if (wheelDelta != 0 && hasShiftDown()) { + public boolean mouseScrolled(double x, double y, double deltaX, double deltaY) { + if (deltaY != 0 && hasShiftDown()) { if (this.findSlot(x, y) instanceof RepoSlot repoSlot) { GridInventoryEntry entry = repoSlot.getEntry(); long serial = entry != null ? entry.getSerial() : -1; - final InventoryAction direction = wheelDelta > 0 ? InventoryAction.ROLL_DOWN + final InventoryAction direction = deltaY > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP; - int times = (int) Math.abs(wheelDelta); + int times = (int) Math.abs(deltaY); for (int h = 0; h < times; h++) { final MEInteractionPacket p = new MEInteractionPacket(this.menu.containerId, serial, direction); NetworkHandler.instance().sendToServer(p); @@ -486,7 +486,7 @@ public boolean mouseScrolled(double x, double y, double wheelDelta) { return true; } } - return super.mouseScrolled(x, y, wheelDelta); + return super.mouseScrolled(x, y, deltaX, deltaY); } @Override diff --git a/src/main/java/appeng/client/gui/widgets/AETextField.java b/src/main/java/appeng/client/gui/widgets/AETextField.java index 2ba9b408bff..bb5100cb246 100644 --- a/src/main/java/appeng/client/gui/widgets/AETextField.java +++ b/src/main/java/appeng/client/gui/widgets/AETextField.java @@ -130,7 +130,7 @@ public void resize(int width, int height) { } public void selectAll() { - this.moveCursorTo(0); + this.moveCursorTo(0, false); this.setHighlightPos(this.getMaxLength()); } diff --git a/src/main/java/appeng/client/gui/widgets/NumberEntryWidget.java b/src/main/java/appeng/client/gui/widgets/NumberEntryWidget.java index da100cc22ed..b76edccf743 100644 --- a/src/main/java/appeng/client/gui/widgets/NumberEntryWidget.java +++ b/src/main/java/appeng/client/gui/widgets/NumberEntryWidget.java @@ -281,7 +281,7 @@ public OptionalLong getLongValue() { public void setLongValue(long value) { var internalValue = convertToInternalValue(Longs.constrainToRange(value, minValue, maxValue)); this.textField.setValue(decimalFormat.format(internalValue)); - this.textField.moveCursorToEnd(); + this.textField.moveCursorToEnd(false); this.textField.setHighlightPos(0); validate(); } diff --git a/src/main/java/appeng/client/guidebook/Guide.java b/src/main/java/appeng/client/guidebook/Guide.java index 0536dde5e84..a95a109ec57 100644 --- a/src/main/java/appeng/client/guidebook/Guide.java +++ b/src/main/java/appeng/client/guidebook/Guide.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; +import net.minecraft.world.level.validation.DirectoryValidator; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -140,7 +141,7 @@ public static void runDatapackReload() { try { var layeredAccess = RegistryLayer.createRegistryAccess(); - PackRepository packRepository = new PackRepository(new ServerPacksSource()); + PackRepository packRepository = new PackRepository(new ServerPacksSource(new DirectoryValidator(path -> false))); net.neoforged.neoforge.resource.ResourcePackLoader.loadResourcePacks(packRepository, net.neoforged.neoforge.server.ServerLifecycleHooks::buildPackFinder); packRepository.reload(); diff --git a/src/main/java/appeng/client/guidebook/screen/GuideNavBar.java b/src/main/java/appeng/client/guidebook/screen/GuideNavBar.java index 73e14461b89..b279c8b16bd 100644 --- a/src/main/java/appeng/client/guidebook/screen/GuideNavBar.java +++ b/src/main/java/appeng/client/guidebook/screen/GuideNavBar.java @@ -90,12 +90,12 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double dra } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double delta) { + public boolean mouseScrolled(double mouseX, double mouseY, double deltaX, double deltaY) { if (state != State.OPENING && state != State.OPEN) { return false; } - setScrollOffset((int) Math.round(scrollOffset - delta * 20)); + setScrollOffset((int) Math.round(scrollOffset - deltaY * 20)); return true; } diff --git a/src/main/java/appeng/client/guidebook/screen/GuideScreen.java b/src/main/java/appeng/client/guidebook/screen/GuideScreen.java index 74e46403ada..dd66efa6c68 100644 --- a/src/main/java/appeng/client/guidebook/screen/GuideScreen.java +++ b/src/main/java/appeng/client/guidebook/screen/GuideScreen.java @@ -640,9 +640,9 @@ private LytRect getDocumentViewport() { } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double delta) { - if (!super.mouseScrolled(mouseX, mouseY, delta)) { - return scrollbar.mouseScrolled(mouseX, mouseY, delta); + public boolean mouseScrolled(double mouseX, double mouseY, double deltaX, double deltaY) { + if (!super.mouseScrolled(mouseX, mouseY, deltaX, deltaY)) { + return scrollbar.mouseScrolled(mouseX, mouseY, deltaX, deltaY); } return true; } diff --git a/src/main/java/appeng/client/guidebook/screen/GuideScrollbar.java b/src/main/java/appeng/client/guidebook/screen/GuideScrollbar.java index c6490a57a9b..ed076e13c43 100644 --- a/src/main/java/appeng/client/guidebook/screen/GuideScrollbar.java +++ b/src/main/java/appeng/client/guidebook/screen/GuideScrollbar.java @@ -128,7 +128,7 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double dra } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double delta) { + public boolean mouseScrolled(double mouseX, double mouseY, double delta, double deltaHorizontal) { if (this.visible) { this.setScrollAmount((int) (this.scrollAmount - delta * 10)); return true; diff --git a/src/main/java/appeng/client/render/tesr/InscriberTESR.java b/src/main/java/appeng/client/render/tesr/InscriberTESR.java index 61d0f766d57..6e0172cd3ea 100644 --- a/src/main/java/appeng/client/render/tesr/InscriberTESR.java +++ b/src/main/java/appeng/client/render/tesr/InscriberTESR.java @@ -219,7 +219,7 @@ public void render(InscriberBlockEntity blockEntity, float partialTicks, PoseSta } private static void addVertex(VertexConsumer vb, PoseStack ms, TextureAtlasSprite sprite, float x, float y, - float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) { + float z, float texU, float texV, int overlayUV, int lightmapUV, Direction front) { vb.vertex(ms.last().pose(), x, y, z); vb.color(1.0f, 1.0f, 1.0f, 1.0f); vb.uv(sprite.getU(texU), sprite.getV(texV)); diff --git a/src/main/java/appeng/datagen/providers/loot/BlockDropProvider.java b/src/main/java/appeng/datagen/providers/loot/BlockDropProvider.java index 0070a0c188e..7ea9a412a14 100644 --- a/src/main/java/appeng/datagen/providers/loot/BlockDropProvider.java +++ b/src/main/java/appeng/datagen/providers/loot/BlockDropProvider.java @@ -109,15 +109,16 @@ public CompletableFuture run(CachedOutput cache) { if (entry.getKey().location().getNamespace().equals(AppEng.MOD_ID)) { builder = overrides.getOrDefault(entry.getValue(), this::defaultBuilder).apply(entry.getValue()); - futures.add(DataProvider.saveStable(cache, toJson(builder), + futures.add(DataProvider.saveStable(cache, LootTable.CODEC, finishBuilding(builder), getPath(outputFolder, entry.getKey().location()))); } } - futures.add(DataProvider.saveStable(cache, toJson(LootTable.lootTable() + var table = LootTable.lootTable() .withPool(LootPool.lootPool() .setRolls(UniformGenerator.between(1, 3)) - .add(LootItem.lootTableItem(AEBlocks.SKY_STONE_BLOCK)))), + .add(LootItem.lootTableItem(AEBlocks.SKY_STONE_BLOCK))); + futures.add(DataProvider.saveStable(cache, LootTable.CODEC, finishBuilding(table), getPath(outputFolder, AppEng.makeId("chests/meteorite")))); return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)); @@ -160,10 +161,6 @@ private Path getPath(Path root, ResourceLocation id) { return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json"); } - public JsonElement toJson(LootTable.Builder builder) { - return LootDataType.TABLE.parser().toJsonTree(finishBuilding(builder)); - } - public LootTable finishBuilding(LootTable.Builder builder) { return builder.setParamSet(LootContextParamSets.BLOCK).build(); } diff --git a/src/main/java/appeng/integration/modules/jeirei/CraftingHelper.java b/src/main/java/appeng/integration/modules/jeirei/CraftingHelper.java index fe50155db1c..3366a6c285d 100644 --- a/src/main/java/appeng/integration/modules/jeirei/CraftingHelper.java +++ b/src/main/java/appeng/integration/modules/jeirei/CraftingHelper.java @@ -15,6 +15,7 @@ import appeng.menu.me.common.MEStorageMenu; import appeng.menu.me.items.CraftingTermMenu; import appeng.util.CraftingRecipeUtil; +import net.minecraft.world.item.crafting.RecipeHolder; public final class CraftingHelper { private static final Comparator ENTRY_COMPARATOR = Comparator @@ -23,15 +24,15 @@ public final class CraftingHelper { private CraftingHelper() { } - public static void performTransfer(CraftingTermMenu menu, Recipe recipe, boolean craftMissing) { + public static void performTransfer(CraftingTermMenu menu, RecipeHolder recipe, boolean craftMissing) { // We send the items in the recipe in any case to serve as a fallback in case the recipe is transient - var templateItems = findGoodTemplateItems(recipe, menu); + var templateItems = findGoodTemplateItems(recipe.value(), menu); - var recipeId = recipe.getId(); + var recipeId = recipe.id(); // Don't transmit a recipe id to the server in case the recipe is not actually resolvable // this is the case for recipes synthetically generated for JEI - if (menu.getPlayer().level().getRecipeManager().byKey(recipe.getId()).isEmpty()) { + if (menu.getPlayer().level().getRecipeManager().byKey(recipe.id()).isEmpty()) { AELog.debug("Cannot send recipe id %s to server because it's transient", recipeId); recipeId = null; } diff --git a/src/main/java/appeng/integration/modules/jeirei/EncodingHelper.java b/src/main/java/appeng/integration/modules/jeirei/EncodingHelper.java index 15661f4c109..ce916ca9d40 100644 --- a/src/main/java/appeng/integration/modules/jeirei/EncodingHelper.java +++ b/src/main/java/appeng/integration/modules/jeirei/EncodingHelper.java @@ -10,6 +10,7 @@ import com.google.common.math.LongMath; +import net.minecraft.world.item.crafting.RecipeHolder; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; @@ -96,13 +97,13 @@ public static boolean isSupportedCraftingRecipe(@Nullable Recipe recipe) { } public static void encodeCraftingRecipe(PatternEncodingTermMenu menu, - @Nullable Recipe recipe, + @Nullable RecipeHolder recipe, List> genericIngredients, Predicate visiblePredicate) { - if (recipe != null && recipe.getType().equals(RecipeType.STONECUTTING)) { + if (recipe != null && recipe.value().getType().equals(RecipeType.STONECUTTING)) { menu.setMode(EncodingMode.STONECUTTING); - menu.setStonecuttingRecipeId(recipe.getId()); - } else if (recipe != null && recipe.getType().equals(RecipeType.SMITHING)) { + menu.setStonecuttingRecipeId(recipe.id()); + } else if (recipe != null && recipe.value().getType().equals(RecipeType.SMITHING)) { menu.setMode(EncodingMode.SMITHING_TABLE); } else { menu.setMode(EncodingMode.CRAFTING); @@ -116,7 +117,7 @@ public static void encodeCraftingRecipe(PatternEncodingTermMenu menu, if (recipe != null) { // When we have access to a crafting recipe, we'll switch modes and try to find suitable // ingredients based on the recipe ingredients, which allows for fuzzy-matching. - var ingredients3x3 = CraftingRecipeUtil.ensure3by3CraftingMatrix(recipe); + var ingredients3x3 = CraftingRecipeUtil.ensure3by3CraftingMatrix(recipe.value()); // Find a good match for every ingredient for (int slot = 0; slot < ingredients3x3.size(); slot++) { diff --git a/src/main/java/appeng/integration/modules/rei/FacadeRegistryGenerator.java b/src/main/java/appeng/integration/modules/rei/FacadeRegistryGenerator.java index 9c23615cfae..b6642be7a57 100644 --- a/src/main/java/appeng/integration/modules/rei/FacadeRegistryGenerator.java +++ b/src/main/java/appeng/integration/modules/rei/FacadeRegistryGenerator.java @@ -90,9 +90,6 @@ public Optional> getUsageFor(EntryStack entry) { } private DefaultShapedDisplay make(ItemStack textureItem, ItemStack cableAnchor, ItemStack result) { - // This id should only be used within JEI and not really matter - ResourceLocation id = AppEng.makeId("facade/" + Item.getId(textureItem.getItem())); - var ingredients = NonNullList.withSize(9, Ingredient.EMPTY); ingredients.set(1, Ingredient.of(cableAnchor)); ingredients.set(3, Ingredient.of(cableAnchor)); @@ -102,7 +99,7 @@ private DefaultShapedDisplay make(ItemStack textureItem, ItemStack cableAnchor, result.setCount(4); - return new DefaultShapedDisplay(new ShapedRecipe(id, "", CraftingBookCategory.MISC, 3, 3, ingredients, result)); + return new DefaultShapedDisplay(new ShapedRecipe("", CraftingBookCategory.MISC, 3, 3, ingredients, result)); } } diff --git a/src/main/java/appeng/integration/modules/rei/InscriberRecipeWrapper.java b/src/main/java/appeng/integration/modules/rei/InscriberRecipeWrapper.java index 5dbbbe5d563..6d2046b27aa 100644 --- a/src/main/java/appeng/integration/modules/rei/InscriberRecipeWrapper.java +++ b/src/main/java/appeng/integration/modules/rei/InscriberRecipeWrapper.java @@ -63,6 +63,6 @@ public CategoryIdentifier getCategoryIdentifier() { @Override public Optional getDisplayLocation() { - return Optional.of(recipe.getId()); + throw new UnsupportedOperationException(); // TODO } } diff --git a/src/main/java/appeng/integration/modules/rei/ReiRuntimeAdapter.java b/src/main/java/appeng/integration/modules/rei/ReiRuntimeAdapter.java index 04ebfbe57d2..04900225d5d 100644 --- a/src/main/java/appeng/integration/modules/rei/ReiRuntimeAdapter.java +++ b/src/main/java/appeng/integration/modules/rei/ReiRuntimeAdapter.java @@ -59,6 +59,6 @@ public void setSearchText(String text) { @Override public boolean hasSearchFocus() { var searchField = this.runtime.getSearchTextField(); - return searchField != null && searchField.isFocused(); + return searchField != null && searchField.m_93696_(); } } diff --git a/src/main/java/appeng/integration/modules/rei/transfer/UseCraftingRecipeTransfer.java b/src/main/java/appeng/integration/modules/rei/transfer/UseCraftingRecipeTransfer.java index d22f66088a1..23d9032d073 100644 --- a/src/main/java/appeng/integration/modules/rei/transfer/UseCraftingRecipeTransfer.java +++ b/src/main/java/appeng/integration/modules/rei/transfer/UseCraftingRecipeTransfer.java @@ -109,7 +109,7 @@ private Recipe createFakeRecipe(Display display) { ingredients.set(i, ingredient); } - return new ShapedRecipe(AppEng.makeId("__fake_recipe"), "", CraftingBookCategory.MISC, CRAFTING_GRID_WIDTH, + return new ShapedRecipe("", CraftingBookCategory.MISC, CRAFTING_GRID_WIDTH, CRAFTING_GRID_HEIGHT, ingredients, ItemStack.EMPTY); } diff --git a/src/main/java/appeng/parts/automation/FluidPickupStrategy.java b/src/main/java/appeng/parts/automation/FluidPickupStrategy.java index d6fedf33617..f2ea8e35779 100644 --- a/src/main/java/appeng/parts/automation/FluidPickupStrategy.java +++ b/src/main/java/appeng/parts/automation/FluidPickupStrategy.java @@ -3,6 +3,7 @@ import java.util.Map; import java.util.UUID; +import appeng.util.Platform; import org.jetbrains.annotations.Nullable; import net.minecraft.core.BlockPos; @@ -29,6 +30,8 @@ public class FluidPickupStrategy implements PickupStrategy { private final ServerLevel level; private final BlockPos pos; private final Direction side; + @Nullable + private final UUID owningPlayerId; /** * {@link System#currentTimeMillis()} of when the last sound/visual effect was played by this plane. @@ -40,6 +43,7 @@ public FluidPickupStrategy(ServerLevel level, BlockPos pos, Direction side, Bloc this.level = level; this.pos = pos; this.side = side; + this.owningPlayerId = owningPlayerId; } @Override @@ -75,7 +79,8 @@ public Result tryPickup(IEnergySource energySource, PickupSink sink) { // bucket // This _MIGHT_ change the liquid, and if it does, and we dont have enough // space, tough luck. you loose the source block. - var fluidContainer = bucketPickup.pickupBlock(level, pos, blockstate); + var fakePlayer = Platform.getFakePlayer(level, owningPlayerId); + var fluidContainer = bucketPickup.pickupBlock(fakePlayer, level, pos, blockstate); var pickedUpStack = GenericContainerHelper.getContainedFluidStack(fluidContainer); if (pickedUpStack != null && pickedUpStack.what() instanceof AEFluidKey fluidKey) { this.storeFluid(sink, fluidKey, pickedUpStack.amount(), true); diff --git a/src/main/java/appeng/parts/automation/FluidPlacementStrategy.java b/src/main/java/appeng/parts/automation/FluidPlacementStrategy.java index 3b5a8104b91..3d3c7516e56 100644 --- a/src/main/java/appeng/parts/automation/FluidPlacementStrategy.java +++ b/src/main/java/appeng/parts/automation/FluidPlacementStrategy.java @@ -4,6 +4,7 @@ import java.util.Set; import java.util.UUID; +import appeng.util.Platform; import org.jetbrains.annotations.Nullable; import net.minecraft.core.BlockPos; @@ -33,6 +34,8 @@ public class FluidPlacementStrategy implements PlacementStrategy { private final ServerLevel level; private final BlockPos pos; private final Direction side; + @Nullable + private final UUID owningPlayerId; /** * The fluids that we tried to place unsuccessfully. */ @@ -47,6 +50,7 @@ public FluidPlacementStrategy(ServerLevel level, BlockPos pos, Direction side, B this.level = level; this.pos = pos; this.side = side; + this.owningPlayerId = owningPlayerId; } @Override @@ -143,7 +147,7 @@ private void playEvaporationEffect(Level level, BlockPos pos) { /** * Checks from {@link net.minecraft.world.item.BucketItem#emptyContents} */ - private boolean canPlace(Level level, BlockState state, BlockPos pos, Fluid fluid) { + private boolean canPlace(ServerLevel level, BlockState state, BlockPos pos, Fluid fluid) { if (!(fluid instanceof FlowingFluid)) { return false; } @@ -154,10 +158,20 @@ private boolean canPlace(Level level, BlockState state, BlockPos pos, Fluid flui return false; } - return state.isAir() - || state.canBeReplaced(fluid) - || state.getBlock() instanceof LiquidBlockContainer liquidBlockContainer - && liquidBlockContainer.canPlaceLiquid(level, pos, state, fluid); + if (state.isAir()) { + return true; + } + + if (state.canBeReplaced(fluid)) { + return true; + } + + if (state.getBlock() instanceof LiquidBlockContainer liquidBlockContainer) { + var fakePlayer = Platform.getFakePlayer(level, owningPlayerId); + return liquidBlockContainer.canPlaceLiquid(fakePlayer, level, pos, state, fluid); + } + + return false; } /** diff --git a/src/main/java/appeng/parts/automation/HandlerStrategy.java b/src/main/java/appeng/parts/automation/HandlerStrategy.java index 7f4e57aabc3..82e709a8e03 100644 --- a/src/main/java/appeng/parts/automation/HandlerStrategy.java +++ b/src/main/java/appeng/parts/automation/HandlerStrategy.java @@ -14,6 +14,7 @@ import appeng.api.stacks.AEKey; import appeng.api.stacks.AEKeyType; import appeng.me.storage.ExternalStorageFacade; +import net.neoforged.neoforge.items.ItemHandlerHelper; public abstract class HandlerStrategy { private final AEKeyType keyType; diff --git a/src/main/java/appeng/recipes/game/FacadeRecipe.java b/src/main/java/appeng/recipes/game/FacadeRecipe.java index 1f170bb840e..7b147bc7bc9 100644 --- a/src/main/java/appeng/recipes/game/FacadeRecipe.java +++ b/src/main/java/appeng/recipes/game/FacadeRecipe.java @@ -19,7 +19,6 @@ package appeng.recipes.game; import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.Container; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; @@ -39,8 +38,8 @@ public final class FacadeRecipe extends CustomRecipe { private final ItemDefinition anchor = AEParts.CABLE_ANCHOR; private final FacadeItem facade; - public FacadeRecipe(ResourceLocation id, CraftingBookCategory category, FacadeItem facade) { - super(id, category); + public FacadeRecipe(CraftingBookCategory category, FacadeItem facade) { + super(category); this.facade = facade; } @@ -82,7 +81,7 @@ public RecipeSerializer getSerializer() { public static RecipeSerializer getSerializer(FacadeItem facade) { if (SERIALIZER == null) { - SERIALIZER = new SimpleCraftingRecipeSerializer<>((id, category) -> new FacadeRecipe(id, category, facade)); + SERIALIZER = new SimpleCraftingRecipeSerializer<>((id, category) -> new FacadeRecipe(category, facade)); } return SERIALIZER; } diff --git a/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmo.java b/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmo.java index 420f5dc6a35..3f2f25b2a81 100644 --- a/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmo.java +++ b/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmo.java @@ -58,15 +58,12 @@ public class MatterCannonAmmo implements Recipe { public static final RecipeType TYPE = InitRecipeTypes.register(TYPE_ID.toString()); - private final ResourceLocation id; - private final Ingredient ammo; private final float weight; - public MatterCannonAmmo(ResourceLocation id, Ingredient ammo, float weight) { + public MatterCannonAmmo(Ingredient ammo, float weight) { Preconditions.checkArgument(weight >= 0, "Weight must not be negative"); - this.id = Objects.requireNonNull(id, "id must not be null"); this.ammo = Objects.requireNonNull(ammo, "ammo must not be null"); this.weight = weight; } @@ -103,11 +100,6 @@ public ItemStack getResultItem(RegistryAccess registryAccess) { return ItemStack.EMPTY; } - @Override - public ResourceLocation getId() { - return id; - } - @Override public RecipeSerializer getSerializer() { return MatterCannonAmmoSerializer.INSTANCE; diff --git a/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmoSerializer.java b/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmoSerializer.java index c7b943b1e35..ac08d9b35b5 100644 --- a/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmoSerializer.java +++ b/src/main/java/appeng/recipes/mattercannon/MatterCannonAmmoSerializer.java @@ -38,7 +38,7 @@ private MatterCannonAmmoSerializer() { public MatterCannonAmmo fromJson(ResourceLocation recipeId, JsonObject json) { var ammo = Ingredient.fromJson(json.get("ammo")); var weight = json.get("weight").getAsFloat(); - return new MatterCannonAmmo(recipeId, ammo, weight); + return new MatterCannonAmmo(ammo, weight); } @Nullable @@ -46,7 +46,7 @@ public MatterCannonAmmo fromJson(ResourceLocation recipeId, JsonObject json) { public MatterCannonAmmo fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) { var ammo = Ingredient.fromNetwork(buffer); var weight = buffer.readFloat(); - return new MatterCannonAmmo(recipeId, ammo, weight); + return new MatterCannonAmmo(ammo, weight); } @Override diff --git a/src/main/java/appeng/server/testplots/AutoCraftingTestPlots.java b/src/main/java/appeng/server/testplots/AutoCraftingTestPlots.java index a34d621fd23..4109e710573 100644 --- a/src/main/java/appeng/server/testplots/AutoCraftingTestPlots.java +++ b/src/main/java/appeng/server/testplots/AutoCraftingTestPlots.java @@ -236,7 +236,7 @@ private static ItemStack encodeCraftingPattern(ServerLevel level, var recipe = level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, c, level).orElseThrow(); - var result = recipe.assemble(c, level.registryAccess()); + var result = recipe.value().assemble(c, level.registryAccess()); return PatternDetailsHelper.encodeCraftingPattern( recipe, diff --git a/src/main/java/appeng/server/testplots/CraftingPatternHelper.java b/src/main/java/appeng/server/testplots/CraftingPatternHelper.java index 1ab4006173f..34f5753fdb8 100644 --- a/src/main/java/appeng/server/testplots/CraftingPatternHelper.java +++ b/src/main/java/appeng/server/testplots/CraftingPatternHelper.java @@ -26,7 +26,7 @@ public static ItemStack encodeShapelessCraftingRecipe(Level level, ItemStack... return PatternDetailsHelper.encodeCraftingPattern( recipe, actualInputs, - recipe.getResultItem(level.registryAccess()), + recipe.value().getResultItem(level.registryAccess()), false, false); } diff --git a/src/main/java/appeng/siteexport/SiteExporter.java b/src/main/java/appeng/siteexport/SiteExporter.java index 8ccdae82b13..4c90e45b071 100644 --- a/src/main/java/appeng/siteexport/SiteExporter.java +++ b/src/main/java/appeng/siteexport/SiteExporter.java @@ -214,31 +214,32 @@ public void referenceRecipe(RecipeHolder holder) { private void dumpRecipes(SiteExportWriter writer) { for (var holder : recipes) { + var id = holder.id(); var recipe = holder.value(); if (recipe instanceof CraftingRecipe craftingRecipe) { if (craftingRecipe.isSpecial()) { continue; } - writer.addRecipe(craftingRecipe); + writer.addRecipe(id, craftingRecipe); } else if (recipe instanceof AbstractCookingRecipe cookingRecipe) { - writer.addRecipe(cookingRecipe); + writer.addRecipe(id, cookingRecipe); } else if (recipe instanceof InscriberRecipe inscriberRecipe) { - writer.addRecipe(inscriberRecipe); + writer.addRecipe(id, inscriberRecipe); } else if (recipe instanceof TransformRecipe transformRecipe) { - writer.addRecipe(transformRecipe); + writer.addRecipe(id, transformRecipe); } else if (recipe instanceof SmithingTransformRecipe smithingTransformRecipe) { - writer.addRecipe(smithingTransformRecipe); + writer.addRecipe(id, smithingTransformRecipe); } else if (recipe instanceof SmithingTrimRecipe smithingTrimRecipe) { - writer.addRecipe(smithingTrimRecipe); + writer.addRecipe(id, smithingTrimRecipe); } else if (recipe instanceof StonecutterRecipe stonecutterRecipe) { - writer.addRecipe(stonecutterRecipe); + writer.addRecipe(id, stonecutterRecipe); } else if (recipe instanceof EntropyRecipe entropyRecipe) { - writer.addRecipe(entropyRecipe); + writer.addRecipe(id, entropyRecipe); } else if (recipe instanceof MatterCannonAmmo ammoRecipe) { - writer.addRecipe(ammoRecipe); + writer.addRecipe(id, ammoRecipe); } else if (recipe instanceof ChargerRecipe chargerRecipe) { - writer.addRecipe(chargerRecipe); + writer.addRecipe(id, chargerRecipe); } else { LOGGER.warn("Unable to handle recipe {} of type {}", holder.id(), recipe.getType()); } diff --git a/src/main/java/appeng/util/InteractionUtil.java b/src/main/java/appeng/util/InteractionUtil.java index 8bed0ade9e7..e3058b6362a 100644 --- a/src/main/java/appeng/util/InteractionUtil.java +++ b/src/main/java/appeng/util/InteractionUtil.java @@ -116,7 +116,7 @@ public static HitResult rayTrace(Player p, boolean hitBlocks, boolean hitEntitie float f1 = p.xRotO + (p.getXRot() - p.xRotO) * f; final float f2 = p.yRotO + (p.getYRot() - p.yRotO) * f; final double d0 = p.xo + (p.getX() - p.xo) * f; - final double d1 = p.yo + (p.getY() - p.yo) * f + 1.62D - p.getMyRidingOffset(); + final double d1 = p.yo + (p.getY() - p.yo) * f + 1.62D - p.getMyRidingOffset(p); final double d2 = p.zo + (p.getZ() - p.zo) * f; final Vec3 vec3 = new Vec3(d0, d1, d2); final float f3 = Mth.cos(-f2 * 0.017453292F - (float) Math.PI);