diff --git a/RebornCore/build.gradle b/RebornCore/build.gradle index 91c32113d..800f50d22 100644 --- a/RebornCore/build.gradle +++ b/RebornCore/build.gradle @@ -17,7 +17,7 @@ curseforge { id = "237903" changelog = ENV.CHANGELOG ?: "No changelog provided" releaseType = ENV.RELEASE_CHANNEL ?: "release" - addGameVersion "1.19.2" + addGameVersion "1.19.3" addGameVersion "Fabric" mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) diff --git a/RebornCore/src/client/java/reborncore/RebornCoreClient.java b/RebornCore/src/client/java/reborncore/RebornCoreClient.java index 7d879e026..ef20244af 100644 --- a/RebornCore/src/client/java/reborncore/RebornCoreClient.java +++ b/RebornCore/src/client/java/reborncore/RebornCoreClient.java @@ -30,11 +30,13 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -import net.minecraft.screen.PlayerScreenHandler; import reborncore.api.blockentity.UnloadHandler; -import reborncore.client.*; -import reborncore.common.screen.ScreenIcons; +import reborncore.client.BlockOutlineRenderer; +import reborncore.client.ClientBoundPacketHandlers; +import reborncore.client.HolidayRenderManager; +import reborncore.client.ItemStackRenderer; +import reborncore.client.RebornFluidRenderManager; +import reborncore.client.StackToolTipHandler; import java.util.Locale; @@ -44,12 +46,6 @@ public class RebornCoreClient implements ClientModInitializer { public void onInitializeClient() { RebornFluidRenderManager.setupClient(); HolidayRenderManager.setupClient(); - ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register((atlasTexture, registry) -> { - registry.register(ScreenIcons.HEAD); - registry.register(ScreenIcons.CHEST); - registry.register(ScreenIcons.LEGS); - registry.register(ScreenIcons.FEET); - }); ClientBoundPacketHandlers.init(); HudRenderCallback.EVENT.register(new ItemStackRenderer()); ItemTooltipCallback.EVENT.register(new StackToolTipHandler()); diff --git a/RebornCore/src/client/java/reborncore/client/HolidayRenderManager.java b/RebornCore/src/client/java/reborncore/client/HolidayRenderManager.java index ee51582e7..39e3ad269 100644 --- a/RebornCore/src/client/java/reborncore/client/HolidayRenderManager.java +++ b/RebornCore/src/client/java/reborncore/client/HolidayRenderManager.java @@ -37,7 +37,7 @@ import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import reborncore.common.RebornCoreConfig; import reborncore.common.util.CalenderUtils; @@ -74,8 +74,8 @@ public class HolidayRenderManager { float yaw = player.prevYaw + (player.getYaw() - player.prevYaw) * tickDelta - (player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw) * tickDelta); float pitch = player.prevPitch + (player.getPitch() - player.prevPitch) * tickDelta; - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(yaw)); - matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(pitch)); + matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(yaw)); + matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(pitch)); santaHat.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(player, 0.0F), 1F, 1F, 1F, 1F); matrixStack.pop(); } diff --git a/RebornCore/src/client/java/reborncore/client/ItemStackRenderer.java b/RebornCore/src/client/java/reborncore/client/ItemStackRenderer.java index 9792f7cc0..a7bf4dc5a 100644 --- a/RebornCore/src/client/java/reborncore/client/ItemStackRenderer.java +++ b/RebornCore/src/client/java/reborncore/client/ItemStackRenderer.java @@ -35,9 +35,10 @@ import net.minecraft.client.render.DiffuseLighting; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.math.Matrix4f; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; +import org.joml.Matrix4f; import org.lwjgl.opengl.GL12; import java.nio.file.Files; @@ -56,14 +57,15 @@ public class ItemStackRenderer implements HudRenderCallback { public void onHudRender(MatrixStack matrixStack, float v) { if (!ItemStackRenderManager.RENDER_QUEUE.isEmpty()) { ItemStack itemStack = ItemStackRenderManager.RENDER_QUEUE.remove(); - Identifier id = Registry.ITEM.getId(itemStack.getItem()); + Identifier id = Registries.ITEM.getId(itemStack.getItem()); MinecraftClient.getInstance().textRenderer.draw(matrixStack, "Rendering " + id + ", " + ItemStackRenderManager.RENDER_QUEUE.size() + " items left", 5, 5, -1); export(id, itemStack); } } private void export(Identifier identifier, ItemStack item) { - RenderSystem.setProjectionMatrix(Matrix4f.projectionMatrix(0, 16, 0, 16, 1000, 3000)); + Matrix4f matrix4f = new Matrix4f().setOrtho(0, 16, 0, 16, 1000, 3000); + RenderSystem.setProjectionMatrix(matrix4f); MatrixStack stack = RenderSystem.getModelViewStack(); stack.loadIdentity(); stack.translate(0, 0, -2000); diff --git a/RebornCore/src/client/java/reborncore/client/RebornFluidRenderManager.java b/RebornCore/src/client/java/reborncore/client/RebornFluidRenderManager.java index 7870f6e3b..83c0b8826 100644 --- a/RebornCore/src/client/java/reborncore/client/RebornFluidRenderManager.java +++ b/RebornCore/src/client/java/reborncore/client/RebornFluidRenderManager.java @@ -25,16 +25,13 @@ package reborncore.client; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.fluid.Fluid; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceType; -import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Identifier; import reborncore.common.fluid.FluidSettings; import reborncore.common.fluid.RebornFluid; @@ -45,15 +42,13 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.stream.Stream; -public class RebornFluidRenderManager implements ClientSpriteRegistryCallback, SimpleSynchronousResourceReloadListener { +public class RebornFluidRenderManager implements SimpleSynchronousResourceReloadListener { private static final Map> spriteMap = new HashMap<>(); public static void setupClient() { RebornFluidRenderManager rebornFluidRenderManager = new RebornFluidRenderManager(); - ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register(rebornFluidRenderManager); ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(rebornFluidRenderManager); RebornFluidManager.getFluidStream().forEach(RebornFluidRenderManager::setupFluidRenderer); } @@ -70,14 +65,6 @@ public class RebornFluidRenderManager implements ClientSpriteRegistryCallback, S FluidRenderHandlerRegistry.INSTANCE.register(fluid, (extendedBlockView, blockPos, fluidState) -> sprites.get()); } - @Override - public void registerSprites(SpriteAtlasTexture spriteAtlasTexture, Registry registry) { - Stream.concat( - RebornFluidManager.getFluidStream().map(rebornFluid -> rebornFluid.getFluidSettings().getFlowingTexture()), - RebornFluidManager.getFluidStream().map(rebornFluid -> rebornFluid.getFluidSettings().getStillTexture()) - ).forEach(registry::register); - } - @Override public Identifier getFabricId() { return new Identifier("reborncore", "fluid_render_manager"); diff --git a/RebornCore/src/client/java/reborncore/client/RenderUtil.java b/RebornCore/src/client/java/reborncore/client/RenderUtil.java index c4e59d0cc..3176e4ed6 100644 --- a/RebornCore/src/client/java/reborncore/client/RenderUtil.java +++ b/RebornCore/src/client/java/reborncore/client/RenderUtil.java @@ -150,7 +150,7 @@ public class RenderUtil { RenderSystem.disableTexture(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); diff --git a/RebornCore/src/client/java/reborncore/client/gui/GuiButtonCustomTexture.java b/RebornCore/src/client/java/reborncore/client/gui/GuiButtonCustomTexture.java deleted file mode 100644 index 2002695b0..000000000 --- a/RebornCore/src/client/java/reborncore/client/gui/GuiButtonCustomTexture.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.client.gui; - -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import reborncore.common.util.Color; - -public class GuiButtonCustomTexture extends ButtonWidget { - public int textureU; - public int textureV; - public String textureName; - public String linkedPage; - public Text name; - public String imagePrefix = "techreborn:textures/manual/elements/"; - public int buttonHeight; - public int buttonWidth; - public int buttonU; - public int buttonV; - public int textureH; - public int textureW; - - public GuiButtonCustomTexture(int xPos, int yPos, int u, int v, int buttonWidth, int buttonHeight, - String textureName, String linkedPage, Text name, int buttonU, int buttonV, int textureH, int textureW, ButtonWidget.PressAction pressAction) { - super(xPos, yPos, buttonWidth, buttonHeight, Text.empty(), pressAction); - this.textureU = u; - this.textureV = v; - this.textureName = textureName; - this.name = name; - this.linkedPage = linkedPage; - this.buttonHeight = height; - this.buttonWidth = width; - this.buttonU = buttonU; - this.buttonV = buttonV; - this.textureH = textureH; - this.textureW = textureW; - } - - public void drawButton(MatrixStack matrixStack, MinecraftClient mc, int mouseX, int mouseY) { - if (this.visible) { - boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width - && mouseY < this.y + this.height; - RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE); - int u = textureU; - int v = textureV; - - if (flag) { - u += width; - matrixStack.push(); - RenderSystem.setShaderColor(0f, 0f, 0f, 1f); - this.drawTexture(matrixStack, this.x, this.y, u, v, width, height); - matrixStack.pop(); - } - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - renderImage(matrixStack, this.x, this.y); - drawTextWithShadow(matrixStack, mc.textRenderer, this.name, this.x + 20, this.y + 3, - Color.WHITE.getColor()); - } - } - - public void renderImage(MatrixStack matrixStack, int offsetX, int offsetY) { - RenderSystem.setShaderTexture(0, new Identifier(imagePrefix + this.textureName + ".png")); - - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - drawTexture(matrixStack, offsetX, offsetY, this.buttonU, this.buttonV, this.textureW, this.textureH); - RenderSystem.disableBlend(); - } - -} diff --git a/RebornCore/src/client/java/reborncore/client/gui/GuiButtonItemTexture.java b/RebornCore/src/client/java/reborncore/client/gui/GuiButtonItemTexture.java deleted file mode 100644 index 62669692a..000000000 --- a/RebornCore/src/client/java/reborncore/client/gui/GuiButtonItemTexture.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.client.gui; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; -import reborncore.common.util.Color; - -public class GuiButtonItemTexture extends ButtonWidget { - - public int textureU; - public int textureV; - public ItemStack itemstack; - public String LINKED_PAGE; - public Text NAME; - - public GuiButtonItemTexture(int xPos, int yPos, int u, int v, int width, int height, ItemStack stack, - String linkedPage, Text name, ButtonWidget.PressAction pressAction) { - super(xPos, yPos, width, height, Text.empty(), pressAction); - textureU = u; - textureV = v; - itemstack = stack; - NAME = name; - this.LINKED_PAGE = linkedPage; - } - - @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float ticks) { - if (this.visible) { - MinecraftClient mc = MinecraftClient.getInstance(); - boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width - && mouseY < this.y + this.height; - RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE); - int u = textureU; - int v = textureV; - if (flag) { - u += mc.textRenderer.getWidth(this.NAME) + 25; - v += mc.textRenderer.getWidth(this.NAME) + 25; - matrixStack.push(); - RenderSystem.setShaderColor(0f, 0f, 0f, 1f); - this.drawTexture(matrixStack, this.x, this.y, u, v, mc.textRenderer.getWidth(this.NAME) + 25, height); - matrixStack.pop(); - } - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - //GL11.glEnable(32826); RESCALE_NORMAL_EXT - // DiffuseLighting.enable(); FIXME 1.17 - ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer(); - itemRenderer.renderGuiItemIcon(itemstack, this.x, this.y); - this.drawTextWithShadow(matrixStack, mc.textRenderer, this.NAME, this.x + 20, this.y + 3, - Color.WHITE.getColor()); - } - } - -} diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/GuiBase.java b/RebornCore/src/client/java/reborncore/client/gui/builder/GuiBase.java index 736291d57..f10fd7e1a 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/GuiBase.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/GuiBase.java @@ -278,7 +278,8 @@ public class GuiBase extends HandledScreen { for (Selectable selectable : selectables) { if (selectable instanceof ClickableWidget clickable) { if (clickable.isHovered()) { - clickable.renderTooltip(matrixStack, mouseX, mouseY); + // TODO 1.19.3 + // clickable.renderTooltip(matrixStack, mouseX, mouseY); break; } } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java index 44413bc06..7751c451f 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java @@ -37,9 +37,9 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Quaternion; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import net.minecraft.world.World; +import org.joml.Quaternionf; import reborncore.RebornCore; import reborncore.client.ClientNetworkManager; import reborncore.client.gui.GuiUtil; @@ -75,12 +75,12 @@ public class FluidConfigPopupElement extends ElementBase { BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); MinecraftClient.getInstance().getTextureManager().bindTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); - drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //left - drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, Vec3f.NEGATIVE_X.getDegreesQuaternion(90F)); //top + drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //left + drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, RotationAxis.NEGATIVE_X.rotationDegrees(90F)); //top drawState(gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre - drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, Vec3f.POSITIVE_X.getDegreesQuaternion(90F)); //bottom - drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right - drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back + drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, RotationAxis.POSITIVE_X.rotationDegrees(90F)); //bottom + drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //right + drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, RotationAxis.POSITIVE_Y.rotationDegrees(180F)); //back drawSateColor(matrixStack, gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui); drawSateColor(matrixStack, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui); @@ -178,7 +178,7 @@ public class FluidConfigPopupElement extends ElementBase { BlockRenderManager dispatcher, int x, int y, - Quaternion quaternion) { + Quaternionf quaternion) { MatrixStack matrixStack = new MatrixStack(); matrixStack.push(); diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java index d8337141a..c3d064c23 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java @@ -37,9 +37,9 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Quaternion; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import net.minecraft.world.World; +import org.joml.Quaternionf; import reborncore.RebornCore; import reborncore.client.ClientNetworkManager; import reborncore.client.gui.GuiUtil; @@ -79,12 +79,12 @@ public class SlotConfigPopupElement extends ElementBase { BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); MinecraftClient.getInstance().getTextureManager().bindTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); - drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //left - drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, Vec3f.NEGATIVE_X.getDegreesQuaternion(90F)); //top + drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //left + drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, RotationAxis.NEGATIVE_X.rotationDegrees(90F)); //top drawState(gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre - drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, Vec3f.POSITIVE_X.getDegreesQuaternion(90F)); //bottom - drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right - drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back + drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, RotationAxis.POSITIVE_X.rotationDegrees(90F)); //bottom + drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //right + drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, RotationAxis.POSITIVE_Y.rotationDegrees(180F)); //back drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui); drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui); @@ -184,7 +184,7 @@ public class SlotConfigPopupElement extends ElementBase { BlockRenderManager dispatcher, int x, int y, - Quaternion quaternion) { + Quaternionf quaternion) { MatrixStack matrixStack = new MatrixStack(); matrixStack.push(); diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonExtended.java b/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonExtended.java index 41e26b44f..ad11546d2 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonExtended.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonExtended.java @@ -25,19 +25,22 @@ package reborncore.client.gui.builder.widget; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import reborncore.common.misc.TriConsumer; +import java.util.function.Supplier; + public class GuiButtonExtended extends ButtonWidget { private TriConsumer clickHandler; public GuiButtonExtended(int x, int y, Text buttonText, ButtonWidget.PressAction pressAction) { - super(x, y, 20, 200, buttonText, pressAction); + super(x, y, 20, 200, buttonText, pressAction, narrationSupplier()); } public GuiButtonExtended(int x, int y, int widthIn, int heightIn, Text buttonText, ButtonWidget.PressAction pressAction) { - super(x, y, widthIn, heightIn, buttonText, pressAction); + super(x, y, widthIn, heightIn, buttonText, pressAction, narrationSupplier()); } public GuiButtonExtended clickHandler(TriConsumer consumer) { @@ -52,4 +55,11 @@ public class GuiButtonExtended extends ButtonWidget { } super.onClick(mouseX, mouseY); } + + private static NarrationSupplier narrationSupplier() { + return textSupplier -> { + // TODO 1.19.3 + return null; + }; + } } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonSimple.java b/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonSimple.java index 543e27d51..26a11348d 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonSimple.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonSimple.java @@ -34,7 +34,7 @@ public class GuiButtonSimple extends ButtonWidget { */ @Deprecated public GuiButtonSimple(int x, int y, Text buttonText, ButtonWidget.PressAction pressAction) { - super(x, y, 20, 200, buttonText, pressAction); + super(x, y, 20, 200, buttonText, pressAction, narrationSupplier()); } /** @@ -42,6 +42,13 @@ public class GuiButtonSimple extends ButtonWidget { */ @Deprecated public GuiButtonSimple(int x, int y, int widthIn, int heightIn, Text buttonText, ButtonWidget.PressAction pressAction) { - super(x, y, widthIn, heightIn, buttonText, pressAction); + super(x, y, widthIn, heightIn, buttonText, pressAction, narrationSupplier()); + } + + private static NarrationSupplier narrationSupplier() { + return textSupplier -> { + // TODO 1.19.3 + return null; + }; } } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonUpDown.java b/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonUpDown.java index 90d8dca19..bc3fec5de 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonUpDown.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/widget/GuiButtonUpDown.java @@ -50,16 +50,16 @@ public class GuiButtonUpDown extends GuiButtonExtended { RenderSystem.setShaderTexture(0, gui.builder.getResourceLocation()); switch (type) { case FASTFORWARD: - gui.drawTexture(matrixStack, x, y, 174, 74, 12, 12); + gui.drawTexture(matrixStack, getX(), getY(), 174, 74, 12, 12); break; case FORWARD: - gui.drawTexture(matrixStack, x, y, 174, 86, 12, 12); + gui.drawTexture(matrixStack, getX(), getY(), 174, 86, 12, 12); break; case REWIND: - gui.drawTexture(matrixStack, x, y, 174, 98, 12, 12); + gui.drawTexture(matrixStack, getX(), getY(), 174, 98, 12, 12); break; case FASTREWIND: - gui.drawTexture(matrixStack, x, y, 174, 110, 12, 12); + gui.drawTexture(matrixStack, getX(), getY(), 174, 110, 12, 12); break; default: break; diff --git a/RebornCore/src/client/java/reborncore/client/gui/componets/BaseTextures.java b/RebornCore/src/client/java/reborncore/client/gui/componets/BaseTextures.java deleted file mode 100644 index 43a9ed713..000000000 --- a/RebornCore/src/client/java/reborncore/client/gui/componets/BaseTextures.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.client.gui.componets; - -public class BaseTextures { - // - // private static final ResourceLocation baseTexture = new ResourceLocation("reborncore", "textures/gui/base.png"); - // - // public GuiTexture background; - // public GuiTexture slot; - // public GuiTexture burnBase; - // public GuiTexture burnOverlay; - // public GuiTexture powerBase; - // public GuiTexture powerOverlay; - // public GuiTexture progressBase; - // public GuiTexture progressOverlay; - // public GuiTexture tank; - // public GuiTexture tankBase; - // public GuiTexture tankScale; - // public GuiTexture powerBaseOld; - // public GuiTexture powerOverlayOld; - // - // public BaseTextures() - // { - // background = new GuiTexture(baseTexture, 176, 166, 0, 0); - // slot = new GuiTexture(baseTexture, 18, 18, 176, 31); - // burnBase = new GuiTexture(baseTexture, 14, 14, 176, 0); - // burnOverlay = new GuiTexture(baseTexture, 13, 13, 176, 50); - // powerBase = new GuiTexture(baseTexture, 7, 13, 190, 0); - // powerOverlay = new GuiTexture(baseTexture, 7, 13, 197, 0); - // progressBase = new GuiTexture(baseTexture, 22, 15, 200, 14); - // progressOverlay = new GuiTexture(baseTexture, 22, 16, 177, 14); - // tank = new GuiTexture(baseTexture, 20, 55, 176, 63); - // tankBase = new GuiTexture(baseTexture, 20, 55, 196, 63); - // tankScale = new GuiTexture(baseTexture, 20, 55, 216, 63); - // powerBaseOld = new GuiTexture(baseTexture, 32, 17, 224, 13); - // powerOverlayOld = new GuiTexture(baseTexture, 32, 17, 224, 30); - // } -} diff --git a/RebornCore/src/client/java/reborncore/client/gui/componets/GuiHiddenButton.java b/RebornCore/src/client/java/reborncore/client/gui/componets/GuiHiddenButton.java deleted file mode 100644 index f1e2f962e..000000000 --- a/RebornCore/src/client/java/reborncore/client/gui/componets/GuiHiddenButton.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.client.gui.componets; - -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; - -public class GuiHiddenButton extends ButtonWidget { - - public GuiHiddenButton(int xPosition, int yPosition, Text displayString) { - super(xPosition, yPosition, 0, 0, displayString, var1 -> { - }); - } - - public GuiHiddenButton(int id, int xPosition, int yPosition, int width, int height, Text displayString) { - super(xPosition, yPosition, width, height, displayString, var1 -> { - }); - } - - @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - if (this.visible) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; - RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mouseX >= this.x && mouseY >= this.y - && mouseX < this.x + this.width && mouseY < this.y + this.height; - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(770, 771, 1, 0); - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - int l = 14737632; - - if (!this.active) { - l = 10526880; - } else if (this.isHovered()) { - l = 16777120; - } - - this.drawTextWithShadow(matrixStack, textRenderer, this.getMessage(), this.x + this.width / 2, - this.y + (this.height - 8) / 2, l); - } - } -} diff --git a/RebornCore/src/client/java/reborncore/client/gui/guibuilder/GuiBuilder.java b/RebornCore/src/client/java/reborncore/client/gui/guibuilder/GuiBuilder.java index 1011bbeb3..89d2c1f58 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/guibuilder/GuiBuilder.java +++ b/RebornCore/src/client/java/reborncore/client/gui/guibuilder/GuiBuilder.java @@ -721,7 +721,7 @@ public class GuiBuilder { int color = FluidVariantRendering.getColor(fluid.getVariant()); final int drawHeight = (int) (fluid.getAmount().getRawValue() / (maxCapacity * 1F) * height); - final int iconHeight = sprite.getHeight(); + final int iconHeight = sprite.getContents().getHeight(); int offsetHeight = drawHeight; RenderSystem.setShaderColor((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F, 1F); diff --git a/RebornCore/src/client/resources/assets/minecraft/atlases/blocks.json b/RebornCore/src/client/resources/assets/minecraft/atlases/blocks.json new file mode 100644 index 000000000..5bfd155ef --- /dev/null +++ b/RebornCore/src/client/resources/assets/minecraft/atlases/blocks.json @@ -0,0 +1,20 @@ +{ + "sources": [ + { + "type": "single", + "resource": "reborncore:gui/slot_sprites/armour_head" + }, + { + "type": "single", + "resource": "reborncore:gui/slot_sprites/armour_chest" + }, + { + "type": "single", + "resource": "reborncore:gui/slot_sprites/armour_legs" + }, + { + "type": "single", + "resource": "reborncore:gui/slot_sprites/armour_feet" + } + ] +} \ No newline at end of file diff --git a/RebornCore/src/main/java/reborncore/RebornRegistry.java b/RebornCore/src/main/java/reborncore/RebornRegistry.java index c62a9e42c..ac26146b8 100644 --- a/RebornCore/src/main/java/reborncore/RebornRegistry.java +++ b/RebornCore/src/main/java/reborncore/RebornRegistry.java @@ -27,8 +27,9 @@ package reborncore; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import org.apache.commons.lang3.Validate; import java.util.HashMap; @@ -49,15 +50,15 @@ public class RebornRegistry { * @param name {@link Identifier} Registry name for block and item */ public static void registerBlock(Block block, Item.Settings builder, Identifier name) { - Registry.register(Registry.BLOCK, name, block); + Registry.register(Registries.BLOCK, name, block); BlockItem itemBlock = new BlockItem(block, builder); - Registry.register(Registry.ITEM, name, itemBlock); + Registry.register(Registries.ITEM, name, itemBlock); } public static void registerBlock(Block block, Function blockItemFunction, Identifier name) { - Registry.register(Registry.BLOCK, name, block); + Registry.register(Registries.BLOCK, name, block); BlockItem itemBlock = blockItemFunction.apply(block); - Registry.register(Registry.ITEM, name, itemBlock); + Registry.register(Registries.ITEM, name, itemBlock); } /** @@ -86,7 +87,7 @@ public class RebornRegistry { */ public static void registerBlockNoItem(Block block) { Validate.isTrue(objIdentMap.containsKey(block)); - Registry.register(Registry.BLOCK, objIdentMap.get(block), block); + Registry.register(Registries.BLOCK, objIdentMap.get(block), block); } @@ -97,7 +98,7 @@ public class RebornRegistry { * @param name {@link Identifier} Registry name for item */ public static void registerItem(Item item, Identifier name) { - Registry.register(Registry.ITEM, name, item); + Registry.register(Registries.ITEM, name, item); } /** diff --git a/RebornCore/src/main/java/reborncore/common/RebornCoreCommands.java b/RebornCore/src/main/java/reborncore/common/RebornCoreCommands.java index 3cd54420f..e35399d29 100644 --- a/RebornCore/src/main/java/reborncore/common/RebornCoreCommands.java +++ b/RebornCore/src/main/java/reborncore/common/RebornCoreCommands.java @@ -38,13 +38,14 @@ import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.command.argument.ItemStackArgumentType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import net.minecraft.world.chunk.ChunkStatus; import reborncore.common.network.ClientBoundPackets; import reborncore.common.network.IdentifiedPacket; @@ -157,9 +158,9 @@ public class RebornCoreCommands { private static int renderMod(CommandContext ctx) { String modid = StringArgumentType.getString(ctx, "modid"); - List list = Registry.ITEM.getIds().stream() + List list = Registries.ITEM.getIds().stream() .filter(identifier -> identifier.getNamespace().equals(modid)) - .map(Registry.ITEM::get) + .map(Registries.ITEM::get) .map(ItemStack::new) .collect(Collectors.toList()); diff --git a/RebornCore/src/main/java/reborncore/common/chunkloading/ChunkLoaderManager.java b/RebornCore/src/main/java/reborncore/common/chunkloading/ChunkLoaderManager.java index af4119d10..a3c4a06c2 100644 --- a/RebornCore/src/main/java/reborncore/common/chunkloading/ChunkLoaderManager.java +++ b/RebornCore/src/main/java/reborncore/common/chunkloading/ChunkLoaderManager.java @@ -36,7 +36,7 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.registry.RegistryKey; import net.minecraft.world.PersistentState; import net.minecraft.world.World; import org.apache.commons.lang3.StringUtils; diff --git a/RebornCore/src/main/java/reborncore/common/crafting/RebornRecipe.java b/RebornCore/src/main/java/reborncore/common/crafting/RebornRecipe.java index 596663872..95b3a3cc9 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/RebornRecipe.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/RebornRecipe.java @@ -32,9 +32,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeSerializer; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import net.minecraft.world.World; import reborncore.RebornCore; import reborncore.api.recipe.IRecipeCrafterProvider; @@ -63,7 +64,7 @@ public class RebornRecipe implements Recipe, CustomOutputRecipe { @Override public ItemStack createIcon() { - Optional catalyst = Registry.ITEM.getOrEmpty(type.name()); + Optional catalyst = Registries.ITEM.getOrEmpty(type.name()); if (catalyst.isPresent()) return new ItemStack(catalyst.get()); else diff --git a/RebornCore/src/main/java/reborncore/common/crafting/RecipeManager.java b/RebornCore/src/main/java/reborncore/common/crafting/RecipeManager.java index 358302318..790f77930 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/RecipeManager.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/RecipeManager.java @@ -24,8 +24,9 @@ package reborncore.common.crafting; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.common.crafting.serde.RebornRecipeSerde; import reborncore.common.crafting.serde.RecipeSerde; @@ -49,8 +50,8 @@ public class RecipeManager { RebornRecipeType type = new RebornRecipeType<>(recipeSerde, name); recipeTypes.put(name, type); - Registry.register(Registry.RECIPE_TYPE, name, type); - Registry.register(Registry.RECIPE_SERIALIZER, name, type); + Registry.register(Registries.RECIPE_TYPE, name, type); + Registry.register(Registries.RECIPE_SERIALIZER, name, type); return type; } diff --git a/RebornCore/src/main/java/reborncore/common/crafting/RecipeUtils.java b/RebornCore/src/main/java/reborncore/common/crafting/RecipeUtils.java index 55d2997c7..7755200fe 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/RecipeUtils.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/RecipeUtils.java @@ -37,10 +37,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtOps; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import reborncore.common.util.DefaultedListCollector; @@ -64,7 +65,7 @@ public class RecipeUtils { private static ItemStack deserializeItem(JsonObject jsonObject) { Identifier resourceLocation = new Identifier(JsonHelper.getString(jsonObject, "item")); - Item item = Registry.ITEM.get(resourceLocation); + Item item = Registries.ITEM.get(resourceLocation); if (item == Items.AIR) { throw new IllegalStateException(resourceLocation + " did not exist"); } diff --git a/RebornCore/src/main/java/reborncore/common/crafting/ShapedRecipeHelper.java b/RebornCore/src/main/java/reborncore/common/crafting/ShapedRecipeHelper.java index 7d187b6b9..5cc585372 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/ShapedRecipeHelper.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/ShapedRecipeHelper.java @@ -29,10 +29,11 @@ import com.google.gson.JsonObject; import net.minecraft.item.Item; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.ShapedRecipe; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registries; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.JsonHelper; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.registry.Registry; +import net.minecraft.registry.entry.RegistryEntry; import java.util.Map; import java.util.stream.Stream; @@ -61,7 +62,7 @@ public class ShapedRecipeHelper { for (Item item : items) { JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("item", Registry.ITEM.getId(item).toString()); + jsonObject.addProperty("item", Registries.ITEM.getId(item).toString()); entries.add(jsonObject); } } else { @@ -82,7 +83,7 @@ public class ShapedRecipeHelper { } private static Stream streamItemsFromTag(TagKey tag) { - return StreamSupport.stream(Registry.ITEM.iterateEntries(tag).spliterator(), false) + return StreamSupport.stream(Registries.ITEM.iterateEntries(tag).spliterator(), false) .map(RegistryEntry::value); } } diff --git a/RebornCore/src/main/java/reborncore/common/crafting/ingredient/FluidIngredient.java b/RebornCore/src/main/java/reborncore/common/crafting/ingredient/FluidIngredient.java index 825a95419..c6ae9cfa8 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/ingredient/FluidIngredient.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/ingredient/FluidIngredient.java @@ -34,10 +34,11 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; import net.minecraft.util.Lazy; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.common.fluid.container.ItemFluidInfo; import java.util.ArrayList; @@ -60,7 +61,7 @@ public class FluidIngredient extends RebornIngredient { this.holders = holders; this.count = count; - previewStacks = new Lazy<>(() -> Registry.ITEM.stream() + previewStacks = new Lazy<>(() -> Registries.ITEM.stream() .filter(item -> item instanceof ItemFluidInfo) .filter(item -> !holders.isPresent() || holders.get().stream().anyMatch(i -> i == item)) .map(item -> ((ItemFluidInfo) item).getFull(fluid)) @@ -72,7 +73,7 @@ public class FluidIngredient extends RebornIngredient { public static RebornIngredient deserialize(JsonObject json) { Identifier identifier = new Identifier(JsonHelper.getString(json, "fluid")); - Fluid fluid = Registry.FLUID.get(identifier); + Fluid fluid = Registries.FLUID.get(identifier); if (fluid == Fluids.EMPTY) { throw new JsonParseException("Fluid could not be found: " + JsonHelper.getString(json, "fluid")); } @@ -82,7 +83,7 @@ public class FluidIngredient extends RebornIngredient { if (json.has("holder")) { if (json.get("holder").isJsonPrimitive()) { String ident = JsonHelper.getString(json, "holder"); - Item item = Registry.ITEM.get(new Identifier(ident)); + Item item = Registries.ITEM.get(new Identifier(ident)); if (item == Items.AIR) { throw new JsonParseException("could not find item:" + ident); } @@ -92,7 +93,7 @@ public class FluidIngredient extends RebornIngredient { List itemList = new ArrayList<>(); for (int i = 0; i < jsonArray.size(); i++) { String ident = jsonArray.get(i).getAsString(); - Item item = Registry.ITEM.get(new Identifier(ident)); + Item item = Registries.ITEM.get(new Identifier(ident)); if (item == Items.AIR) { throw new JsonParseException("could not find item:" + ident); } @@ -138,14 +139,14 @@ public class FluidIngredient extends RebornIngredient { @Override public JsonObject toJson(boolean networkSync) { JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("fluid", Registry.FLUID.getId(fluid).toString()); + jsonObject.addProperty("fluid", Registries.FLUID.getId(fluid).toString()); if (holders.isPresent()) { List holderList = holders.get(); if (holderList.size() == 1) { - jsonObject.addProperty("holder", Registry.ITEM.getId(holderList.get(0)).toString()); + jsonObject.addProperty("holder", Registries.ITEM.getId(holderList.get(0)).toString()); } else { JsonArray holderArray = new JsonArray(); - holderList.forEach(item -> holderArray.add(new JsonPrimitive(Registry.ITEM.getId(item).toString()))); + holderList.forEach(item -> holderArray.add(new JsonPrimitive(Registries.ITEM.getId(item).toString()))); jsonObject.add("holder", holderArray); } } diff --git a/RebornCore/src/main/java/reborncore/common/crafting/ingredient/StackIngredient.java b/RebornCore/src/main/java/reborncore/common/crafting/ingredient/StackIngredient.java index 11db8608a..6377f89f2 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/ingredient/StackIngredient.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/ingredient/StackIngredient.java @@ -34,9 +34,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtOps; import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import org.apache.commons.lang3.Validate; import java.util.Collections; @@ -62,7 +63,7 @@ public class StackIngredient extends RebornIngredient { public static RebornIngredient deserialize(JsonObject json) { Identifier identifier = new Identifier(JsonHelper.getString(json, "item")); - Item item = Registry.ITEM.getOrEmpty(identifier).orElseThrow(() -> new JsonSyntaxException("Unknown item '" + identifier + "'")); + Item item = Registries.ITEM.getOrEmpty(identifier).orElseThrow(() -> new JsonSyntaxException("Unknown item '" + identifier + "'")); Optional stackSize = Optional.empty(); if (json.has("count")) { @@ -137,7 +138,7 @@ public class StackIngredient extends RebornIngredient { public JsonObject toJson(boolean networkSync) { JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("item", Registry.ITEM.getId(stack.getItem()).toString()); + jsonObject.addProperty("item", Registries.ITEM.getId(stack.getItem()).toString()); count.ifPresent(integer -> jsonObject.addProperty("count", integer)); if (requireEmptyNbt) { diff --git a/RebornCore/src/main/java/reborncore/common/crafting/ingredient/TagIngredient.java b/RebornCore/src/main/java/reborncore/common/crafting/ingredient/TagIngredient.java index 6cf8648c0..9ae5a80c5 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/ingredient/TagIngredient.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/ingredient/TagIngredient.java @@ -30,11 +30,13 @@ import com.google.gson.JsonObject; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.registry.Registry; +import net.minecraft.registry.entry.RegistryEntry; import org.apache.commons.lang3.Validate; import java.util.ArrayList; @@ -85,16 +87,16 @@ public class TagIngredient extends RebornIngredient { final JsonArray itemsArray = JsonHelper.getArray(json, "items"); for (JsonElement jsonElement : itemsArray) { Validate.isTrue(jsonElement.isJsonPrimitive()); - Optional> entry = Registry.ITEM.getEntry(jsonElement.getAsInt()); - items.add(entry.orElseThrow().value()); + Item item = Registries.ITEM.get(jsonElement.getAsInt()); + items.add(item); } - return new Synced(TagKey.of(Registry.ITEM_KEY, tagIdent), count, items); + return new Synced(TagKey.of(RegistryKeys.ITEM, tagIdent), count, items); } Identifier identifier = new Identifier(JsonHelper.getString(json, "tag")); - TagKey tagKey = TagKey.of(Registry.ITEM_KEY, identifier); + TagKey tagKey = TagKey.of(RegistryKeys.ITEM, identifier); return new TagIngredient(tagKey, count); } @@ -118,7 +120,7 @@ public class TagIngredient extends RebornIngredient { JsonArray itemArray = new JsonArray(); for (Item item : items) { - int rawId = Registry.ITEM.getRawId(item); + int rawId = Registries.ITEM.getRawId(item); itemArray.add(rawId); } @@ -130,7 +132,7 @@ public class TagIngredient extends RebornIngredient { } protected Stream streamItems() { - return StreamSupport.stream(Registry.ITEM.iterateEntries(tag).spliterator(), false) + return StreamSupport.stream(Registries.ITEM.iterateEntries(tag).spliterator(), false) .map(RegistryEntry::value); } diff --git a/RebornCore/src/main/java/reborncore/common/crafting/serde/AbstractRecipeSerde.java b/RebornCore/src/main/java/reborncore/common/crafting/serde/AbstractRecipeSerde.java index 67f27c922..18189d592 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/serde/AbstractRecipeSerde.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/serde/AbstractRecipeSerde.java @@ -30,8 +30,9 @@ import com.mojang.serialization.Dynamic; import com.mojang.serialization.JsonOps; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtOps; +import net.minecraft.registry.Registries; import net.minecraft.util.JsonHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RecipeUtils; import reborncore.common.crafting.ingredient.IngredientFactory; @@ -72,7 +73,7 @@ public abstract class AbstractRecipeSerde implements Rec for (ItemStack stack : recipe.getOutputs()) { final JsonObject stackObject = new JsonObject(); - stackObject.addProperty("item", Registry.ITEM.getId(stack.getItem()).toString()); + stackObject.addProperty("item", Registries.ITEM.getId(stack.getItem()).toString()); if (stack.getCount() > 1) { stackObject.addProperty("count", stack.getCount()); diff --git a/RebornCore/src/main/java/reborncore/common/crafting/serde/RebornFluidRecipeSerde.java b/RebornCore/src/main/java/reborncore/common/crafting/serde/RebornFluidRecipeSerde.java index 19b879bdd..c5fed78e1 100644 --- a/RebornCore/src/main/java/reborncore/common/crafting/serde/RebornFluidRecipeSerde.java +++ b/RebornCore/src/main/java/reborncore/common/crafting/serde/RebornFluidRecipeSerde.java @@ -27,9 +27,10 @@ package reborncore.common.crafting.serde; import com.google.gson.JsonObject; import net.minecraft.fluid.Fluid; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.NotNull; import reborncore.common.crafting.RebornFluidRecipe; import reborncore.common.crafting.RebornRecipeType; @@ -46,7 +47,7 @@ public abstract class RebornFluidRecipeSerde extend protected final R fromJson(JsonObject jsonObject, RebornRecipeType type, Identifier name, List ingredients, List outputs, int power, int time) { final JsonObject tank = JsonHelper.getObject(jsonObject, "tank"); final Identifier identifier = new Identifier(JsonHelper.getString(tank, "fluid")); - final Fluid fluid = Registry.FLUID.get(identifier); + final Fluid fluid = Registries.FLUID.get(identifier); FluidValue value = FluidValue.BUCKET; if (tank.has("amount")){ @@ -61,7 +62,7 @@ public abstract class RebornFluidRecipeSerde extend @Override public void collectJsonData(R recipe, JsonObject jsonObject, boolean networkSync) { final JsonObject tankObject = new JsonObject(); - tankObject.addProperty("fluid", Registry.FLUID.getId(recipe.getFluidInstance().getFluid()).toString()); + tankObject.addProperty("fluid", Registries.FLUID.getId(recipe.getFluidInstance().getFluid()).toString()); var amountObject = new JsonObject(); amountObject.addProperty("droplets", recipe.getFluidInstance().getAmount().getRawValue()); diff --git a/RebornCore/src/main/java/reborncore/common/fluid/FluidUtils.java b/RebornCore/src/main/java/reborncore/common/fluid/FluidUtils.java index 926b2a270..8bf2e85fa 100644 --- a/RebornCore/src/main/java/reborncore/common/fluid/FluidUtils.java +++ b/RebornCore/src/main/java/reborncore/common/fluid/FluidUtils.java @@ -41,9 +41,10 @@ import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.text.Text; import net.minecraft.util.Hand; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import org.jetbrains.annotations.NotNull; import reborncore.common.fluid.container.FluidInstance; import reborncore.common.util.Tank; @@ -64,7 +65,7 @@ public class FluidUtils { } public static List getAllFluids() { - return Registry.FLUID.stream().collect(Collectors.toList()); + return Registries.FLUID.stream().collect(Collectors.toList()); } public static boolean drainContainers(Tank tank, Inventory inventory, int inputSlot, int outputSlot) { diff --git a/RebornCore/src/main/java/reborncore/common/fluid/RebornFluid.java b/RebornCore/src/main/java/reborncore/common/fluid/RebornFluid.java index fae899bd3..d9f3f3078 100644 --- a/RebornCore/src/main/java/reborncore/common/fluid/RebornFluid.java +++ b/RebornCore/src/main/java/reborncore/common/fluid/RebornFluid.java @@ -36,6 +36,7 @@ import net.minecraft.state.StateManager; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; +import net.minecraft.world.World; import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldView; @@ -75,7 +76,7 @@ public abstract class RebornFluid extends FlowableFluid { } @Override - protected boolean isInfinite() { + protected boolean isInfinite(World world) { return false; } diff --git a/RebornCore/src/main/java/reborncore/common/fluid/RebornFluidManager.java b/RebornCore/src/main/java/reborncore/common/fluid/RebornFluidManager.java index 1dc7df24a..318f68b49 100644 --- a/RebornCore/src/main/java/reborncore/common/fluid/RebornFluidManager.java +++ b/RebornCore/src/main/java/reborncore/common/fluid/RebornFluidManager.java @@ -24,8 +24,9 @@ package reborncore.common.fluid; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import java.util.HashMap; import java.util.stream.Stream; @@ -36,7 +37,7 @@ public class RebornFluidManager { public static void register(RebornFluid rebornFluid, Identifier identifier) { fluids.put(identifier, rebornFluid); - Registry.register(Registry.FLUID, identifier, rebornFluid); + Registry.register(Registries.FLUID, identifier, rebornFluid); } public static HashMap getFluids() { diff --git a/RebornCore/src/main/java/reborncore/common/fluid/container/FluidInstance.java b/RebornCore/src/main/java/reborncore/common/fluid/container/FluidInstance.java index 76a9ab89a..69abd713d 100644 --- a/RebornCore/src/main/java/reborncore/common/fluid/container/FluidInstance.java +++ b/RebornCore/src/main/java/reborncore/common/fluid/container/FluidInstance.java @@ -28,8 +28,9 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.common.fluid.FluidValue; import reborncore.common.util.NBTSerializable; @@ -114,7 +115,7 @@ public class FluidInstance implements NBTSerializable { @Override public NbtCompound write() { NbtCompound tag = new NbtCompound(); - tag.putString(FLUID_KEY, Registry.FLUID.getId(fluid).toString()); + tag.putString(FLUID_KEY, Registries.FLUID.getId(fluid).toString()); tag.putLong(AMOUNT_KEY, amount.getRawValue()); if (this.tag != null && !this.tag.isEmpty()) { tag.put(TAG_KEY, this.tag); @@ -124,7 +125,7 @@ public class FluidInstance implements NBTSerializable { @Override public void read(NbtCompound tag) { - fluid = Registry.FLUID.get(new Identifier(tag.getString(FLUID_KEY))); + fluid = Registries.FLUID.get(new Identifier(tag.getString(FLUID_KEY))); amount = FluidValue.fromRaw(tag.getLong(AMOUNT_KEY)); if (tag.contains(TAG_KEY)) { this.tag = tag.getCompound(TAG_KEY); diff --git a/RebornCore/src/main/java/reborncore/common/misc/ModSounds.java b/RebornCore/src/main/java/reborncore/common/misc/ModSounds.java index d561d053a..1b3696f18 100644 --- a/RebornCore/src/main/java/reborncore/common/misc/ModSounds.java +++ b/RebornCore/src/main/java/reborncore/common/misc/ModSounds.java @@ -24,9 +24,10 @@ package reborncore.common.misc; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; /** * @author drcrazy @@ -41,6 +42,6 @@ public class ModSounds { } private static SoundEvent createSoundEvent(Identifier identifier) { - return Registry.register(Registry.SOUND_EVENT, identifier, new SoundEvent(identifier)); + return Registry.register(Registries.SOUND_EVENT, identifier, SoundEvent.of(identifier)); } } diff --git a/RebornCore/src/main/java/reborncore/common/misc/RebornCoreTags.java b/RebornCore/src/main/java/reborncore/common/misc/RebornCoreTags.java index 019a0efc4..93ff73d97 100644 --- a/RebornCore/src/main/java/reborncore/common/misc/RebornCoreTags.java +++ b/RebornCore/src/main/java/reborncore/common/misc/RebornCoreTags.java @@ -25,10 +25,10 @@ package reborncore.common.misc; import net.minecraft.item.Item; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; public class RebornCoreTags { - public static final TagKey WATER_EXPLOSION_ITEM = TagKey.of(Registry.ITEM_KEY, new Identifier("reborncore", "water_explosion")); + public static final TagKey WATER_EXPLOSION_ITEM = TagKey.of(RegistryKeys.ITEM, new Identifier("reborncore", "water_explosion")); } diff --git a/RebornCore/src/main/java/reborncore/common/misc/TagConvertible.java b/RebornCore/src/main/java/reborncore/common/misc/TagConvertible.java index 34744aab3..57fce5e17 100644 --- a/RebornCore/src/main/java/reborncore/common/misc/TagConvertible.java +++ b/RebornCore/src/main/java/reborncore/common/misc/TagConvertible.java @@ -26,7 +26,7 @@ package reborncore.common.misc; import net.minecraft.block.Block; import net.minecraft.item.Item; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.tag.TagKey; import org.jetbrains.annotations.Contract; /** diff --git a/RebornCore/src/main/java/reborncore/common/recipes/PaddedShapedRecipe.java b/RebornCore/src/main/java/reborncore/common/recipes/PaddedShapedRecipe.java index 0053447b4..0a765d38d 100644 --- a/RebornCore/src/main/java/reborncore/common/recipes/PaddedShapedRecipe.java +++ b/RebornCore/src/main/java/reborncore/common/recipes/PaddedShapedRecipe.java @@ -30,26 +30,29 @@ import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.ShapedRecipe; +import net.minecraft.recipe.book.CraftingRecipeCategory; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.registry.Registry; import net.minecraft.world.World; import java.util.Map; public class PaddedShapedRecipe extends ShapedRecipe { public static final Identifier ID = new Identifier("reborncore", "padded"); - public static final RecipeSerializer PADDED = Registry.register(Registry.RECIPE_SERIALIZER, ID, new Serializer()); + public static final RecipeSerializer PADDED = Registry.register(Registries.RECIPE_SERIALIZER, ID, new Serializer()); - public PaddedShapedRecipe(Identifier id, String group, int width, int height, DefaultedList input, ItemStack output) { - super(id, group, width, height, input, output); + public PaddedShapedRecipe(Identifier id, String group, CraftingRecipeCategory category, int width, int height, DefaultedList input, ItemStack output) { + super(id, group, category, width, height, input, output); } private static class Serializer extends ShapedRecipe.Serializer { @Override public PaddedShapedRecipe read(Identifier identifier, JsonObject jsonObject) { String group = JsonHelper.getString(jsonObject, "group", ""); + CraftingRecipeCategory category = CraftingRecipeCategory.CODEC.byId(JsonHelper.getString(jsonObject, "category", null), CraftingRecipeCategory.MISC); Map map = readSymbols(JsonHelper.getObject(jsonObject, "key")); String[] strings = getPattern(JsonHelper.getArray(jsonObject, "pattern")); @@ -58,7 +61,7 @@ public class PaddedShapedRecipe extends ShapedRecipe { DefaultedList ingredients = createPatternMatrix(strings, map, width, height); ItemStack output = outputFromJson(JsonHelper.getObject(jsonObject, "result")); - return new PaddedShapedRecipe(identifier, group, width, height, ingredients, output); + return new PaddedShapedRecipe(identifier, group, category, width, height, ingredients, output); } } diff --git a/RebornCore/src/main/java/reborncore/common/screen/BuiltScreenHandler.java b/RebornCore/src/main/java/reborncore/common/screen/BuiltScreenHandler.java index eca558171..9c9442402 100644 --- a/RebornCore/src/main/java/reborncore/common/screen/BuiltScreenHandler.java +++ b/RebornCore/src/main/java/reborncore/common/screen/BuiltScreenHandler.java @@ -165,7 +165,7 @@ public class BuiltScreenHandler extends ScreenHandler { } @Override - public ItemStack transferSlot(final PlayerEntity player, final int index) { + public ItemStack quickMove(final PlayerEntity player, final int index) { ItemStack originalStack = ItemStack.EMPTY; diff --git a/RebornCore/src/main/java/reborncore/common/util/GenericWrenchHelper.java b/RebornCore/src/main/java/reborncore/common/util/GenericWrenchHelper.java index fafaafa3c..0f2242e8f 100644 --- a/RebornCore/src/main/java/reborncore/common/util/GenericWrenchHelper.java +++ b/RebornCore/src/main/java/reborncore/common/util/GenericWrenchHelper.java @@ -26,11 +26,11 @@ package reborncore.common.util; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; import net.minecraft.world.World; import reborncore.api.ICustomToolHandler; @@ -46,7 +46,7 @@ public class GenericWrenchHelper implements ICustomToolHandler { @Override public boolean canHandleTool(ItemStack stack) { - return Registry.ITEM.getId(stack.getItem()).equals(itemLocation); + return Registries.ITEM.getId(stack.getItem()).equals(itemLocation); } @Override diff --git a/RebornCore/src/main/java/reborncore/common/util/Tank.java b/RebornCore/src/main/java/reborncore/common/util/Tank.java index eff06d039..fb4b1c1ba 100644 --- a/RebornCore/src/main/java/reborncore/common/util/Tank.java +++ b/RebornCore/src/main/java/reborncore/common/util/Tank.java @@ -32,8 +32,9 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; @@ -123,7 +124,7 @@ public class Tank extends SnapshotParticipant implements Syncable @Override public void getSyncPair(List, Consumer>> pairList) { - pairList.add(Pair.of(() -> Registry.FLUID.getId(fluidInstance.getFluid()).toString(), (Consumer) o -> fluidInstance.setFluid(Registry.FLUID.get(new Identifier(o))))); + pairList.add(Pair.of(() -> Registries.FLUID.getId(fluidInstance.getFluid()).toString(), (Consumer) o -> fluidInstance.setFluid(Registries.FLUID.get(new Identifier(o))))); pairList.add(Pair.of(() -> fluidInstance.getAmount(), o -> fluidInstance.setAmount((FluidValue) o))); } diff --git a/RebornCore/src/main/java/reborncore/common/util/WorldUtils.java b/RebornCore/src/main/java/reborncore/common/util/WorldUtils.java index 2ed4d0293..ec3411fbe 100644 --- a/RebornCore/src/main/java/reborncore/common/util/WorldUtils.java +++ b/RebornCore/src/main/java/reborncore/common/util/WorldUtils.java @@ -24,15 +24,20 @@ package reborncore.common.util; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.ItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.random.Random; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -89,4 +94,8 @@ public class WorldUtils { itemStack.setCount(0); } } + + public static RegistryWrapper getBlockRegistryWrapper(@Nullable World world) { + return world != null ? world.createCommandRegistryWrapper(RegistryKeys.BLOCK) : Registries.BLOCK.getReadOnlyWrapper(); + } } diff --git a/RebornCore/src/main/java/reborncore/common/util/serialization/ItemStackSerializer.java b/RebornCore/src/main/java/reborncore/common/util/serialization/ItemStackSerializer.java index 0b53eb593..6f30bedc9 100644 --- a/RebornCore/src/main/java/reborncore/common/util/serialization/ItemStackSerializer.java +++ b/RebornCore/src/main/java/reborncore/common/util/serialization/ItemStackSerializer.java @@ -29,8 +29,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.StringNbtReader; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import java.lang.reflect.Type; @@ -68,8 +69,8 @@ public class ItemStackSerializer implements JsonSerializer, JsonDeser } } - if (name != null && Registry.ITEM.get(new Identifier(name)) != null) { - ItemStack itemStack = new ItemStack(Registry.ITEM.get(new Identifier(name)), stackSize); + if (name != null && Registries.ITEM.get(new Identifier(name)) != null) { + ItemStack itemStack = new ItemStack(Registries.ITEM.get(new Identifier(name)), stackSize); itemStack.setNbt(tagCompound); return itemStack; } @@ -84,8 +85,8 @@ public class ItemStackSerializer implements JsonSerializer, JsonDeser if (src != null && src.getItem() != null) { JsonObject jsonObject = new JsonObject(); - if (Registry.ITEM.getId(src.getItem()) != null) { - jsonObject.addProperty(NAME, Registry.ITEM.getId(src.getItem()).toString()); + if (Registries.ITEM.getId(src.getItem()) != null) { + jsonObject.addProperty(NAME, Registries.ITEM.getId(src.getItem()).toString()); } else { return JsonNull.INSTANCE; } diff --git a/RebornCore/src/main/java/reborncore/mixin/common/MixinItemEntity.java b/RebornCore/src/main/java/reborncore/mixin/common/MixinItemEntity.java index 40e96882d..356d6f525 100644 --- a/RebornCore/src/main/java/reborncore/mixin/common/MixinItemEntity.java +++ b/RebornCore/src/main/java/reborncore/mixin/common/MixinItemEntity.java @@ -50,7 +50,7 @@ public abstract class MixinItemEntity extends Entity { public void tick(CallbackInfo info) { if (!world.isClient && isTouchingWater() && !getStack().isEmpty()) { if (getStack().isIn(RebornCoreTags.WATER_EXPLOSION_ITEM)) { - world.createExplosion(this, getX(), getY(), getZ(), 2F, Explosion.DestructionType.BREAK); + world.createExplosion(this, getX(), getY(), getZ(), 2F, World.ExplosionSourceType.NONE); this.remove(RemovalReason.KILLED); } } diff --git a/RebornCore/src/main/resources/fabric.mod.json b/RebornCore/src/main/resources/fabric.mod.json index 91c2f1645..5a61574dc 100644 --- a/RebornCore/src/main/resources/fabric.mod.json +++ b/RebornCore/src/main/resources/fabric.mod.json @@ -28,11 +28,11 @@ } ], "depends": { - "fabricloader": ">=0.14.8", - "fabric-api": ">=0.66.0", + "fabricloader": ">=0.14.11", + "fabric-api": ">=0.68.1", "team_reborn_energy": ">=2.3.0", "fabric-biome-api-v1": ">=3.0.0", - "minecraft": "~1.19.2" + "minecraft": ">=1.19.3- <1.19.4-" }, "authors": [ "Team Reborn", diff --git a/RebornCore/src/main/resources/reborncore.accesswidener b/RebornCore/src/main/resources/reborncore.accesswidener index eb0df9c30..ec3424d2f 100644 --- a/RebornCore/src/main/resources/reborncore.accesswidener +++ b/RebornCore/src/main/resources/reborncore.accesswidener @@ -8,7 +8,7 @@ accessible class net/minecraft/recipe/Ingredient$Entry accessible class net/minecraft/recipe/Ingredient$TagEntry accessible class net/minecraft/recipe/Ingredient$StackEntry accessible field net/minecraft/recipe/Ingredient entries [Lnet/minecraft/recipe/Ingredient$Entry; -accessible field net/minecraft/recipe/Ingredient$TagEntry tag Lnet/minecraft/tag/TagKey; +accessible field net/minecraft/recipe/Ingredient$TagEntry tag Lnet/minecraft/registry/tag/TagKey; accessible method net/minecraft/client/gui/screen/ingame/HandledScreen getSlotAt (DD)Lnet/minecraft/screen/slot/Slot; @@ -16,10 +16,13 @@ accessible method net/minecraft/client/render/WorldRenderer drawShapeOu accessible method net/minecraft/world/gen/treedecorator/TreeDecoratorType (Lcom/mojang/serialization/Codec;)V -accessible method net/minecraft/client/item/ModelPredicateProviderRegistry register (Lnet/minecraft/item/Item;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/item/UnclampedModelPredicateProvider;)V accessible field net/minecraft/client/gui/screen/Screen selectables Ljava/util/List; accessible field net/minecraft/block/FluidBlock fluid Lnet/minecraft/fluid/FlowableFluid; accessible method net/minecraft/world/gen/foliage/FoliagePlacerType register (Ljava/lang/String;Lcom/mojang/serialization/Codec;)Lnet/minecraft/world/gen/foliage/FoliagePlacerType; accessible method net/minecraft/recipe/RecipeManager getAllOfType (Lnet/minecraft/recipe/RecipeType;)Ljava/util/Map; accessible field net/minecraft/screen/ScreenHandler listeners Ljava/util/List; accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/inventory/CraftingInventory;IIZ)Z + +accessible field net/minecraft/structure/pool/StructurePool elements Lit/unimi/dsi/fastutil/objects/ObjectArrayList; + +extendable method net/minecraft/data/server/recipe/RecipeProvider getName ()Ljava/lang/String; diff --git a/build.gradle b/build.gradle index cb9a1fbc5..6a99df5de 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,7 @@ repositories { includeGroup "dev.architectury" } } + mavenCentral() } def ENV = System.getenv() @@ -180,12 +181,12 @@ dependencies { include project(":RebornCore") - optionalClientDependency("dev.architectury:architectury-fabric:${project.arch_version}") - optionalClientDependency("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") + optionalClientDependency("dev.architectury:architectury-fabric:${project.arch_version}", false) + optionalClientDependency("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}", false) // Use groovy for datagen/gametest, if you are copying this you prob dont want it. - gametestImplementation 'org.apache.groovy:groovy:4.0.4' - datagenImplementation 'org.apache.groovy:groovy:4.0.4' + gametestImplementation 'org.apache.groovy:groovy:4.0.6' + datagenImplementation 'org.apache.groovy:groovy:4.0.6' gametestImplementation ("com.google.truth:truth:1.1.3") { exclude module: "guava" @@ -320,7 +321,7 @@ curseforge { id = "233564" changelog = ENV.CHANGELOG ?: "No changelog provided" releaseType = ENV.RELEASE_CHANNEL ?: "release" - addGameVersion "1.19.2" // Also update in RebornCore/build.gradle + addGameVersion "1.19.3" // Also update in RebornCore/build.gradle addGameVersion "Fabric" mainArtifact remapJar diff --git a/gradle.properties b/gradle.properties index 7add57a40..345a9a36f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,14 @@ org.gradle.jvmargs=-Xmx2G # Mod properties -mod_version=5.4.0 +mod_version=5.5.0 # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.19.2 -yarn_version=1.19.2+build.10 -loader_version=0.14.9 -fapi_version=0.66.0+1.19.2 +minecraft_version=1.19.3 +yarn_version=1.19.3+build.1 +loader_version=0.14.11 +fapi_version=0.68.1+1.19.3 # Dependencies energy_version=2.3.0 diff --git a/src/client/java/techreborn/TechRebornClient.java b/src/client/java/techreborn/TechRebornClient.java index 9b34c8282..53c380d92 100644 --- a/src/client/java/techreborn/TechRebornClient.java +++ b/src/client/java/techreborn/TechRebornClient.java @@ -30,10 +30,11 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.renderer.v1.RendererAccess; +import net.minecraft.client.item.ClampedModelPredicateProvider; import net.minecraft.client.item.ModelPredicateProviderRegistry; -import net.minecraft.client.item.UnclampedModelPredicateProvider; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.render.model.Baker; import net.minecraft.client.render.model.ModelBakeSettings; import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.UnbakedModel; @@ -47,8 +48,9 @@ import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import org.jetbrains.annotations.Nullable; import reborncore.client.ClientJumpEvent; import reborncore.client.gui.builder.GuiBase; @@ -60,6 +62,7 @@ import techreborn.client.ClientGuiType; import techreborn.client.ClientboundPacketHandlers; import techreborn.client.events.ClientJumpHandler; import techreborn.client.events.StackToolTipHandler; +import techreborn.client.render.BaseDynamicFluidBakedModel; import techreborn.client.render.DynamicBucketBakedModel; import techreborn.client.render.DynamicCellBakedModel; import techreborn.client.render.entitys.CableCoverRenderer; @@ -80,6 +83,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; +import java.util.function.Supplier; public class TechRebornClient implements ClientModInitializer { @@ -103,47 +107,15 @@ public class TechRebornClient implements ClientModInitializer { return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"techreborn:item/cell_background\"}}"); } - return new UnbakedModel() { - @Override - public Collection getModelDependencies() { - return Collections.emptyList(); - } - - @Override - public Collection getTextureDependencies(Function unbakedModelGetter, Set> unresolvedTextureReferences) { - return Collections.emptyList(); - } - - @Override - public BakedModel bake(ModelLoader loader, Function textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { - return new DynamicCellBakedModel(); - } - - }; + return new UnbakedDynamicModel(DynamicCellBakedModel::new); } - Fluid fluid = Registry.FLUID.get(new Identifier(TechReborn.MOD_ID, modelIdentifier.getPath().split("_bucket")[0])); + Fluid fluid = Registries.FLUID.get(new Identifier(TechReborn.MOD_ID, modelIdentifier.getPath().split("_bucket")[0])); if (modelIdentifier.getPath().endsWith("_bucket") && fluid != Fluids.EMPTY) { if (!RendererAccess.INSTANCE.hasRenderer()) { return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"minecraft:item/bucket\"}}"); } - return new UnbakedModel() { - @Override - public Collection getModelDependencies() { - return Collections.emptyList(); - } - - @Override - public Collection getTextureDependencies(Function unbakedModelGetter, Set> unresolvedTextureReferences) { - return Collections.emptyList(); - } - - @Override - public BakedModel bake(ModelLoader loader, Function textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { - return new DynamicBucketBakedModel(); - } - - }; + return new UnbakedDynamicModel(DynamicBucketBakedModel::new); } } return null; @@ -252,13 +224,13 @@ public class TechRebornClient implements ClientModInitializer { } private static void registerPredicateProvider(Class itemClass, Identifier identifier, ItemModelPredicateProvider modelPredicateProvider) { - Registry.ITEM.stream() + Registries.ITEM.stream() .filter(item -> item.getClass().isAssignableFrom(itemClass)) .forEach(item -> ModelPredicateProviderRegistry.register(item, identifier, modelPredicateProvider)); } //Need the item instance in a few places, this makes it easier - private interface ItemModelPredicateProvider extends UnclampedModelPredicateProvider { + private interface ItemModelPredicateProvider extends ClampedModelPredicateProvider { float call(T item, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity, int seed); @@ -268,4 +240,28 @@ public class TechRebornClient implements ClientModInitializer { } } + + private static class UnbakedDynamicModel implements UnbakedModel { + private final Supplier supplier; + + public UnbakedDynamicModel(Supplier supplier) { + this.supplier = supplier; + } + + @Override + public Collection getModelDependencies() { + return Collections.emptyList(); + } + + @Override + public void setParents(Function modelLoader) { + + } + + @Nullable + @Override + public BakedModel bake(Baker baker, Function textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { + return supplier.get(); + } + } } diff --git a/src/client/java/techreborn/client/compat/rei/ReiPlugin.java b/src/client/java/techreborn/client/compat/rei/ReiPlugin.java index 652ff764c..03469d392 100644 --- a/src/client/java/techreborn/client/compat/rei/ReiPlugin.java +++ b/src/client/java/techreborn/client/compat/rei/ReiPlugin.java @@ -373,7 +373,7 @@ public class ReiPlugin implements REIClientPlugin { final Sprite sprite = handler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0]; int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState()); - final int iconHeight = sprite.getHeight(); + final int iconHeight = sprite.getContents().getHeight(); int offsetHeight = drawHeight; RenderSystem.setShaderColor((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F, 1F); diff --git a/src/client/java/techreborn/client/events/StackToolTipHandler.java b/src/client/java/techreborn/client/events/StackToolTipHandler.java index 4184dd517..147dea9ce 100644 --- a/src/client/java/techreborn/client/events/StackToolTipHandler.java +++ b/src/client/java/techreborn/client/events/StackToolTipHandler.java @@ -40,10 +40,11 @@ import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.api.IListInfoProvider; import reborncore.common.BaseBlockEntityProvider; import techreborn.blocks.cable.CableBlock; @@ -135,7 +136,7 @@ public class StackToolTipHandler implements ItemTooltipCallback { } private static boolean isTRItem(Item item) { - return Registry.ITEM.getId(item).getNamespace().equals("techreborn"); + return Registries.ITEM.getId(item).getNamespace().equals("techreborn"); } private static Text getOreDepthText(OreDepth depth) { diff --git a/src/client/java/techreborn/client/gui/GuiChunkLoader.java b/src/client/java/techreborn/client/gui/GuiChunkLoader.java index 8774f1185..5829e5b2a 100644 --- a/src/client/java/techreborn/client/gui/GuiChunkLoader.java +++ b/src/client/java/techreborn/client/gui/GuiChunkLoader.java @@ -53,7 +53,10 @@ public class GuiChunkLoader extends GuiBase { addDrawableChild(new GuiButtonUpDown(x + 64 + 24, y + 40, this, b -> onClick(-1), UpDownButtonType.REWIND)); addDrawableChild(new GuiButtonUpDown(x + 64 + 36, y + 40, this, b -> onClick(-5), UpDownButtonType.FASTREWIND)); - addDrawableChild(new ButtonWidget(x + 10, y + 70, 155, 20, Text.literal("Toggle Loaded Chunks"), b -> ClientChunkManager.toggleLoadedChunks(blockEntity.getPos()))); + addDrawableChild(ButtonWidget.builder(Text.literal("Toggle Loaded Chunks"), b -> ClientChunkManager.toggleLoadedChunks(blockEntity.getPos())) + .position(x + 10, y + 70) + .size(155, 20) + .build()); } @Override diff --git a/src/client/java/techreborn/client/gui/GuiIronFurnace.java b/src/client/java/techreborn/client/gui/GuiIronFurnace.java index 4a5eccbdb..e99855e68 100644 --- a/src/client/java/techreborn/client/gui/GuiIronFurnace.java +++ b/src/client/java/techreborn/client/gui/GuiIronFurnace.java @@ -24,8 +24,6 @@ package techreborn.client.gui; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TexturedButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; @@ -37,7 +35,6 @@ import reborncore.client.gui.guibuilder.GuiBuilder; import reborncore.common.screen.BuiltScreenHandler; import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity; import techreborn.packets.ServerboundPackets; -import techreborn.utils.PlayerUtils; public class GuiIronFurnace extends GuiBase { @@ -57,34 +54,35 @@ public class GuiIronFurnace extends GuiBase { @Override public void init() { super.init(); - ButtonWidget.TooltipSupplier tooltipSupplier = (button, matrices, mouseX, mouseY) -> { - PlayerEntity player = MinecraftClient.getInstance().player; - if (player == null) { return; } - String message = "Experience: "; - - float furnaceExp = blockEntity.experience; - if (furnaceExp <= 0) { - message = message + "0"; - } else { - float expTillLevel = (1.0F - player.experienceProgress) * player.getNextLevelExperience(); - if (furnaceExp <= expTillLevel) { - int percentage = (int) (blockEntity.experience * 100 / player.getNextLevelExperience()); - message = message + "+" - + (percentage > 0 ? String.valueOf(percentage) : "<1") - + "%"; - } else { - int levels = 0; - furnaceExp -= expTillLevel; - while (furnaceExp > 0) { - furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel); - ++levels; - } - message = message + "+" + levels + "L"; - } - } - - renderTooltip(matrices, Text.literal(message), mouseX, mouseY); - }; + // TODO 1.19.3 +// ButtonWidget.TooltipSupplier tooltipSupplier = (button, matrices, mouseX, mouseY) -> { +// PlayerEntity player = MinecraftClient.getInstance().player; +// if (player == null) { return; } +// String message = "Experience: "; +// +// float furnaceExp = blockEntity.experience; +// if (furnaceExp <= 0) { +// message = message + "0"; +// } else { +// float expTillLevel = (1.0F - player.experienceProgress) * player.getNextLevelExperience(); +// if (furnaceExp <= expTillLevel) { +// int percentage = (int) (blockEntity.experience * 100 / player.getNextLevelExperience()); +// message = message + "+" +// + (percentage > 0 ? String.valueOf(percentage) : "<1") +// + "%"; +// } else { +// int levels = 0; +// furnaceExp -= expTillLevel; +// while (furnaceExp > 0) { +// furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel); +// ++levels; +// } +// message = message + "+" + levels + "L"; +// } +// } +// +// renderTooltip(matrices, Text.literal(message), mouseX, mouseY); +// }; addDrawableChild(new TexturedButtonWidget( getGuiLeft() + 116, @@ -98,7 +96,6 @@ public class GuiIronFurnace extends GuiBase { 16, 16, b -> onClick(), - tooltipSupplier, Text.empty())); } diff --git a/src/client/java/techreborn/client/render/entitys/NukeRenderer.java b/src/client/java/techreborn/client/render/entitys/NukeRenderer.java index ae5195ffa..79ada1795 100644 --- a/src/client/java/techreborn/client/render/entitys/NukeRenderer.java +++ b/src/client/java/techreborn/client/render/entitys/NukeRenderer.java @@ -33,7 +33,7 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import org.jetbrains.annotations.Nullable; import techreborn.entities.EntityNukePrimed; import techreborn.init.TRContent; @@ -69,7 +69,7 @@ public class NukeRenderer extends EntityRenderer { matrixStack.scale(j, j, j); } - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); + matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-90.0F)); matrixStack.translate(-0.5D, -0.5D, 0.5D); TntMinecartEntityRenderer.renderFlashingBlock(blockRenderManager, TRContent.NUKE.getDefaultState(), matrixStack, vertexConsumerProvider, i, entity.getFuse() / 5 % 2 == 0); matrixStack.pop(); diff --git a/src/client/java/techreborn/client/render/entitys/StorageUnitRenderer.java b/src/client/java/techreborn/client/render/entitys/StorageUnitRenderer.java index 015caab54..95ce55aab 100644 --- a/src/client/java/techreborn/client/render/entitys/StorageUnitRenderer.java +++ b/src/client/java/techreborn/client/render/entitys/StorageUnitRenderer.java @@ -35,7 +35,7 @@ import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity; /** @@ -59,7 +59,7 @@ public class StorageUnitRenderer implements BlockEntityRenderer matrices.translate(1, 1, 0); @@ -78,7 +78,7 @@ public class StorageUnitRenderer implements BlockEntityRenderer matrixStack.push(); matrixStack.translate(0.5, 0, 0.5); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-facing.rotateYCounterclockwise().asRotation() + 90)); + matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-facing.rotateYCounterclockwise().asRotation() + 90)); matrixStack.translate(0, -1, -0.56); float spin = blockEntity.bladeAngle + tickDelta * blockEntity.spinSpeed; diff --git a/src/client/java/techreborn/client/screen/DestructoPackScreenHandler.java b/src/client/java/techreborn/client/screen/DestructoPackScreenHandler.java index 36787058d..6d3f8d2cd 100644 --- a/src/client/java/techreborn/client/screen/DestructoPackScreenHandler.java +++ b/src/client/java/techreborn/client/screen/DestructoPackScreenHandler.java @@ -45,7 +45,7 @@ public class DestructoPackScreenHandler extends ScreenHandler { } @Override - public ItemStack transferSlot(PlayerEntity player, int index) { + public ItemStack quickMove(PlayerEntity player, int index) { return ItemStack.EMPTY; } diff --git a/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy b/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy index 2ae410f4b..80ac18667 100644 --- a/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy +++ b/src/datagen/groovy/techreborn/datagen/TechRebornDataGen.groovy @@ -26,6 +26,8 @@ package techreborn.datagen import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.minecraft.registry.RegistryBuilder +import net.minecraft.registry.RegistryKeys import techreborn.TechReborn import techreborn.datagen.models.BlockLootTableProvider import techreborn.datagen.models.ModelProvider @@ -42,35 +44,50 @@ import techreborn.datagen.recipes.smelting.SmeltingRecipesProvider import techreborn.datagen.tags.TRBlockTagProvider import techreborn.datagen.tags.TRItemTagProvider import techreborn.datagen.tags.TRPointOfInterestTagProvider -import techreborn.datagen.tags.WaterExplosionTagProvider +import techreborn.datagen.worldgen.TRWorldGenBootstrap +import techreborn.datagen.worldgen.TRWorldGenProvider class TechRebornDataGen implements DataGeneratorEntrypoint { @Override void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { - fabricDataGenerator.addProvider(WaterExplosionTagProvider.&new) - fabricDataGenerator.addProvider(TRItemTagProvider.&new) - fabricDataGenerator.addProvider(TRPointOfInterestTagProvider.&new) - fabricDataGenerator.addProvider(TRBlockTagProvider.&new) + def pack = fabricDataGenerator.createPack() + + def add = { FabricDataGenerator.Pack.RegistryDependentFactory factory -> + pack.addProvider factory + } + + add TRItemTagProvider::new + add TRPointOfInterestTagProvider::new + + add TRBlockTagProvider::new // tags before all else, very important!! - fabricDataGenerator.addProvider(SmeltingRecipesProvider.&new) - fabricDataGenerator.addProvider(CraftingRecipesProvider.&new) + add SmeltingRecipesProvider::new + add CraftingRecipesProvider::new - fabricDataGenerator.addProvider(GrinderRecipesProvider.&new) - fabricDataGenerator.addProvider(CompressorRecipesProvider.&new) - fabricDataGenerator.addProvider(ExtractorRecipesProvider.&new) - fabricDataGenerator.addProvider(ChemicalReactorRecipesProvider.&new) - fabricDataGenerator.addProvider(AssemblingMachineRecipesProvider.&new) - fabricDataGenerator.addProvider(BlastFurnaceRecipesProvider.&new) - fabricDataGenerator.addProvider(IndustrialGrinderRecipesProvider.&new) - fabricDataGenerator.addProvider(IndustrialSawmillRecipesProvider.&new) + add GrinderRecipesProvider::new + add CompressorRecipesProvider::new + add ExtractorRecipesProvider::new + add ChemicalReactorRecipesProvider::new + add AssemblingMachineRecipesProvider::new + add BlastFurnaceRecipesProvider::new + add IndustrialGrinderRecipesProvider::new + add IndustrialSawmillRecipesProvider::new - fabricDataGenerator.addProvider(ModelProvider.&new) - fabricDataGenerator.addProvider(BlockLootTableProvider.&new) + add ModelProvider::new + add BlockLootTableProvider::new + + add TRWorldGenProvider::new } @Override String getEffectiveModId() { return TechReborn.MOD_ID } + + @Override + void buildRegistry(RegistryBuilder registryBuilder) { + registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, TRWorldGenBootstrap::configuredFeatures) + registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, TRWorldGenBootstrap::placedFeatures) + } } diff --git a/src/datagen/groovy/techreborn/datagen/models/BlockLootTableProvider.groovy b/src/datagen/groovy/techreborn/datagen/models/BlockLootTableProvider.groovy index 4aa00e568..fca6ccc03 100644 --- a/src/datagen/groovy/techreborn/datagen/models/BlockLootTableProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/models/BlockLootTableProvider.groovy @@ -1,26 +1,20 @@ package techreborn.datagen.models -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider -import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider -import net.minecraft.data.DataWriter -import net.minecraft.data.server.BlockLootTableGenerator -import net.minecraft.loot.LootTable -import net.minecraft.util.Identifier -import org.jetbrains.annotations.NotNull +import net.minecraft.registry.RegistryWrapper import techreborn.init.TRContent -import java.util.function.BiConsumer -import java.util.function.Consumer +import java.util.concurrent.CompletableFuture class BlockLootTableProvider extends FabricBlockLootTableProvider{ - BlockLootTableProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + BlockLootTableProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output) } @Override - protected void generateBlockLootTables() { + public void generate() { TRContent.StorageBlocks.values().each { addDrop(it.getBlock()) addDrop(it.getSlabBlock()) diff --git a/src/datagen/groovy/techreborn/datagen/models/ModelProvider.groovy b/src/datagen/groovy/techreborn/datagen/models/ModelProvider.groovy index 3940269f9..1b8ce4230 100644 --- a/src/datagen/groovy/techreborn/datagen/models/ModelProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/models/ModelProvider.groovy @@ -24,19 +24,20 @@ package techreborn.datagen.models -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider -import net.minecraft.block.Blocks import net.minecraft.data.client.BlockStateModelGenerator import net.minecraft.data.client.ItemModelGenerator import net.minecraft.data.client.Models import net.minecraft.data.family.BlockFamilies -import net.minecraft.data.family.BlockFamily +import net.minecraft.registry.RegistryWrapper import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class ModelProvider extends FabricModelProvider { - ModelProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + ModelProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/TechRebornRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/TechRebornRecipesProvider.groovy index 7c398e27c..85b648b7e 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/TechRebornRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/TechRebornRecipesProvider.groovy @@ -24,13 +24,14 @@ package techreborn.datagen.recipes -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider import net.minecraft.advancement.criterion.CriterionConditions import net.minecraft.data.server.recipe.RecipeJsonProvider import net.minecraft.item.ItemConvertible import net.minecraft.recipe.Ingredient -import net.minecraft.tag.TagKey +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.TagKey import net.minecraft.util.Identifier import techreborn.datagen.recipes.machine.MachineRecipeJsonFactory import techreborn.datagen.recipes.machine.blast_furnace.BlastFurnaceRecipeJsonFactory @@ -38,23 +39,24 @@ import techreborn.datagen.recipes.machine.industrial_grinder.IndustrialGrinderRe import techreborn.datagen.recipes.machine.industrial_sawmill.IndustrialSawmillRecipeJsonFactory import techreborn.init.ModRecipes +import java.util.concurrent.CompletableFuture import java.util.function.Consumer abstract class TechRebornRecipesProvider extends FabricRecipeProvider { protected Consumer exporter - TechRebornRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + TechRebornRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output) } @Override - protected void generateRecipes(Consumer exporter) { + final void generate(Consumer exporter) { this.exporter = exporter generateRecipes() } abstract void generateRecipes() - static Ingredient createIngredient(def input) { + static Ingredient createIngredient(def input) { if (input instanceof Ingredient) { return input } @@ -161,4 +163,9 @@ abstract class TechRebornRecipesProvider extends FabricRecipeProvider { protected Identifier getRecipeIdentifier(Identifier identifier) { return new Identifier("techreborn", super.getRecipeIdentifier(identifier).path) } + + @Override + public String getName() { + return "Recipes / " + getClass().name + } } diff --git a/src/datagen/groovy/techreborn/datagen/recipes/crafting/CraftingRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/crafting/CraftingRecipesProvider.groovy index 203557c9b..fe774e911 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/crafting/CraftingRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/crafting/CraftingRecipesProvider.groovy @@ -25,21 +25,26 @@ package techreborn.datagen.recipes.crafting import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder import net.minecraft.data.server.recipe.SingleItemRecipeJsonBuilder import net.minecraft.item.ItemConvertible import net.minecraft.item.Items +import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.book.RecipeCategory +import net.minecraft.registry.RegistryWrapper import net.minecraft.util.Identifier import techreborn.TechReborn import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture import java.util.function.Function class CraftingRecipesProvider extends TechRebornRecipesProvider { - CraftingRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + CraftingRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override @@ -191,8 +196,8 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider { return s.toString() } - def offerMonoShapelessRecipe(def input, int inputSize, ItemConvertible output, int outputSize, String source, prefix = "", String result = null) { - ShapelessRecipeJsonBuilder.create(output, outputSize).input(createIngredient(input), inputSize) + def offerMonoShapelessRecipe(def input, int inputSize, ItemConvertible output, int outputSize, String source, prefix = "", String result = null, RecipeCategory category = RecipeCategory.MISC) { + new ShapelessRecipeJsonBuilder(category, output, outputSize).input(createIngredient(input), inputSize) .criterion(getCriterionName(input), getCriterionConditions(input)) .offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(prefix, input, output, source, result))) } @@ -206,14 +211,14 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider { return s.toString() } - def static createMonoShapeRecipe(def input, ItemConvertible output, char character, int outputAmount = 1) { - return ShapedRecipeJsonBuilder.create(output, outputAmount) + def static createMonoShapeRecipe(def input, ItemConvertible output, char character, int outputAmount = 1, RecipeCategory category = RecipeCategory.MISC) { + return new ShapedRecipeJsonBuilder(category, output, outputAmount) .input(character, createIngredient(input)) .criterion(getCriterionName(input), getCriterionConditions(input)) } - def static createDuoShapeRecipe(def input1, def input2, ItemConvertible output, char char1, char char2, boolean crit1 = true, boolean crit2 = false) { - ShapedRecipeJsonBuilder factory = ShapedRecipeJsonBuilder.create(output) + def static createDuoShapeRecipe(def input1, def input2, ItemConvertible output, char char1, char char2, boolean crit1 = true, boolean crit2 = false, RecipeCategory category = RecipeCategory.MISC) { + ShapedRecipeJsonBuilder factory = ShapedRecipeJsonBuilder.create(category, output) .input(char1, createIngredient(input1)) .input(char2, createIngredient(input2)) if (crit1) @@ -223,8 +228,8 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider { return factory } - def static createStonecutterRecipe(def input, ItemConvertible output, int outputAmount = 1) { - return SingleItemRecipeJsonBuilder.createStonecutting(createIngredient(input), output, outputAmount) + def static createStonecutterRecipe(def input, ItemConvertible output, int outputAmount = 1, RecipeCategory category = RecipeCategory.MISC) { + return new SingleItemRecipeJsonBuilder(category, RecipeSerializer.STONECUTTING, createIngredient(input), output, outputAmount) .criterion(getCriterionName(input), getCriterionConditions(input)) } diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/IngredientBuilder.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/IngredientBuilder.groovy index 779b1b169..5aff85491 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/IngredientBuilder.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/IngredientBuilder.groovy @@ -27,7 +27,7 @@ package techreborn.datagen.recipes.machine import net.minecraft.item.Item import net.minecraft.item.ItemConvertible import net.minecraft.item.ItemStack -import net.minecraft.tag.TagKey +import net.minecraft.registry.tag.TagKey import net.minecraft.util.Identifier import reborncore.common.crafting.ingredient.RebornIngredient import reborncore.common.crafting.ingredient.StackIngredient diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/MachineRecipeJsonFactory.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/MachineRecipeJsonFactory.groovy index 9a6a7ad75..aac23a0de 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/MachineRecipeJsonFactory.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/MachineRecipeJsonFactory.groovy @@ -26,6 +26,7 @@ package techreborn.datagen.recipes.machine import com.google.gson.JsonObject import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider +import net.fabricmc.fabric.api.resource.conditions.v1.DefaultResourceConditions import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper import net.minecraft.advancement.Advancement.Builder import net.minecraft.advancement.criterion.CriterionConditions @@ -33,15 +34,16 @@ import net.minecraft.data.server.recipe.RecipeJsonProvider import net.minecraft.item.ItemConvertible import net.minecraft.item.ItemStack import net.minecraft.recipe.RecipeSerializer -import net.minecraft.tag.TagKey +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry +import net.minecraft.registry.tag.TagKey +import net.minecraft.resource.featuretoggle.FeatureFlag import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry import org.jetbrains.annotations.NotNull import reborncore.common.crafting.RebornRecipe import reborncore.common.crafting.RebornRecipeType import reborncore.common.crafting.RecipeUtils import reborncore.common.crafting.ingredient.RebornIngredient -import techreborn.datagen.recipes.TechRebornRecipesProvider import java.util.function.Consumer @@ -209,10 +211,14 @@ class MachineRecipeJsonFactory { throw new IllegalStateException("Recipe has no outputs") } - def outputId = Registry.ITEM.getId(outputs[0].item) + def outputId = Registries.ITEM.getId(outputs[0].item) return new Identifier("techreborn", "${type.name().path}/${outputId.path}${getSourceAppendix()}") } + def feature(FeatureFlag flag) { + condition(DefaultResourceConditions.featuresEnabled(flag)) + } + static class MachineRecipeJsonProvider implements RecipeJsonProvider { private final RebornRecipeType type private final R recipe diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/assembling_machine/AssemblingMachineRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/assembling_machine/AssemblingMachineRecipesProvider.groovy index 9a51d4195..4ff9a2736 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/assembling_machine/AssemblingMachineRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/assembling_machine/AssemblingMachineRecipesProvider.groovy @@ -24,16 +24,19 @@ package techreborn.datagen.recipes.machine.assembling_machine -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack import net.minecraft.item.Items -import net.minecraft.tag.ItemTags +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.ItemTags import techreborn.datagen.recipes.TechRebornRecipesProvider +import java.util.concurrent.CompletableFuture + class AssemblingMachineRecipesProvider extends TechRebornRecipesProvider { - AssemblingMachineRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + AssemblingMachineRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/blast_furnace/BlastFurnaceRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/blast_furnace/BlastFurnaceRecipesProvider.groovy index 5c00dc3b7..6b847ce42 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/blast_furnace/BlastFurnaceRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/blast_furnace/BlastFurnaceRecipesProvider.groovy @@ -24,12 +24,15 @@ package techreborn.datagen.recipes.machine.blast_furnace -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack import net.minecraft.item.Items +import net.minecraft.registry.RegistryWrapper import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class BlastFurnaceRecipesProvider extends TechRebornRecipesProvider { public final int ARMOR_POWER = 128 @@ -39,8 +42,8 @@ class BlastFurnaceRecipesProvider extends TechRebornRecipesProvider { public final int TOOL_TIME = ARMOR_TIME public final int TOOL_HEAT = ARMOR_HEAT - BlastFurnaceRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + BlastFurnaceRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/chemical_reactor/ChemicalReactorRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/chemical_reactor/ChemicalReactorRecipesProvider.groovy index f037e282b..1c848a1d2 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/chemical_reactor/ChemicalReactorRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/chemical_reactor/ChemicalReactorRecipesProvider.groovy @@ -24,18 +24,21 @@ package techreborn.datagen.recipes.machine.chemical_reactor -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack +import net.minecraft.registry.RegistryWrapper import reborncore.common.util.ColoredItem import techreborn.datagen.recipes.TechRebornRecipesProvider +import java.util.concurrent.CompletableFuture + class ChemicalReactorRecipesProvider extends TechRebornRecipesProvider { public final int DYE_POWER = 25 public final int DYE_TIME = 250 - ChemicalReactorRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + ChemicalReactorRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/compressor/CompressorRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/compressor/CompressorRecipesProvider.groovy index 94725e589..b99aa0ed4 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/compressor/CompressorRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/compressor/CompressorRecipesProvider.groovy @@ -24,15 +24,18 @@ package techreborn.datagen.recipes.machine.compressor -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack +import net.minecraft.registry.RegistryWrapper import reborncore.common.misc.TagConvertible import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class CompressorRecipesProvider extends TechRebornRecipesProvider { - CompressorRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + CompressorRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/extractor/ExtractorRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/extractor/ExtractorRecipesProvider.groovy index 489e5297d..81ff4959f 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/extractor/ExtractorRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/extractor/ExtractorRecipesProvider.groovy @@ -24,15 +24,18 @@ package techreborn.datagen.recipes.machine.extractor -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack import net.minecraft.item.Items +import net.minecraft.registry.RegistryWrapper import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class ExtractorRecipesProvider extends TechRebornRecipesProvider { - ExtractorRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + ExtractorRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/grinder/GrinderRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/grinder/GrinderRecipesProvider.groovy index c25f84987..0253b4a72 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/grinder/GrinderRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/grinder/GrinderRecipesProvider.groovy @@ -24,19 +24,23 @@ package techreborn.datagen.recipes.machine.grinder -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack import net.minecraft.item.Items -import net.minecraft.tag.ItemTags -import net.minecraft.tag.TagKey +import net.minecraft.registry.Registry +import net.minecraft.registry.RegistryKeys +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.ItemTags +import net.minecraft.registry.tag.TagKey import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class GrinderRecipesProvider extends TechRebornRecipesProvider { - GrinderRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + GrinderRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override @@ -57,9 +61,9 @@ class GrinderRecipesProvider extends TechRebornRecipesProvider { void generateVanillaRawMetals() { [ - (Items.RAW_IRON) : (TagKey.of(Registry.ITEM_KEY, new Identifier("c", "iron_ores"))), - (Items.RAW_COPPER): (TagKey.of(Registry.ITEM_KEY, new Identifier("c", "copper_ores"))), - (Items.RAW_GOLD) : (TagKey.of(Registry.ITEM_KEY, new Identifier("c", "gold_ores"))) + (Items.RAW_IRON) : (TagKey.of(RegistryKeys.ITEM, new Identifier("c", "iron_ores"))), + (Items.RAW_COPPER): (TagKey.of(RegistryKeys.ITEM, new Identifier("c", "copper_ores"))), + (Items.RAW_GOLD) : (TagKey.of(RegistryKeys.ITEM, new Identifier("c", "gold_ores"))) ].each { raw, oreTag -> offerGrinderRecipe { ingredients oreTag @@ -249,5 +253,4 @@ class GrinderRecipesProvider extends TechRebornRecipesProvider { } } } - } \ No newline at end of file diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_grinder/IndustrialGrinderRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_grinder/IndustrialGrinderRecipesProvider.groovy index 96b603d29..e4ee2e247 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_grinder/IndustrialGrinderRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_grinder/IndustrialGrinderRecipesProvider.groovy @@ -24,13 +24,16 @@ package techreborn.datagen.recipes.machine.industrial_grinder -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack import net.minecraft.item.Items +import net.minecraft.registry.RegistryWrapper import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.ModFluids import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class IndustrialGrinderRecipesProvider extends TechRebornRecipesProvider { public final int ARMOR_POWER = 128 @@ -41,8 +44,8 @@ class IndustrialGrinderRecipesProvider extends TechRebornRecipesProvider { public final long TOOL_FLUID_AMOUNT = 500L // in millibuckets var dustMap = TRContent.SmallDusts.SD2DMap - IndustrialGrinderRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + IndustrialGrinderRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override diff --git a/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy index 8a565dbef..d449c31ff 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/machine/industrial_sawmill/IndustrialSawmillRecipesProvider.groovy @@ -24,17 +24,21 @@ package techreborn.datagen.recipes.machine.industrial_sawmill -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.item.ItemStack import net.minecraft.item.Items -import net.minecraft.tag.ItemTags +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.ItemTags +import net.minecraft.resource.featuretoggle.FeatureFlags import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class IndustrialSawmillRecipesProvider extends TechRebornRecipesProvider { - IndustrialSawmillRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + IndustrialSawmillRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override @@ -59,6 +63,14 @@ class IndustrialSawmillRecipesProvider extends TechRebornRecipesProvider { fluidAmount 1000 // in millibuckets } } + offerIndustrialSawmillRecipe { + ingredients ItemTags.BAMBOO_BLOCKS + outputs new ItemStack(Items.BAMBOO_PLANKS,2), new ItemStack(TRContent.Dusts.SAW, 1) + power 40 + time 100 + fluidAmount 500 // in millibuckets + feature FeatureFlags.UPDATE_1_20 + } [ (Items.ACACIA_STAIRS): Items.ACACIA_SLAB, (Items.BIRCH_STAIRS): Items.BIRCH_SLAB, @@ -81,6 +93,21 @@ class IndustrialSawmillRecipesProvider extends TechRebornRecipesProvider { criterion getCriterionName(stairs), getCriterionConditions(stairs) } } + [ + (Items.BAMBOO_STAIRS): Items.BAMBOO_SLAB, + (Items.BAMBOO_MOSAIC_STAIRS): Items.BAMBOO_MOSAIC_SLAB + ].each { stairs, slab -> + offerIndustrialSawmillRecipe { + ingredients stairs + outputs slab, new ItemStack(TRContent.Dusts.SAW, 2) + power 30 + time 100 + fluidAmount 250 // in millibuckets + source "stairs" + criterion getCriterionName(stairs), getCriterionConditions(stairs) + feature FeatureFlags.UPDATE_1_20 + } + } [ (Items.ACACIA_SLAB): Items.ACACIA_PRESSURE_PLATE, (Items.BIRCH_SLAB): Items.BIRCH_PRESSURE_PLATE, @@ -103,6 +130,21 @@ class IndustrialSawmillRecipesProvider extends TechRebornRecipesProvider { criterion getCriterionName(slab), getCriterionConditions(slab) } } + [ + (Items.BAMBOO_SLAB): Items.BAMBOO_PRESSURE_PLATE, + (Items.BAMBOO_MOSAIC_SLAB): Items.BAMBOO_PRESSURE_PLATE + ].each { slab, plate -> + offerIndustrialSawmillRecipe { + ingredients slab + outputs new ItemStack(plate, 2), new ItemStack(TRContent.Dusts.SAW, 2) + power 30 + time 200 + fluidAmount 250 // in millibuckets + source ((slab == Items.BAMBOO_MOSAIC_SLAB ? "mosaic_" : "") + "slab") + criterion getCriterionName(slab), getCriterionConditions(slab) + feature FeatureFlags.UPDATE_1_20 + } + } [ (ItemTags.PLANKS): 8, // stairs would be 6, slabs 4 diff --git a/src/datagen/groovy/techreborn/datagen/recipes/smelting/SmeltingRecipesProvider.groovy b/src/datagen/groovy/techreborn/datagen/recipes/smelting/SmeltingRecipesProvider.groovy index 4c121660b..803a740e6 100644 --- a/src/datagen/groovy/techreborn/datagen/recipes/smelting/SmeltingRecipesProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/recipes/smelting/SmeltingRecipesProvider.groovy @@ -24,18 +24,22 @@ package techreborn.datagen.recipes.smelting -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.minecraft.data.server.recipe.CookingRecipeJsonBuilder import net.minecraft.item.ItemConvertible import net.minecraft.item.Items import net.minecraft.recipe.CookingRecipeSerializer import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.book.RecipeCategory +import net.minecraft.registry.RegistryWrapper import techreborn.datagen.recipes.TechRebornRecipesProvider import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class SmeltingRecipesProvider extends TechRebornRecipesProvider { - SmeltingRecipesProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + SmeltingRecipesProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override @@ -73,8 +77,8 @@ class SmeltingRecipesProvider extends TechRebornRecipesProvider { offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.BLASTING, "blasting/") } - def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer serializer, String prefix = "") { - CookingRecipeJsonBuilder.create(createIngredient(input), output, experience, cookingTime, serializer) + def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer serializer, String prefix = "", RecipeCategory category = RecipeCategory.MISC) { + CookingRecipeJsonBuilder.create(createIngredient(input), category, output, experience, cookingTime, serializer) .criterion(getCriterionName(input), getCriterionConditions(input)) .offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input)) } diff --git a/src/datagen/groovy/techreborn/datagen/tags/TRBlockTagProvider.groovy b/src/datagen/groovy/techreborn/datagen/tags/TRBlockTagProvider.groovy index e27fb4096..eb07e3dd3 100644 --- a/src/datagen/groovy/techreborn/datagen/tags/TRBlockTagProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/tags/TRBlockTagProvider.groovy @@ -24,22 +24,25 @@ package techreborn.datagen.tags -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBlockTags -import net.minecraft.tag.BlockTags +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.BlockTags import net.minecraft.util.Identifier import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class TRBlockTagProvider extends FabricTagProvider.BlockTagProvider { - TRBlockTagProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + TRBlockTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) } @Override - protected void generateTags() { + protected void configure(RegistryWrapper.WrapperLookup lookup) { getOrCreateTagBuilder(TRContent.BlockTags.DRILL_MINEABLE) .addOptionalTag(BlockTags.PICKAXE_MINEABLE.id()) .addOptionalTag(BlockTags.SHOVEL_MINEABLE.id()) diff --git a/src/datagen/groovy/techreborn/datagen/tags/TRItemTagProvider.groovy b/src/datagen/groovy/techreborn/datagen/tags/TRItemTagProvider.groovy index a93d672f0..c36af3b58 100644 --- a/src/datagen/groovy/techreborn/datagen/tags/TRItemTagProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/tags/TRItemTagProvider.groovy @@ -24,19 +24,23 @@ package techreborn.datagen.tags -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.ItemTagProvider -import net.minecraft.tag.BlockTags -import net.minecraft.tag.ItemTags +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.ItemTags +import reborncore.common.misc.RebornCoreTags +import techreborn.init.ModFluids import techreborn.init.TRContent +import java.util.concurrent.CompletableFuture + class TRItemTagProvider extends ItemTagProvider { - TRItemTagProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) + TRItemTagProvider(FabricDataOutput dataOutput, CompletableFuture registriesFuture) { + super(dataOutput, registriesFuture) } @Override - protected void generateTags() { + protected void configure(RegistryWrapper.WrapperLookup arg) { TRContent.Ores.values().each { ore -> getOrCreateTagBuilder(ore.asTag()).add(ore.asItem()) getOrCreateTagBuilder(TRContent.ItemTags.ORES).add(ore.asItem()) @@ -176,5 +180,8 @@ class TRItemTagProvider extends ItemTagProvider { getOrCreateTagBuilder(ItemTags.WOODEN_TRAPDOORS) .add(TRContent.RUBBER_TRAPDOOR.asItem()) + + getOrCreateTagBuilder(RebornCoreTags.WATER_EXPLOSION_ITEM) + .add(ModFluids.SODIUM.getBucket()) } } diff --git a/src/datagen/groovy/techreborn/datagen/tags/TRPointOfInterestTagProvider.groovy b/src/datagen/groovy/techreborn/datagen/tags/TRPointOfInterestTagProvider.groovy index 0ddf21c2f..deade27f9 100644 --- a/src/datagen/groovy/techreborn/datagen/tags/TRPointOfInterestTagProvider.groovy +++ b/src/datagen/groovy/techreborn/datagen/tags/TRPointOfInterestTagProvider.groovy @@ -24,20 +24,23 @@ package techreborn.datagen.tags -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider -import net.minecraft.tag.PointOfInterestTypeTags -import net.minecraft.util.registry.Registry +import net.minecraft.registry.RegistryKeys +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.tag.PointOfInterestTypeTags import net.minecraft.world.poi.PointOfInterestType import techreborn.init.TRVillager +import java.util.concurrent.CompletableFuture + class TRPointOfInterestTagProvider extends FabricTagProvider { - TRPointOfInterestTagProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator, Registry.POINT_OF_INTEREST_TYPE) + TRPointOfInterestTagProvider(FabricDataOutput dataOutput, CompletableFuture registriesFuture) { + super(dataOutput, RegistryKeys.POINT_OF_INTEREST_TYPE, registriesFuture) } @Override - protected void generateTags() { + protected void configure(RegistryWrapper.WrapperLookup arg) { getOrCreateTagBuilder(PointOfInterestTypeTags.ACQUIRABLE_JOB_SITE) .add(TRVillager.METALLURGIST_POI) .add(TRVillager.ELECTRICIAN_POI) diff --git a/src/datagen/groovy/techreborn/datagen/worldgen/TRWorldGenBootstrap.groovy b/src/datagen/groovy/techreborn/datagen/worldgen/TRWorldGenBootstrap.groovy new file mode 100644 index 000000000..3f5962f3d --- /dev/null +++ b/src/datagen/groovy/techreborn/datagen/worldgen/TRWorldGenBootstrap.groovy @@ -0,0 +1,185 @@ +package techreborn.datagen.worldgen + +import net.minecraft.block.BlockState +import net.minecraft.block.Blocks +import net.minecraft.registry.Registerable +import net.minecraft.registry.RegistryEntryLookup +import net.minecraft.registry.RegistryKeys +import net.minecraft.registry.tag.BlockTags +import net.minecraft.structure.rule.BlockMatchRuleTest +import net.minecraft.structure.rule.BlockStateMatchRuleTest +import net.minecraft.structure.rule.RuleTest +import net.minecraft.structure.rule.TagMatchRuleTest +import net.minecraft.util.collection.DataPool +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Direction +import net.minecraft.util.math.intprovider.ConstantIntProvider +import net.minecraft.world.Heightmap +import net.minecraft.world.gen.YOffset +import net.minecraft.world.gen.blockpredicate.BlockPredicate +import net.minecraft.world.gen.feature.* +import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize +import net.minecraft.world.gen.foliage.BlobFoliagePlacer +import net.minecraft.world.gen.heightprovider.UniformHeightProvider +import net.minecraft.world.gen.placementmodifier.* +import net.minecraft.world.gen.stateprovider.BlockStateProvider +import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider +import net.minecraft.world.gen.trunk.StraightTrunkPlacer +import techreborn.blocks.misc.BlockRubberLog +import techreborn.init.ModFluids +import techreborn.init.TRContent +import techreborn.world.RubberTreeSpikeDecorator +import techreborn.world.TROreFeatureConfig +import techreborn.world.TargetDimension +import techreborn.world.WorldGenerator + +class TRWorldGenBootstrap { + static void configuredFeatures(Registerable registry) { + def placedFeatureLookup = registry.getRegistryLookup(RegistryKeys.PLACED_FEATURE) + + WorldGenerator.ORE_FEATURES.forEach { + registry.register(it.configuredFeature(), createOreConfiguredFeature(it)) + } + + registry.register(WorldGenerator.OIL_LAKE_FEATURE, createOilLakeConfiguredFeature()) + registry.register(WorldGenerator.RUBBER_TREE_FEATURE, createRubberTreeConfiguredFeature()) + registry.register(WorldGenerator.RUBBER_TREE_PATCH_FEATURE, createRubberPatchTreeConfiguredFeature(placedFeatureLookup)) + } + + static void placedFeatures(Registerable registry) { + def configuredFeatureLookup = registry.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE) + + WorldGenerator.ORE_FEATURES.forEach { + registry.register(it.placedFeature(), createOrePlacedFeature(configuredFeatureLookup, it)) + } + + registry.register(WorldGenerator.OIL_LAKE_PLACED_FEATURE, createOilLakePlacedFeature(configuredFeatureLookup)) + registry.register(WorldGenerator.RUBBER_TREE_PLACED_FEATURE, createRubberTreePlacedFeature(configuredFeatureLookup)) + registry.register(WorldGenerator.RUBBER_TREE_PATCH_PLACED_FEATURE, createRubberTreePatchPlacedFeature(configuredFeatureLookup)) + } + + // Ores + private static ConfiguredFeature createOreConfiguredFeature(TROreFeatureConfig config) { + def oreFeatureConfig = switch (config.ore().distribution.dimension) { + case TargetDimension.OVERWORLD -> createOverworldOreFeatureConfig(config) + case TargetDimension.NETHER -> createSimpleOreFeatureConfig(new BlockMatchRuleTest(Blocks.NETHERRACK), config) + case TargetDimension.END -> createSimpleOreFeatureConfig(new BlockStateMatchRuleTest(Blocks.END_STONE.getDefaultState()), config) + } + + return new ConfiguredFeature<>(Feature.ORE, oreFeatureConfig) + } + + private static OreFeatureConfig createOverworldOreFeatureConfig(TROreFeatureConfig config) { + if (config.ore().getDeepslate() != null) { + return new OreFeatureConfig(List.of( + OreFeatureConfig.createTarget(new TagMatchRuleTest(BlockTags.STONE_ORE_REPLACEABLES), config.ore().block.getDefaultState()), + OreFeatureConfig.createTarget(new TagMatchRuleTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES), config.ore().getDeepslate().block.getDefaultState()) + ), config.ore().distribution.veinSize) + } + + return createSimpleOreFeatureConfig(new TagMatchRuleTest(BlockTags.STONE_ORE_REPLACEABLES), config) + } + + private static OreFeatureConfig createSimpleOreFeatureConfig(RuleTest test, TROreFeatureConfig config) { + return new OreFeatureConfig(test, config.ore().block.getDefaultState(), config.ore().distribution.veinSize) + } + + private static PlacedFeature createOrePlacedFeature(RegistryEntryLookup configuredFeatureLookup, TROreFeatureConfig config) { + return new PlacedFeature(configuredFeatureLookup.getOrThrow(config.configuredFeature()), getOrePlacementModifiers(config)) + } + + private static List getOrePlacementModifiers(TROreFeatureConfig config) { + return oreModifiers( + CountPlacementModifier.of(config.ore().distribution.veinsPerChunk), + HeightRangePlacementModifier.uniform( + config.ore().distribution.minOffset, + YOffset.fixed(config.ore().distribution.maxY) + ) + ) + } + + private static List oreModifiers(PlacementModifier first, PlacementModifier second) { + return List.of(first, SquarePlacementModifier.of(), second, BiomePlacementModifier.of()) + } + + // Oil lake + private static ConfiguredFeature createOilLakeConfiguredFeature() { + return new ConfiguredFeature<>(Feature.LAKE, + new LakeFeature.Config( + BlockStateProvider.of(ModFluids.OIL.getBlock().getDefaultState()), + BlockStateProvider.of(Blocks.STONE.getDefaultState()) + ) + ) + } + + private static PlacedFeature createOilLakePlacedFeature(RegistryEntryLookup lookup) { + return new PlacedFeature( + lookup.getOrThrow(WorldGenerator.OIL_LAKE_FEATURE), List.of( + RarityFilterPlacementModifier.of(20), + HeightRangePlacementModifier.of(UniformHeightProvider.create(YOffset.fixed(0), YOffset.getTop())), + EnvironmentScanPlacementModifier.of(Direction.DOWN, BlockPredicate.bothOf(BlockPredicate.not(BlockPredicate.IS_AIR), BlockPredicate.insideWorldBounds(new BlockPos(0, -5, 0))), 32), + SurfaceThresholdFilterPlacementModifier.of(Heightmap.Type.OCEAN_FLOOR_WG, Integer.MIN_VALUE, -5) + ) + ) + } + + // Rubber tree + private static ConfiguredFeature createRubberTreeConfiguredFeature() { + final DataPool.Builder logDataPool = DataPool.builder() + .add(TRContent.RUBBER_LOG.getDefaultState(), 6) + + Arrays.stream(Direction.values()) + .filter(direction -> direction.getAxis().isHorizontal()) + .map(direction -> TRContent.RUBBER_LOG.getDefaultState() + .with(BlockRubberLog.HAS_SAP, true) + .with(BlockRubberLog.SAP_SIDE, direction) + ) + .forEach(state -> logDataPool.add(state, 1)) + + return new ConfiguredFeature<>(Feature.TREE, + new TreeFeatureConfig.Builder( + new WeightedBlockStateProvider(logDataPool), + new StraightTrunkPlacer(6, 3, 0), + BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState()), + new BlobFoliagePlacer( + ConstantIntProvider.create(2), + ConstantIntProvider.create(0), + 3 + ), + new TwoLayersFeatureSize( + 1, + 0, + 1 + )) + .decorators(List.of( + new RubberTreeSpikeDecorator(4, BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState())) + )).build() + ) + } + + private static PlacedFeature createRubberTreePlacedFeature(RegistryEntryLookup lookup) { + return new PlacedFeature(lookup.getOrThrow(WorldGenerator.RUBBER_TREE_FEATURE), List.of( + PlacedFeatures.wouldSurvive(TRContent.RUBBER_SAPLING) + )) + } + + private static ConfiguredFeature createRubberPatchTreeConfiguredFeature(RegistryEntryLookup lookup) { + return new ConfiguredFeature<>(Feature.RANDOM_PATCH, + ConfiguredFeatures.createRandomPatchFeatureConfig( + 6, lookup.getOrThrow(WorldGenerator.RUBBER_TREE_PLACED_FEATURE) + ) + ) + } + + private static PlacedFeature createRubberTreePatchPlacedFeature(RegistryEntryLookup lookup) { + return new PlacedFeature( + lookup.getOrThrow(WorldGenerator.RUBBER_TREE_PATCH_FEATURE), + List.of( + RarityFilterPlacementModifier.of(3), + SquarePlacementModifier.of(), + PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, + BiomePlacementModifier.of() + ) + ) + } +} diff --git a/src/datagen/groovy/techreborn/datagen/worldgen/TRWorldGenProvider.groovy b/src/datagen/groovy/techreborn/datagen/worldgen/TRWorldGenProvider.groovy new file mode 100644 index 000000000..822fb9098 --- /dev/null +++ b/src/datagen/groovy/techreborn/datagen/worldgen/TRWorldGenProvider.groovy @@ -0,0 +1,25 @@ +package techreborn.datagen.worldgen + +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider +import net.minecraft.registry.RegistryKeys +import net.minecraft.registry.RegistryWrapper + +import java.util.concurrent.CompletableFuture + +class TRWorldGenProvider extends FabricDynamicRegistryProvider { + TRWorldGenProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture) + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE)) + entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE)) + } + + @Override + String getName() { + return "TechReborn World gen" + } +} diff --git a/src/gametest/groovy/techreborn/OreDistributionVisualiser.groovy b/src/gametest/groovy/techreborn/OreDistributionVisualiser.groovy index f30eb75fb..054876825 100644 --- a/src/gametest/groovy/techreborn/OreDistributionVisualiser.groovy +++ b/src/gametest/groovy/techreborn/OreDistributionVisualiser.groovy @@ -26,7 +26,7 @@ package techreborn import net.minecraft.Bootstrap import net.minecraft.SharedConstants -import net.minecraft.util.registry.BuiltinRegistries +import net.minecraft.registry.BuiltinRegistries import net.minecraft.world.EmptyBlockView import net.minecraft.world.gen.HeightContext import net.minecraft.world.gen.chunk.DebugChunkGenerator diff --git a/src/main/java/techreborn/TechReborn.java b/src/main/java/techreborn/TechReborn.java index dd8e8f675..36a7036d8 100644 --- a/src/main/java/techreborn/TechReborn.java +++ b/src/main/java/techreborn/TechReborn.java @@ -25,12 +25,9 @@ package techreborn; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.minecraft.block.ComposterBlock; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reborncore.common.blockentity.RedstoneConfiguration; @@ -42,7 +39,15 @@ import techreborn.config.TechRebornConfig; import techreborn.events.ApplyArmorToDamageHandler; import techreborn.events.OreDepthSyncHandler; import techreborn.events.UseBlockHandler; -import techreborn.init.*; +import techreborn.init.FluidGeneratorRecipes; +import techreborn.init.FuelRecipes; +import techreborn.init.ModLoot; +import techreborn.init.ModRecipes; +import techreborn.init.ModSounds; +import techreborn.init.TRBlockEntities; +import techreborn.init.TRCauldronBehavior; +import techreborn.init.TRContent; +import techreborn.init.TRDispenserBehavior; import techreborn.init.template.TechRebornTemplates; import techreborn.items.DynamicCellItem; import techreborn.packets.ServerboundPackets; @@ -55,10 +60,6 @@ public class TechReborn implements ModInitializer { public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public static TechReborn INSTANCE; - public static ItemGroup ITEMGROUP = FabricItemGroupBuilder.build( - new Identifier("techreborn", "item_group"), - () -> new ItemStack(TRContent.NUKE)); - @Override public void onInitialize() { INSTANCE = this; diff --git a/src/main/java/techreborn/blockentity/GuiType.java b/src/main/java/techreborn/blockentity/GuiType.java index 3b2da2c14..6f9b31732 100644 --- a/src/main/java/techreborn/blockentity/GuiType.java +++ b/src/main/java/techreborn/blockentity/GuiType.java @@ -30,13 +30,14 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.Registries; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import reborncore.api.blockentity.IMachineGuiHandler; @@ -142,7 +143,7 @@ public final class GuiType implements IMachineGuiHandler private GuiType(Identifier identifier) { this.identifier = identifier; - this.screenHandlerType = Registry.register(Registry.SCREEN_HANDLER, identifier, new ExtendedScreenHandlerType<>(getScreenHandlerFactory())); + this.screenHandlerType = Registry.register(Registries.SCREEN_HANDLER, identifier, new ExtendedScreenHandlerType<>(getScreenHandlerFactory())); TYPES.put(identifier, this); } diff --git a/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java b/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java index 92c2b7485..114191f8c 100644 --- a/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java +++ b/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java @@ -35,6 +35,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtHelper; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -48,6 +51,7 @@ import reborncore.common.network.ClientBoundPackets; import reborncore.common.network.NetworkManager; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.util.StringUtils; +import reborncore.common.util.WorldUtils; import team.reborn.energy.api.EnergyStorage; import team.reborn.energy.api.base.SimpleSidedEnergyContainer; import techreborn.blocks.cable.CableBlock; @@ -232,7 +236,7 @@ public class CableBlockEntity extends BlockEntity energyContainer.amount = compound.getLong("energy"); } if (compound.contains("cover")) { - cover = NbtHelper.toBlockState(compound.getCompound("cover")); + cover = NbtHelper.toBlockState(WorldUtils.getBlockRegistryWrapper(world), compound.getCompound("cover")); } else { cover = null; } diff --git a/src/main/java/techreborn/blockentity/machine/iron/IronAlloyFurnaceBlockEntity.java b/src/main/java/techreborn/blockentity/machine/iron/IronAlloyFurnaceBlockEntity.java index 04d051127..6d227b47d 100644 --- a/src/main/java/techreborn/blockentity/machine/iron/IronAlloyFurnaceBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/iron/IronAlloyFurnaceBlockEntity.java @@ -104,7 +104,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity return false; if (inventory.getStack(OUTPUT_SLOT).isEmpty()) return true; - if (!inventory.getStack(OUTPUT_SLOT).isItemEqualIgnoreDamage(itemstack)) + if (!inventory.getStack(OUTPUT_SLOT).isItemEqual(itemstack)) return false; int result = inventory.getStack(OUTPUT_SLOT).getCount() + itemstack.getCount(); return result <= inventory.getStackLimit() && result <= inventory.getStack(OUTPUT_SLOT).getMaxCount(); diff --git a/src/main/java/techreborn/blockentity/machine/iron/IronFurnaceBlockEntity.java b/src/main/java/techreborn/blockentity/machine/iron/IronFurnaceBlockEntity.java index 8b91e1b05..b534d5bd6 100644 --- a/src/main/java/techreborn/blockentity/machine/iron/IronFurnaceBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/iron/IronFurnaceBlockEntity.java @@ -98,7 +98,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple // Fast fail if there is no input, no point checking the recipes if the machine is empty return ItemStack.EMPTY; } - if (previousStack.isItemEqualIgnoreDamage(stack) && !previousValid){ + if (previousStack.isItemEqual(stack) && !previousValid){ return ItemStack.EMPTY; } @@ -127,7 +127,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple if (inventory.getStack(OUTPUT_SLOT).isEmpty()) { inventory.setStack(OUTPUT_SLOT, resultStack.copy()); - } else if (inventory.getStack(OUTPUT_SLOT).isItemEqualIgnoreDamage(resultStack)) { + } else if (inventory.getStack(OUTPUT_SLOT).isItemEqual(resultStack)) { inventory.getStack(OUTPUT_SLOT).increment(resultStack.getCount()); } experience += getExperienceFor(); @@ -158,7 +158,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple ItemStack outputSlotStack = inventory.getStack(OUTPUT_SLOT); if (outputSlotStack.isEmpty()) return true; - if (!outputSlotStack.isItemEqualIgnoreDamage(outputStack)) + if (!outputSlotStack.isItemEqual(outputStack)) return false; int result = outputSlotStack.getCount() + outputStack.getCount(); return result <= inventory.getStackLimit() && result <= outputStack.getMaxCount(); diff --git a/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java b/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java index 7f31e9730..a31d36786 100644 --- a/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java @@ -115,7 +115,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem private static IInventoryAccess getInventoryAccess() { return (slotID, stack, face, direction, blockEntity) -> { if (slotID == 0) { - return stack.isItemEqualIgnoreDamage(TRContent.Parts.UU_MATTER.getStack()); + return stack.isItemEqual(TRContent.Parts.UU_MATTER.getStack()); } return true; }; @@ -132,7 +132,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem @Override public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) { return new ScreenHandlerBuilder("fluidreplicator").player(player.getInventory()).inventory().hotbar().addInventory() - .blockEntity(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isItemEqualIgnoreDamage(TRContent.Parts.UU_MATTER.getStack())) + .blockEntity(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isItemEqual(TRContent.Parts.UU_MATTER.getStack())) .outputSlot(2, 124, 55).energySlot(3, 8, 72).sync(tank).syncEnergyValue().syncCrafterValue().addInventory() .create(this, syncID); } diff --git a/src/main/java/techreborn/blockentity/machine/tier0/block/blockbreaker/BlockBreakerProcessor.java b/src/main/java/techreborn/blockentity/machine/tier0/block/blockbreaker/BlockBreakerProcessor.java index 671f5d917..51a23c415 100644 --- a/src/main/java/techreborn/blockentity/machine/tier0/block/blockbreaker/BlockBreakerProcessor.java +++ b/src/main/java/techreborn/blockentity/machine/tier0/block/blockbreaker/BlockBreakerProcessor.java @@ -8,7 +8,7 @@ import net.minecraft.item.Items; import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContextParameters; import net.minecraft.server.world.ServerWorld; -import net.minecraft.tag.BlockTags; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; diff --git a/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java index 83822474a..0855cc106 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java @@ -125,7 +125,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity if (inventoryCrafting == null) { inventoryCrafting = new CraftingInventory(new ScreenHandler(null, -1) { @Override - public ItemStack transferSlot(PlayerEntity player, int index) { + public ItemStack quickMove(PlayerEntity player, int index) { return ItemStack.EMPTY; } diff --git a/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java index 88d2367e0..460a8c035 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java @@ -28,8 +28,9 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.api.blockentity.IUpgrade; import reborncore.common.screen.BuiltScreenHandler; import reborncore.common.screen.BuiltScreenHandlerProvider; @@ -56,7 +57,7 @@ public class RecyclerBlockEntity extends GenericMachineBlockEntity implements Bu if ((item instanceof IUpgrade)) { return false; } - return !TechRebornConfig.recyclerBlackList.contains(Registry.ITEM.getId(item).toString()); + return !TechRebornConfig.recyclerBlackList.contains(Registries.ITEM.getId(item).toString()); } // BuiltScreenHandlerProvider diff --git a/src/main/java/techreborn/blockentity/machine/tier1/RollingMachineBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/RollingMachineBlockEntity.java index afe9e3563..c7d39119b 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/RollingMachineBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/RollingMachineBlockEntity.java @@ -433,7 +433,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity } @Override - public ItemStack transferSlot(PlayerEntity player, int index) { + public ItemStack quickMove(PlayerEntity player, int slot) { return ItemStack.EMPTY; } diff --git a/src/main/java/techreborn/blockentity/machine/tier3/MatterFabricatorBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier3/MatterFabricatorBlockEntity.java index 14aa7d3cc..e8ca5f545 100644 --- a/src/main/java/techreborn/blockentity/machine/tier3/MatterFabricatorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier3/MatterFabricatorBlockEntity.java @@ -87,7 +87,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity } public int getValue(ItemStack itemStack) { - if (itemStack.isItemEqualIgnoreDamage(TRContent.Parts.SCRAP.getStack())) { + if (itemStack.isItemEqual(TRContent.Parts.SCRAP.getStack())) { return 200; } else if (itemStack.getItem() == TRContent.SCRAP_BOX) { return 2000; diff --git a/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java b/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java index 388137e6c..046808438 100644 --- a/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java +++ b/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java @@ -155,7 +155,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements // MachineBaseBlockEntity @Override public boolean isUpgradeValid(IUpgrade upgrade, ItemStack stack) { - return stack.isItemEqual(new ItemStack(TRContent.Upgrades.SUPERCONDUCTOR.item)); + return stack.isOf(TRContent.Upgrades.SUPERCONDUCTOR.item); } // IContainerProvider diff --git a/src/main/java/techreborn/blocks/cable/CableBlock.java b/src/main/java/techreborn/blocks/cable/CableBlock.java index 3bfa2fb2e..c6c2877a3 100644 --- a/src/main/java/techreborn/blocks/cable/CableBlock.java +++ b/src/main/java/techreborn/blocks/cable/CableBlock.java @@ -181,7 +181,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { public BlockState getStateForNeighborUpdate(BlockState ourState, Direction direction, BlockState otherState, WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) { if (ourState.get(WATERLOGGED)) { - worldIn.createAndScheduleFluidTick(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); + worldIn.scheduleFluidTick(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); } return ourState; } diff --git a/src/main/java/techreborn/blocks/misc/BlockRubberLog.java b/src/main/java/techreborn/blocks/misc/BlockRubberLog.java index 8c1c55fc5..81af08617 100644 --- a/src/main/java/techreborn/blocks/misc/BlockRubberLog.java +++ b/src/main/java/techreborn/blocks/misc/BlockRubberLog.java @@ -37,7 +37,7 @@ import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; diff --git a/src/main/java/techreborn/blocks/misc/RubberButtonBlock.java b/src/main/java/techreborn/blocks/misc/RubberButtonBlock.java index f4753b050..ca99fc55d 100644 --- a/src/main/java/techreborn/blocks/misc/RubberButtonBlock.java +++ b/src/main/java/techreborn/blocks/misc/RubberButtonBlock.java @@ -24,15 +24,16 @@ package techreborn.blocks.misc; -import net.minecraft.block.WoodenButtonBlock; +import net.minecraft.block.ButtonBlock; +import net.minecraft.sound.SoundEvents; import techreborn.utils.InitUtils; /** * @author drcrazy */ -public class RubberButtonBlock extends WoodenButtonBlock { +public class RubberButtonBlock extends ButtonBlock { public RubberButtonBlock() { - super(InitUtils.setupRubberBlockSettings(true, 0.5F, 0.5F)); + super(InitUtils.setupRubberBlockSettings(true, 0.5F, 0.5F), 30, true, SoundEvents.BLOCK_WOODEN_BUTTON_CLICK_OFF, SoundEvents.BLOCK_WOODEN_BUTTON_CLICK_ON); } } diff --git a/src/main/java/techreborn/blocks/misc/RubberDoorBlock.java b/src/main/java/techreborn/blocks/misc/RubberDoorBlock.java index 0802b9641..2ef7d4123 100644 --- a/src/main/java/techreborn/blocks/misc/RubberDoorBlock.java +++ b/src/main/java/techreborn/blocks/misc/RubberDoorBlock.java @@ -25,6 +25,7 @@ package techreborn.blocks.misc; import net.minecraft.block.DoorBlock; +import net.minecraft.sound.SoundEvents; import techreborn.utils.InitUtils; /** @@ -33,6 +34,6 @@ import techreborn.utils.InitUtils; public class RubberDoorBlock extends DoorBlock { public RubberDoorBlock() { - super(InitUtils.setupRubberBlockSettings(3.0F, 3.0F)); + super(InitUtils.setupRubberBlockSettings(3.0F, 3.0F), SoundEvents.BLOCK_NETHER_WOOD_TRAPDOOR_CLOSE, SoundEvents.BLOCK_NETHER_WOOD_TRAPDOOR_OPEN); } } diff --git a/src/main/java/techreborn/blocks/misc/RubberPressurePlateBlock.java b/src/main/java/techreborn/blocks/misc/RubberPressurePlateBlock.java index 37cc098f8..c23c358b7 100644 --- a/src/main/java/techreborn/blocks/misc/RubberPressurePlateBlock.java +++ b/src/main/java/techreborn/blocks/misc/RubberPressurePlateBlock.java @@ -25,6 +25,7 @@ package techreborn.blocks.misc; import net.minecraft.block.PressurePlateBlock; +import net.minecraft.sound.SoundEvents; import techreborn.utils.InitUtils; /** @@ -33,7 +34,7 @@ import techreborn.utils.InitUtils; public class RubberPressurePlateBlock extends PressurePlateBlock { public RubberPressurePlateBlock() { - super(PressurePlateBlock.ActivationRule.EVERYTHING, InitUtils.setupRubberBlockSettings(true, 0.5F, 0.5F)); + super(PressurePlateBlock.ActivationRule.EVERYTHING, InitUtils.setupRubberBlockSettings(true, 0.5F, 0.5F), SoundEvents.BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_OFF, SoundEvents.BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_ON); } } diff --git a/src/main/java/techreborn/blocks/misc/RubberTrapdoorBlock.java b/src/main/java/techreborn/blocks/misc/RubberTrapdoorBlock.java index 2bc762e8a..86b0b5d6f 100644 --- a/src/main/java/techreborn/blocks/misc/RubberTrapdoorBlock.java +++ b/src/main/java/techreborn/blocks/misc/RubberTrapdoorBlock.java @@ -25,6 +25,7 @@ package techreborn.blocks.misc; import net.minecraft.block.TrapdoorBlock; +import net.minecraft.sound.SoundEvents; import techreborn.utils.InitUtils; /** @@ -33,6 +34,6 @@ import techreborn.utils.InitUtils; public class RubberTrapdoorBlock extends TrapdoorBlock { public RubberTrapdoorBlock() { - super(InitUtils.setupRubberBlockSettings(3.0F, 3.0F)); + super(InitUtils.setupRubberBlockSettings(3.0F, 3.0F), SoundEvents.BLOCK_WOODEN_TRAPDOOR_CLOSE, SoundEvents.BLOCK_WOODEN_TRAPDOOR_OPEN); } } diff --git a/src/main/java/techreborn/config/TechRebornConfig.java b/src/main/java/techreborn/config/TechRebornConfig.java index a0a4b469d..41ea93cb7 100644 --- a/src/main/java/techreborn/config/TechRebornConfig.java +++ b/src/main/java/techreborn/config/TechRebornConfig.java @@ -694,4 +694,10 @@ public class TechRebornConfig { @Config(config = "world", category = "generation", key = "enableOilLakeGeneration", comment = "When enabled oil lakes will generate in the world") public static boolean enableOilLakeGeneration = true; + + @Config(config = "world", category = "generation", key = "enableMetallurgistGeneration", comment = "When enabled metallurgist houses can generate in villages") + public static boolean enableMetallurgistGeneration = true; + + @Config(config = "world", category = "generation", key = "enableElectricianGeneration", comment = "When enabled electrician houses can generate in villages") + public static boolean enableElectricianGeneration = true; } diff --git a/src/main/java/techreborn/events/ModRegistry.java b/src/main/java/techreborn/events/ModRegistry.java index 01eb12778..43c4f22c1 100644 --- a/src/main/java/techreborn/events/ModRegistry.java +++ b/src/main/java/techreborn/events/ModRegistry.java @@ -32,6 +32,7 @@ import net.minecraft.item.Item; import net.minecraft.item.Item.Settings; import net.minecraft.item.Items; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.sound.SoundEvents; import reborncore.RebornRegistry; import reborncore.common.powerSystem.RcEnergyTier; import team.reborn.energy.api.EnergyStorage; @@ -72,10 +73,11 @@ public class ModRegistry { registerApis(); TRVillager.registerVillagerTrades(); TRVillager.registerWanderingTraderTrades(); + TRVillager.registerVillagerHouses(); } private static void registerBlocks() { - Settings itemGroup = new Item.Settings().group(TechReborn.ITEMGROUP); + Settings itemGroup = new Item.Settings(); Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block, itemGroup)); StorageBlocks.blockStream().forEach(block -> RebornRegistry.registerBlock(block, itemGroup)); Arrays.stream(MachineBlocks.values()).forEach(value -> { @@ -103,7 +105,7 @@ public class ModRegistry { RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_SLAB = InitUtils.setup(new SlabBlock(InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_slab"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_FENCE = InitUtils.setup(new FenceBlock(InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_fence"), itemGroup); - RebornRegistry.registerBlock(TRContent.RUBBER_FENCE_GATE = InitUtils.setup(new FenceGateBlock(InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_fence_gate"), itemGroup); + RebornRegistry.registerBlock(TRContent.RUBBER_FENCE_GATE = InitUtils.setup(new FenceGateBlock(InitUtils.setupRubberBlockSettings(2.0F, 15.0F), SoundEvents.BLOCK_FENCE_GATE_CLOSE, SoundEvents.BLOCK_FENCE_GATE_OPEN), "rubber_fence_gate"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_STAIR = InitUtils.setup(new BlockRubberPlankStair(), "rubber_stair"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_TRAPDOOR = InitUtils.setup(new RubberTrapdoorBlock(), "rubber_trapdoor"), itemGroup); RebornRegistry.registerBlock(TRContent.RUBBER_BUTTON = InitUtils.setup(new RubberButtonBlock(), "rubber_button"), itemGroup); diff --git a/src/main/java/techreborn/events/OreDepthSyncHandler.java b/src/main/java/techreborn/events/OreDepthSyncHandler.java index 1dfb0723d..877b42fe1 100644 --- a/src/main/java/techreborn/events/OreDepthSyncHandler.java +++ b/src/main/java/techreborn/events/OreDepthSyncHandler.java @@ -26,7 +26,7 @@ package techreborn.events; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.block.Block; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registries; import reborncore.common.network.NetworkManager; import techreborn.packets.ClientboundPackets; import techreborn.world.OreDepth; @@ -52,7 +52,7 @@ public final class OreDepthSyncHandler { public static void updateDepths(List list) { synchronized (OreDepthSyncHandler.class) { oreDepthMap = list.stream() - .collect(Collectors.toMap(oreDepth -> Registry.BLOCK.get(oreDepth.identifier()), Function.identity())); + .collect(Collectors.toMap(oreDepth -> Registries.BLOCK.get(oreDepth.identifier()), Function.identity())); } } diff --git a/src/main/java/techreborn/init/ModFluids.java b/src/main/java/techreborn/init/ModFluids.java index 3deb71270..58c1fd362 100644 --- a/src/main/java/techreborn/init/ModFluids.java +++ b/src/main/java/techreborn/init/ModFluids.java @@ -28,15 +28,17 @@ package techreborn.init; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Material; import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; import net.minecraft.item.Items; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.common.fluid.*; import techreborn.TechReborn; import java.util.Locale; -public enum ModFluids { +public enum ModFluids implements ItemConvertible { BERYLLIUM, CALCIUM, CALCIUM_CARBONATE, @@ -97,15 +99,15 @@ public enum ModFluids { }; block = new RebornFluidBlock(stillFluid, FabricBlockSettings.of(Material.WATER).noCollision().hardness(100.0F).dropsNothing()); - bucket = new RebornBucketItem(stillFluid, new Item.Settings().group(TechReborn.ITEMGROUP).recipeRemainder(Items.BUCKET).maxCount(1)); + bucket = new RebornBucketItem(stillFluid, new Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1)); } public void register() { RebornFluidManager.register(stillFluid, identifier); RebornFluidManager.register(flowingFluid, new Identifier(TechReborn.MOD_ID, identifier.getPath() + "_flowing")); - Registry.register(Registry.BLOCK, identifier, block); - Registry.register(Registry.ITEM, new Identifier(TechReborn.MOD_ID, identifier.getPath() + "_bucket"), bucket); + Registry.register(Registries.BLOCK, identifier, block); + Registry.register(Registries.ITEM, new Identifier(TechReborn.MOD_ID, identifier.getPath() + "_bucket"), bucket); } public RebornFluid getFluid() { @@ -127,4 +129,9 @@ public enum ModFluids { public RebornBucketItem getBucket() { return bucket; } + + @Override + public Item asItem() { + return getBucket(); + } } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 355b25d28..50b68c2fe 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -24,14 +24,21 @@ package techreborn.init; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RecipeManager; import reborncore.common.crafting.serde.RebornFluidRecipeSerde; import reborncore.common.crafting.serde.RebornRecipeSerde; -import techreborn.api.recipe.recipes.*; +import techreborn.api.recipe.recipes.AssemblingMachineRecipe; +import techreborn.api.recipe.recipes.BlastFurnaceRecipe; +import techreborn.api.recipe.recipes.CentrifugeRecipe; +import techreborn.api.recipe.recipes.FluidReplicatorRecipe; +import techreborn.api.recipe.recipes.FusionReactorRecipe; +import techreborn.api.recipe.recipes.IndustrialGrinderRecipe; +import techreborn.api.recipe.recipes.IndustrialSawmillRecipe; +import techreborn.api.recipe.recipes.RollingMachineRecipe; import techreborn.api.recipe.recipes.serde.BlastFurnaceRecipeSerde; import techreborn.api.recipe.recipes.serde.FusionReactorRecipeSerde; import techreborn.api.recipe.recipes.serde.RollingMachineRecipeSerde; @@ -69,6 +76,6 @@ public class ModRecipes { public static final RebornRecipeType WIRE_MILL = RecipeManager.newRecipeType(new Identifier("techreborn:wire_mill")); public static RebornRecipeType byName(Identifier identifier) { - return (RebornRecipeType) Registry.RECIPE_SERIALIZER.get(identifier); + return (RebornRecipeType) Registries.RECIPE_SERIALIZER.get(identifier); } } diff --git a/src/main/java/techreborn/init/TRBlockEntities.java b/src/main/java/techreborn/init/TRBlockEntities.java index 107f127fd..37c056eba 100644 --- a/src/main/java/techreborn/init/TRBlockEntities.java +++ b/src/main/java/techreborn/init/TRBlockEntities.java @@ -30,9 +30,10 @@ import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.ItemConvertible; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import org.apache.commons.lang3.Validate; import techreborn.TechReborn; import techreborn.blockentity.cable.CableBlockEntity; @@ -158,7 +159,7 @@ public class TRBlockEntities { public static BlockEntityType register(String id, FabricBlockEntityTypeBuilder builder) { BlockEntityType blockEntityType = builder.build(null); - Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(id), blockEntityType); + Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(id), blockEntityType); TRBlockEntities.TYPES.add(blockEntityType); return blockEntityType; } diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index d8ae580d6..b6a5bd0a4 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -26,18 +26,23 @@ package techreborn.init; import com.google.common.base.Preconditions; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.ExperienceDroppingBlock; +import net.minecraft.block.Material; +import net.minecraft.block.SlabBlock; +import net.minecraft.block.StairsBlock; +import net.minecraft.block.WallBlock; import net.minecraft.entity.EntityType; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; import net.minecraft.util.math.intprovider.UniformIntProvider; -import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Marker; @@ -51,16 +56,42 @@ import techreborn.TechReborn; import techreborn.blockentity.GuiType; import techreborn.blockentity.generator.LightningRodBlockEntity; import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity; -import techreborn.blockentity.generator.advanced.*; +import techreborn.blockentity.generator.advanced.DieselGeneratorBlockEntity; +import techreborn.blockentity.generator.advanced.DragonEggSyphonBlockEntity; +import techreborn.blockentity.generator.advanced.GasTurbineBlockEntity; +import techreborn.blockentity.generator.advanced.SemiFluidGeneratorBlockEntity; +import techreborn.blockentity.generator.advanced.ThermalGeneratorBlockEntity; import techreborn.blockentity.generator.basic.SolidFuelGeneratorBlockEntity; import techreborn.blockentity.generator.basic.WaterMillBlockEntity; import techreborn.blockentity.generator.basic.WindMillBlockEntity; import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity; import techreborn.blockentity.machine.misc.DrainBlockEntity; -import techreborn.blockentity.machine.multiblock.*; +import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity; +import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity; +import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity; +import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity; +import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity; +import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity; +import techreborn.blockentity.machine.multiblock.VacuumFreezerBlockEntity; import techreborn.blockentity.machine.tier0.block.BlockBreakerBlockEntity; import techreborn.blockentity.machine.tier0.block.BlockPlacerBlockEntity; -import techreborn.blockentity.machine.tier1.*; +import techreborn.blockentity.machine.tier1.AlloySmelterBlockEntity; +import techreborn.blockentity.machine.tier1.AssemblingMachineBlockEntity; +import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity; +import techreborn.blockentity.machine.tier1.ChemicalReactorBlockEntity; +import techreborn.blockentity.machine.tier1.CompressorBlockEntity; +import techreborn.blockentity.machine.tier1.ElectricFurnaceBlockEntity; +import techreborn.blockentity.machine.tier1.ElevatorBlockEntity; +import techreborn.blockentity.machine.tier1.ExtractorBlockEntity; +import techreborn.blockentity.machine.tier1.GreenhouseControllerBlockEntity; +import techreborn.blockentity.machine.tier1.GrinderBlockEntity; +import techreborn.blockentity.machine.tier1.IndustrialElectrolyzerBlockEntity; +import techreborn.blockentity.machine.tier1.RecyclerBlockEntity; +import techreborn.blockentity.machine.tier1.ResinBasinBlockEntity; +import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity; +import techreborn.blockentity.machine.tier1.ScrapboxinatorBlockEntity; +import techreborn.blockentity.machine.tier1.SolidCanningMachineBlockEntity; +import techreborn.blockentity.machine.tier1.WireMillBlockEntity; import techreborn.blockentity.machine.tier2.LaunchpadBlockEntity; import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity; import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity; @@ -77,8 +108,18 @@ import techreborn.blocks.machine.tier0.IronAlloyFurnaceBlock; import techreborn.blocks.machine.tier0.IronFurnaceBlock; import techreborn.blocks.machine.tier1.PlayerDetectorBlock; import techreborn.blocks.machine.tier1.ResinBasinBlock; -import techreborn.blocks.misc.*; -import techreborn.blocks.storage.energy.*; +import techreborn.blocks.misc.BlockAlarm; +import techreborn.blocks.misc.BlockMachineCasing; +import techreborn.blocks.misc.BlockMachineFrame; +import techreborn.blocks.misc.BlockStorage; +import techreborn.blocks.misc.TechRebornStairsBlock; +import techreborn.blocks.storage.energy.AdjustableSUBlock; +import techreborn.blocks.storage.energy.HighVoltageSUBlock; +import techreborn.blocks.storage.energy.InterdimensionalSUBlock; +import techreborn.blocks.storage.energy.LSUStorageBlock; +import techreborn.blocks.storage.energy.LapotronicSUBlock; +import techreborn.blocks.storage.energy.LowVoltageSUBlock; +import techreborn.blocks.storage.energy.MediumVoltageSUBlock; import techreborn.blocks.storage.fluid.TankUnitBlock; import techreborn.blocks.storage.item.StorageUnitBlock; import techreborn.blocks.transformers.BlockEVTransformer; @@ -95,7 +136,14 @@ import techreborn.items.armor.QuantumSuitItem; import techreborn.utils.InitUtils; import techreborn.world.OreDistribution; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -266,27 +314,27 @@ public class TRContent { public static Item STEEL_BOOTS; public final static class BlockTags { - public static final TagKey RUBBER_LOGS = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "rubber_logs")); - public static final TagKey OMNI_TOOL_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "mineable/omni_tool")); - public static final TagKey DRILL_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "mineable/drill")); - public static final TagKey NONE_SOLID_COVERS = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "none_solid_covers")); + public static final TagKey RUBBER_LOGS = TagKey.of(RegistryKeys.BLOCK, new Identifier(TechReborn.MOD_ID, "rubber_logs")); + public static final TagKey OMNI_TOOL_MINEABLE = TagKey.of(RegistryKeys.BLOCK, new Identifier(TechReborn.MOD_ID, "mineable/omni_tool")); + public static final TagKey DRILL_MINEABLE = TagKey.of(RegistryKeys.BLOCK, new Identifier(TechReborn.MOD_ID, "mineable/drill")); + public static final TagKey NONE_SOLID_COVERS = TagKey.of(RegistryKeys.BLOCK, new Identifier(TechReborn.MOD_ID, "none_solid_covers")); private BlockTags() { } } public final static class ItemTags { - public static final TagKey RUBBER_LOGS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "rubber_logs")); - public static final TagKey INGOTS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "ingots")); - public static final TagKey ORES = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "ores")); - public static final TagKey STORAGE_BLOCK = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "storage_blocks")); - public static final TagKey DUSTS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "dusts")); - public static final TagKey RAW_METALS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "raw_metals")); - public static final TagKey SMALL_DUSTS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "small_dusts")); - public static final TagKey GEMS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "gems")); - public static final TagKey NUGGETS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "nuggets")); - public static final TagKey PLATES = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "plates")); - public static final TagKey STORAGE_UNITS = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "storage_units")); + public static final TagKey RUBBER_LOGS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "rubber_logs")); + public static final TagKey INGOTS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "ingots")); + public static final TagKey ORES = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "ores")); + public static final TagKey STORAGE_BLOCK = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "storage_blocks")); + public static final TagKey DUSTS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "dusts")); + public static final TagKey RAW_METALS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "raw_metals")); + public static final TagKey SMALL_DUSTS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "small_dusts")); + public static final TagKey GEMS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "gems")); + public static final TagKey NUGGETS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "nuggets")); + public static final TagKey PLATES = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "plates")); + public static final TagKey STORAGE_UNITS = TagKey.of(RegistryKeys.ITEM, new Identifier(TechReborn.MOD_ID, "storage_units")); private ItemTags() { } @@ -530,7 +578,7 @@ public class TRContent { Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback, boolean industrial) { name = this.toString().toLowerCase(Locale.ROOT); - block = new OreBlock(FabricBlockSettings.of(Material.STONE) + block = new ExperienceDroppingBlock(FabricBlockSettings.of(Material.STONE) .requiresTool() .sounds(name.startsWith("deepslate") ? BlockSoundGroup.DEEPSLATE : BlockSoundGroup.STONE) .hardness(name.startsWith("deepslate") ? 4.5f : 3f) @@ -539,7 +587,7 @@ public class TRContent { ); this.industrial = industrial; InitUtils.setup(block, name + "_ore"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", (name.startsWith("deepslate_") ? name.substring(name.indexOf('_')+1): name) + "_ores")); this.distribution = distribution; } @@ -642,7 +690,7 @@ public class TRContent { name = this.toString().toLowerCase(Locale.ROOT); block = new BlockStorage(isHot, hardness, resistance); InitUtils.setup(block, name + "_storage_block"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_blocks")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_blocks")); stairsBlock = new TechRebornStairsBlock(block.getDefaultState(), FabricBlockSettings.copyOf(block)); InitUtils.setup(stairsBlock, name + "_storage_block_stairs"); @@ -835,9 +883,9 @@ public class TRContent { Dusts(String tagNameBase) { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); InitUtils.setup(item, name + "_dust"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_dusts")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_dusts")); } Dusts() { @@ -874,7 +922,7 @@ public class TRContent { RawMetals() { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); Ores oreVariant = null; try { oreVariant = Ores.valueOf(this.toString()); @@ -894,7 +942,7 @@ public class TRContent { } storageBlock = blockVariant; InitUtils.setup(item, "raw_" + name); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "raw_" + name + "_ores")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", "raw_" + name + "_ores")); } @Override @@ -955,7 +1003,7 @@ public class TRContent { SmallDusts(String tagNameBase, ItemConvertible dustVariant) { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); if (dustVariant == null) try { dustVariant = Dusts.valueOf(this.toString()); @@ -966,7 +1014,7 @@ public class TRContent { } dust = dustVariant; InitUtils.setup(item, name + "_small_dust"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_small_dusts")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_small_dusts")); } SmallDusts(String tagNameBase) { @@ -1031,7 +1079,7 @@ public class TRContent { Gems(String tagPlural) { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); Dusts dustVariant = null; try { dustVariant = Dusts.valueOf(this.toString()); @@ -1059,7 +1107,7 @@ public class TRContent { } storageBlock = blockVariant; InitUtils.setup(item, name + "_gem"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural)); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural)); } Gems() { @@ -1134,7 +1182,7 @@ public class TRContent { Ingots(String tagNameBase) { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); Dusts dustVariant = null; try { dustVariant = Dusts.valueOf(this.toString()); @@ -1161,7 +1209,7 @@ public class TRContent { } storageBlock = blockVariant; InitUtils.setup(item, name + "_ingot"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_ingots")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_ingots")); } Ingots() { @@ -1233,7 +1281,7 @@ public class TRContent { Nuggets(String tagNameBase, ItemConvertible ingotVariant, boolean ofGem) { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); if (ingotVariant == null) try { ingotVariant = Ingots.valueOf(this.toString()); @@ -1245,7 +1293,7 @@ public class TRContent { ingot = ingotVariant; this.ofGem = ofGem; InitUtils.setup(item, name + "_nugget"); - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_nuggets")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_nuggets")); } Nuggets(ItemConvertible ingotVariant, boolean ofGem) { @@ -1358,7 +1406,7 @@ public class TRContent { Parts() { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); InitUtils.setup(item, name); } @@ -1427,7 +1475,7 @@ public class TRContent { Plates(ItemConvertible source, ItemConvertible sourceBlock, boolean industrial, String tagNameBase) { name = this.toString().toLowerCase(Locale.ROOT); - item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings()); ItemConvertible sourceVariant = null; if (source != null) { sourceVariant = source; @@ -1471,7 +1519,7 @@ public class TRContent { tagNameBase = name; } - tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_plates")); + tag = TagKey.of(RegistryKeys.ITEM, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_plates")); } Plates(String tagNameBase) { @@ -1590,5 +1638,6 @@ public class TRContent { static { ModRegistry.register(); + TRItemGroup.ITEM_GROUP.getId(); } } diff --git a/src/main/java/techreborn/init/TRItemGroup.java b/src/main/java/techreborn/init/TRItemGroup.java new file mode 100644 index 000000000..09276ddca --- /dev/null +++ b/src/main/java/techreborn/init/TRItemGroup.java @@ -0,0 +1,826 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2020 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.init; + +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.fluid.Fluid; +import net.minecraft.item.*; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.util.Identifier; +import reborncore.common.fluid.FluidUtils; +import reborncore.common.powerSystem.RcEnergyItem; +import techreborn.items.DynamicCellItem; +import techreborn.items.tool.basic.RockCutterItem; +import techreborn.items.tool.industrial.NanosaberItem; +import techreborn.utils.MaterialComparator; +import techreborn.utils.MaterialTypeComparator; + +import java.util.*; + +public class TRItemGroup { + public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder(new Identifier("techreborn", "item_group")) + .icon(() -> new ItemStack(TRContent.NUKE)) + .build(); + + static { + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(TRItemGroup::entries); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(TRItemGroup::addBuildingBlocks); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.COLORED_BLOCKS).register(TRItemGroup::addColoredBlocks); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(TRItemGroup::addNaturalBlocks); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(TRItemGroup::addFunctionalBlocks); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.REDSTONE).register(TRItemGroup::addRedstoneBlocks); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(TRItemGroup::addTools); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(TRItemGroup::addCombat); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(TRItemGroup::addIngredients); + } + + private static final ItemConvertible[] rubberOrderSmall = new ItemConvertible[]{ + TRContent.RUBBER_LOG, + TRContent.RUBBER_LOG_STRIPPED, + TRContent.RUBBER_WOOD, + TRContent.STRIPPED_RUBBER_WOOD, + TRContent.RUBBER_PLANKS, + TRContent.RUBBER_STAIR, + TRContent.RUBBER_SLAB, + TRContent.RUBBER_FENCE, + TRContent.RUBBER_FENCE_GATE, + TRContent.RUBBER_DOOR, + TRContent.RUBBER_TRAPDOOR, + TRContent.RUBBER_PRESSURE_PLATE, + TRContent.RUBBER_BUTTON + }; + + private static void entries(FabricItemGroupEntries entries) { + // rubber tree and related stuff + entries.add(TRContent.RUBBER_SAPLING); + entries.add(TRContent.RUBBER_LEAVES); + addContent(rubberOrderSmall, entries); + entries.add(TRContent.TREE_TAP); + addPoweredItem(TRContent.ELECTRIC_TREE_TAP, entries, null, true); + entries.add(TRContent.Machine.RESIN_BASIN); + entries.add(TRContent.Parts.SAP); + entries.add(TRContent.Parts.RUBBER); + + // resources + List> stuff = new LinkedList<>(); + stuff.addAll(Arrays.stream(TRContent.Ores.values()).filter(ore -> !ore.isDeepslate()).toList()); + stuff.addAll(Arrays.stream(TRContent.Dusts.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.RawMetals.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.SmallDusts.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.Gems.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.Ingots.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.Nuggets.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.Plates.values()).toList()); + stuff.addAll(Arrays.stream(TRContent.StorageBlocks.values()).filter(block -> !block.name().startsWith("RAW")).toList()); + Collections.sort(stuff, new MaterialComparator().thenComparing(new MaterialTypeComparator())); + for (Object item : stuff) { + entries.add((ItemConvertible)item); + } + entries.addAfter(TRContent.Plates.COPPER, TRContent.COPPER_WALL); + entries.addAfter(TRContent.Plates.IRON, TRContent.REFINED_IRON_FENCE); + entries.addBefore(TRContent.Plates.CARBON, + TRContent.Parts.CARBON_FIBER, + TRContent.Parts.CARBON_MESH); + entries.addAfter(TRContent.RawMetals.TIN, TRContent.StorageBlocks.RAW_TIN); + entries.addAfter(TRContent.RawMetals.LEAD, TRContent.StorageBlocks.RAW_LEAD); + entries.addAfter(TRContent.RawMetals.SILVER, TRContent.StorageBlocks.RAW_SILVER); + entries.addAfter(TRContent.RawMetals.IRIDIUM, TRContent.StorageBlocks.RAW_IRIDIUM); + entries.addAfter(TRContent.RawMetals.TUNGSTEN, TRContent.StorageBlocks.RAW_TUNGSTEN); + for (TRContent.StorageBlocks block : TRContent.StorageBlocks.values()) { + entries.addAfter(block, + block.getStairsBlock(), + block.getSlabBlock(), + block.getWallBlock() + ); + } + for (TRContent.Ores ore : TRContent.Ores.values()) { + if (!ore.isDeepslate()) { + continue; + } + entries.addAfter(ore.getUnDeepslate(), ore); + } + + // fluids + addContent(ModFluids.values(), entries); + addCells(entries); + + // parts + addContent(TRContent.Parts.values(), entries); + entries.add(TRContent.FREQUENCY_TRANSMITTER); + entries.add(TRContent.REINFORCED_GLASS); + entries.addAfter(TRContent.Parts.SCRAP, TRContent.SCRAP_BOX); + + // machines + entries.add(TRContent.WRENCH); + entries.add(TRContent.PAINTING_TOOL); + for (TRContent.MachineBlocks machineBlock : TRContent.MachineBlocks.values()) { + entries.add(machineBlock.frame); + entries.add(machineBlock.casing); + } + addContent(TRContent.Cables.values(), entries); + addContent(TRContent.Machine.values(), entries); + addContent(TRContent.SolarPanels.values(), entries); + entries.add(TRContent.COMPUTER_CUBE); + entries.add(TRContent.NUKE); + addContent(TRContent.Upgrades.values(), entries); + addContent(TRContent.StorageUnit.values(), entries); + addContent(TRContent.TankUnit.values(), entries); + for (TRContent.StorageUnit storageUnit : TRContent.StorageUnit.values()) { + if (storageUnit.upgrader != null) { + entries.add(storageUnit.upgrader); + } + } + + // armor and traditional tools + entries.add(TRContent.BRONZE_HELMET); + entries.add(TRContent.BRONZE_CHESTPLATE); + entries.add(TRContent.BRONZE_LEGGINGS); + entries.add(TRContent.BRONZE_BOOTS); + entries.add(TRContent.BRONZE_SWORD); + entries.add(TRContent.BRONZE_PICKAXE); + entries.add(TRContent.BRONZE_AXE); + entries.add(TRContent.BRONZE_HOE); + entries.add(TRContent.BRONZE_SPADE); + + entries.add(TRContent.RUBY_HELMET); + entries.add(TRContent.RUBY_CHESTPLATE); + entries.add(TRContent.RUBY_LEGGINGS); + entries.add(TRContent.RUBY_BOOTS); + entries.add(TRContent.RUBY_SWORD); + entries.add(TRContent.RUBY_PICKAXE); + entries.add(TRContent.RUBY_AXE); + entries.add(TRContent.RUBY_HOE); + entries.add(TRContent.RUBY_SPADE); + + entries.add(TRContent.SAPPHIRE_HELMET); + entries.add(TRContent.SAPPHIRE_CHESTPLATE); + entries.add(TRContent.SAPPHIRE_LEGGINGS); + entries.add(TRContent.SAPPHIRE_BOOTS); + entries.add(TRContent.SAPPHIRE_SWORD); + entries.add(TRContent.SAPPHIRE_PICKAXE); + entries.add(TRContent.SAPPHIRE_AXE); + entries.add(TRContent.SAPPHIRE_HOE); + entries.add(TRContent.SAPPHIRE_SPADE); + + entries.add(TRContent.PERIDOT_HELMET); + entries.add(TRContent.PERIDOT_CHESTPLATE); + entries.add(TRContent.PERIDOT_LEGGINGS); + entries.add(TRContent.PERIDOT_BOOTS); + entries.add(TRContent.PERIDOT_SWORD); + entries.add(TRContent.PERIDOT_PICKAXE); + entries.add(TRContent.PERIDOT_AXE); + entries.add(TRContent.PERIDOT_HOE); + entries.add(TRContent.PERIDOT_SPADE); + + entries.add(TRContent.SILVER_HELMET); + entries.add(TRContent.SILVER_CHESTPLATE); + entries.add(TRContent.SILVER_LEGGINGS); + entries.add(TRContent.SILVER_BOOTS); + + entries.add(TRContent.STEEL_HELMET); + entries.add(TRContent.STEEL_CHESTPLATE); + entries.add(TRContent.STEEL_LEGGINGS); + entries.add(TRContent.STEEL_BOOTS); + + // powered tools + addPoweredItem(TRContent.BASIC_CHAINSAW, entries, null, true); + addPoweredItem(TRContent.BASIC_JACKHAMMER, entries, null, true); + addPoweredItem(TRContent.BASIC_DRILL, entries, null, true); + + addPoweredItem(TRContent.ADVANCED_CHAINSAW, entries, null, true); + addPoweredItem(TRContent.ADVANCED_JACKHAMMER, entries, null, true); + addPoweredItem(TRContent.ADVANCED_DRILL, entries, null, true); + + addPoweredItem(TRContent.INDUSTRIAL_CHAINSAW, entries, null, true); + addPoweredItem(TRContent.INDUSTRIAL_JACKHAMMER, entries, null, true); + addPoweredItem(TRContent.INDUSTRIAL_DRILL, entries, null, true); + + addRockCutter(entries, null, true); + addPoweredItem(TRContent.OMNI_TOOL, entries, null, true); + + addPoweredItem(TRContent.QUANTUM_HELMET, entries, null, true); + addPoweredItem(TRContent.QUANTUM_CHESTPLATE, entries, null, true); + addPoweredItem(TRContent.QUANTUM_LEGGINGS, entries, null, true); + addPoweredItem(TRContent.QUANTUM_BOOTS, entries, null, true); + + addNanosaber(entries, null, false); + + addPoweredItem(TRContent.LITHIUM_ION_BATPACK, entries, null, true); + addPoweredItem(TRContent.LAPOTRONIC_ORBPACK, entries, null, true); + addPoweredItem(TRContent.CLOAKING_DEVICE, entries, null, true); + + addPoweredItem(TRContent.RED_CELL_BATTERY, entries, null, true); + addPoweredItem(TRContent.LITHIUM_ION_BATTERY, entries, null, true); + addPoweredItem(TRContent.ENERGY_CRYSTAL, entries, null, true); + addPoweredItem(TRContent.LAPOTRON_CRYSTAL, entries, null, true); + addPoweredItem(TRContent.LAPOTRONIC_ORB, entries, null, true); + + entries.add(TRContent.GPS); + + entries.add(TRContent.MANUAL); + entries.add(TRContent.DEBUG_TOOL); + } + + private static void addBuildingBlocks(FabricItemGroupEntries entries) { + entries.addAfter(Items.MANGROVE_BUTTON, rubberOrderSmall); + entries.addAfter(Items.AMETHYST_BLOCK, + TRContent.MachineBlocks.BASIC.getFrame(), + TRContent.MachineBlocks.ADVANCED.getFrame(), + TRContent.MachineBlocks.INDUSTRIAL.getFrame()); + entries.addAfter(Items.CHAIN, TRContent.REFINED_IRON_FENCE); + entries.addBefore(Items.COPPER_BLOCK, + TRContent.StorageBlocks.RAW_TIN, + TRContent.StorageBlocks.RAW_TIN.getStairsBlock(), + TRContent.StorageBlocks.RAW_TIN.getSlabBlock(), + TRContent.StorageBlocks.RAW_TIN.getWallBlock(), + TRContent.StorageBlocks.TIN, + TRContent.StorageBlocks.TIN.getStairsBlock(), + TRContent.StorageBlocks.TIN.getSlabBlock(), + TRContent.StorageBlocks.TIN.getWallBlock(), + TRContent.StorageBlocks.ZINC, + TRContent.StorageBlocks.ZINC.getStairsBlock(), + TRContent.StorageBlocks.ZINC.getSlabBlock(), + TRContent.StorageBlocks.ZINC.getWallBlock(), + TRContent.StorageBlocks.REFINED_IRON, + TRContent.StorageBlocks.REFINED_IRON.getStairsBlock(), + TRContent.StorageBlocks.REFINED_IRON.getSlabBlock(), + TRContent.StorageBlocks.REFINED_IRON.getWallBlock(), + TRContent.StorageBlocks.STEEL, + TRContent.StorageBlocks.STEEL.getStairsBlock(), + TRContent.StorageBlocks.STEEL.getSlabBlock(), + TRContent.StorageBlocks.STEEL.getWallBlock()); + entries.addAfter(Items.CUT_COPPER_SLAB, TRContent.COPPER_WALL); + entries.addAfter(Items.WAXED_OXIDIZED_CUT_COPPER_SLAB, + TRContent.StorageBlocks.RAW_LEAD, + TRContent.StorageBlocks.RAW_LEAD.getStairsBlock(), + TRContent.StorageBlocks.RAW_LEAD.getSlabBlock(), + TRContent.StorageBlocks.RAW_LEAD.getWallBlock(), + TRContent.StorageBlocks.LEAD, + TRContent.StorageBlocks.LEAD.getStairsBlock(), + TRContent.StorageBlocks.LEAD.getSlabBlock(), + TRContent.StorageBlocks.LEAD.getWallBlock(), + TRContent.StorageBlocks.NICKEL, + TRContent.StorageBlocks.NICKEL.getStairsBlock(), + TRContent.StorageBlocks.NICKEL.getSlabBlock(), + TRContent.StorageBlocks.NICKEL.getWallBlock(), + TRContent.StorageBlocks.BRONZE, + TRContent.StorageBlocks.BRONZE.getStairsBlock(), + TRContent.StorageBlocks.BRONZE.getSlabBlock(), + TRContent.StorageBlocks.BRONZE.getWallBlock(), + TRContent.StorageBlocks.BRASS, + TRContent.StorageBlocks.BRASS.getStairsBlock(), + TRContent.StorageBlocks.BRASS.getSlabBlock(), + TRContent.StorageBlocks.BRASS.getWallBlock(), + TRContent.StorageBlocks.ADVANCED_ALLOY, + TRContent.StorageBlocks.ADVANCED_ALLOY.getStairsBlock(), + TRContent.StorageBlocks.ADVANCED_ALLOY.getSlabBlock(), + TRContent.StorageBlocks.ADVANCED_ALLOY.getWallBlock(), + TRContent.StorageBlocks.INVAR, + TRContent.StorageBlocks.INVAR.getStairsBlock(), + TRContent.StorageBlocks.INVAR.getSlabBlock(), + TRContent.StorageBlocks.INVAR.getWallBlock(), + TRContent.StorageBlocks.RAW_SILVER, + TRContent.StorageBlocks.RAW_SILVER.getStairsBlock(), + TRContent.StorageBlocks.RAW_SILVER.getSlabBlock(), + TRContent.StorageBlocks.RAW_SILVER.getWallBlock(), + TRContent.StorageBlocks.SILVER, + TRContent.StorageBlocks.SILVER.getStairsBlock(), + TRContent.StorageBlocks.SILVER.getSlabBlock(), + TRContent.StorageBlocks.SILVER.getWallBlock(), + TRContent.StorageBlocks.ELECTRUM, + TRContent.StorageBlocks.ELECTRUM.getStairsBlock(), + TRContent.StorageBlocks.ELECTRUM.getSlabBlock(), + TRContent.StorageBlocks.ELECTRUM.getWallBlock(), + TRContent.StorageBlocks.ALUMINUM, + TRContent.StorageBlocks.ALUMINUM.getStairsBlock(), + TRContent.StorageBlocks.ALUMINUM.getSlabBlock(), + TRContent.StorageBlocks.ALUMINUM.getWallBlock(), + TRContent.StorageBlocks.TITANIUM, + TRContent.StorageBlocks.TITANIUM.getStairsBlock(), + TRContent.StorageBlocks.TITANIUM.getSlabBlock(), + TRContent.StorageBlocks.TITANIUM.getWallBlock(), + TRContent.StorageBlocks.CHROME, + TRContent.StorageBlocks.CHROME.getStairsBlock(), + TRContent.StorageBlocks.CHROME.getSlabBlock(), + TRContent.StorageBlocks.CHROME.getWallBlock(), + TRContent.StorageBlocks.RUBY, + TRContent.StorageBlocks.RUBY.getStairsBlock(), + TRContent.StorageBlocks.RUBY.getSlabBlock(), + TRContent.StorageBlocks.RUBY.getWallBlock(), + TRContent.StorageBlocks.SAPPHIRE, + TRContent.StorageBlocks.SAPPHIRE.getStairsBlock(), + TRContent.StorageBlocks.SAPPHIRE.getSlabBlock(), + TRContent.StorageBlocks.SAPPHIRE.getWallBlock(), + TRContent.StorageBlocks.PERIDOT, + TRContent.StorageBlocks.PERIDOT.getStairsBlock(), + TRContent.StorageBlocks.PERIDOT.getSlabBlock(), + TRContent.StorageBlocks.PERIDOT.getWallBlock(), + TRContent.StorageBlocks.RED_GARNET, + TRContent.StorageBlocks.RED_GARNET.getStairsBlock(), + TRContent.StorageBlocks.RED_GARNET.getSlabBlock(), + TRContent.StorageBlocks.RED_GARNET.getWallBlock(), + TRContent.StorageBlocks.YELLOW_GARNET, + TRContent.StorageBlocks.YELLOW_GARNET.getStairsBlock(), + TRContent.StorageBlocks.YELLOW_GARNET.getSlabBlock(), + TRContent.StorageBlocks.YELLOW_GARNET.getWallBlock(), + TRContent.StorageBlocks.RAW_IRIDIUM, + TRContent.StorageBlocks.RAW_IRIDIUM.getStairsBlock(), + TRContent.StorageBlocks.RAW_IRIDIUM.getSlabBlock(), + TRContent.StorageBlocks.RAW_IRIDIUM.getWallBlock(), + TRContent.StorageBlocks.IRIDIUM, + TRContent.StorageBlocks.IRIDIUM.getStairsBlock(), + TRContent.StorageBlocks.IRIDIUM.getSlabBlock(), + TRContent.StorageBlocks.IRIDIUM.getWallBlock(), + TRContent.StorageBlocks.RAW_TUNGSTEN, + TRContent.StorageBlocks.RAW_TUNGSTEN.getStairsBlock(), + TRContent.StorageBlocks.RAW_TUNGSTEN.getSlabBlock(), + TRContent.StorageBlocks.RAW_TUNGSTEN.getWallBlock(), + TRContent.StorageBlocks.TUNGSTEN, + TRContent.StorageBlocks.TUNGSTEN.getStairsBlock(), + TRContent.StorageBlocks.TUNGSTEN.getSlabBlock(), + TRContent.StorageBlocks.TUNGSTEN.getWallBlock(), + TRContent.StorageBlocks.TUNGSTENSTEEL, + TRContent.StorageBlocks.TUNGSTENSTEEL.getStairsBlock(), + TRContent.StorageBlocks.TUNGSTENSTEEL.getSlabBlock(), + TRContent.StorageBlocks.TUNGSTENSTEEL.getWallBlock(), + TRContent.StorageBlocks.HOT_TUNGSTENSTEEL, + TRContent.StorageBlocks.HOT_TUNGSTENSTEEL.getStairsBlock(), + TRContent.StorageBlocks.HOT_TUNGSTENSTEEL.getSlabBlock(), + TRContent.StorageBlocks.HOT_TUNGSTENSTEEL.getWallBlock(), + TRContent.StorageBlocks.IRIDIUM_REINFORCED_STONE, + TRContent.StorageBlocks.IRIDIUM_REINFORCED_STONE.getStairsBlock(), + TRContent.StorageBlocks.IRIDIUM_REINFORCED_STONE.getSlabBlock(), + TRContent.StorageBlocks.IRIDIUM_REINFORCED_STONE.getWallBlock(), + TRContent.StorageBlocks.IRIDIUM_REINFORCED_TUNGSTENSTEEL, + TRContent.StorageBlocks.IRIDIUM_REINFORCED_TUNGSTENSTEEL.getStairsBlock(), + TRContent.StorageBlocks.IRIDIUM_REINFORCED_TUNGSTENSTEEL.getSlabBlock(), + TRContent.StorageBlocks.IRIDIUM_REINFORCED_TUNGSTENSTEEL.getWallBlock()); + } + + private static void addColoredBlocks(FabricItemGroupEntries entries) { + entries.addBefore(Items.TINTED_GLASS, TRContent.REINFORCED_GLASS); + } + + private static void addNaturalBlocks(FabricItemGroupEntries entries) { + entries.addBefore(Items.IRON_ORE, TRContent.Ores.TIN, TRContent.Ores.DEEPSLATE_TIN); + entries.addAfter(Items.DEEPSLATE_COPPER_ORE, + TRContent.Ores.LEAD, TRContent.Ores.DEEPSLATE_LEAD, + TRContent.Ores.SILVER, TRContent.Ores.DEEPSLATE_SILVER); + entries.addAfter(Items.DEEPSLATE_GOLD_ORE, + TRContent.Ores.GALENA, TRContent.Ores.DEEPSLATE_GALENA, + TRContent.Ores.BAUXITE, TRContent.Ores.DEEPSLATE_BAUXITE); + entries.addAfter(Items.DEEPSLATE_REDSTONE_ORE, + TRContent.Ores.RUBY, TRContent.Ores.DEEPSLATE_RUBY, + TRContent.Ores.SAPPHIRE, TRContent.Ores.DEEPSLATE_SAPPHIRE); + entries.addAfter(Items.DEEPSLATE_DIAMOND_ORE, TRContent.Ores.IRIDIUM, TRContent.Ores.DEEPSLATE_IRIDIUM); + entries.addAfter(Items.NETHER_GOLD_ORE, + TRContent.Ores.CINNABAR, + TRContent.Ores.PYRITE, + TRContent.Ores.SPHALERITE); + entries.addAfter(Items.ANCIENT_DEBRIS, + TRContent.Ores.PERIDOT, + TRContent.Ores.SHELDONITE, + TRContent.Ores.SODALITE, + TRContent.Ores.TUNGSTEN); + entries.addBefore(Items.RAW_IRON_BLOCK, TRContent.StorageBlocks.RAW_TIN); + entries.addAfter(Items.RAW_COPPER_BLOCK, + TRContent.StorageBlocks.RAW_LEAD, + TRContent.StorageBlocks.RAW_SILVER); + entries.addAfter(Items.RAW_GOLD_BLOCK, + TRContent.StorageBlocks.RAW_IRIDIUM, + TRContent.StorageBlocks.RAW_TUNGSTEN); + entries.addAfter(Items.MANGROVE_LOG, TRContent.RUBBER_LOG); + entries.addAfter(Items.MUDDY_MANGROVE_ROOTS, TRContent.RUBBER_LEAVES); + entries.addAfter(Items.MANGROVE_PROPAGULE, TRContent.RUBBER_SAPLING); + } + + private static void addFunctionalBlocks(FabricItemGroupEntries entries) { + entries.addAfter(Items.END_ROD, + TRContent.Machine.LAMP_INCANDESCENT, + TRContent.Machine.LAMP_LED); + entries.addBefore(Items.CRYING_OBSIDIAN, TRContent.StorageBlocks.HOT_TUNGSTENSTEEL); + entries.addAfter(Items.CRAFTING_TABLE, + TRContent.Machine.AUTO_CRAFTING_TABLE, + TRContent.Machine.BLOCK_BREAKER, + TRContent.Machine.BLOCK_PLACER); + entries.addAfter(Items.STONECUTTER, TRContent.Machine.RESIN_BASIN); + entries.addAfter(Items.SMITHING_TABLE, TRContent.Machine.ASSEMBLY_MACHINE); + entries.addAfter(Items.FURNACE, + TRContent.Machine.IRON_FURNACE, + TRContent.Machine.ELECTRIC_FURNACE); + entries.addAfter(Items.BLAST_FURNACE, + TRContent.Machine.INDUSTRIAL_BLAST_FURNACE, + TRContent.Machine.IRON_ALLOY_FURNACE, + TRContent.Machine.ALLOY_SMELTER, + TRContent.Machine.GRINDER, + TRContent.Machine.INDUSTRIAL_GRINDER, + TRContent.Machine.INDUSTRIAL_SAWMILL, + TRContent.Machine.ROLLING_MACHINE, + TRContent.Machine.VACUUM_FREEZER); + entries.addAfter(Items.SCAFFOLDING, + TRContent.Machine.ELEVATOR, + TRContent.Machine.LAUNCHPAD); + entries.addAfter(Items.COMPOSTER, + TRContent.Machine.COMPRESSOR, + TRContent.Machine.SOLID_CANNING_MACHINE, + TRContent.Machine.RECYCLER, + TRContent.Machine.SCRAPBOXINATOR, + TRContent.Machine.MATTER_FABRICATOR); + entries.addBefore(Items.BREWING_STAND, TRContent.Machine.IMPLOSION_COMPRESSOR); + entries.addBefore(Items.CAULDRON, + TRContent.Machine.EXTRACTOR, + TRContent.Machine.CHEMICAL_REACTOR, + TRContent.Machine.INDUSTRIAL_CENTRIFUGE, + TRContent.Machine.INDUSTRIAL_ELECTROLYZER, + TRContent.Machine.DISTILLATION_TOWER); + entries.addAfter(Items.CAULDRON, + TRContent.Machine.DRAIN, + TRContent.Machine.FLUID_REPLICATOR); + entries.addAfter(Items.LODESTONE, TRContent.Machine.CHUNK_LOADER); + entries.addAfter(Items.BEEHIVE, TRContent.Machine.GREENHOUSE_CONTROLLER); + entries.addAfter(Items.LIGHTNING_ROD, TRContent.Machine.LIGHTNING_ROD); + // inventory stuff + entries.addAfter(Items.ENDER_CHEST, + TRContent.StorageUnit.BUFFER, + TRContent.StorageUnit.CRUDE, + TRContent.StorageUnit.BASIC, + TRContent.StorageUnit.ADVANCED, + TRContent.StorageUnit.INDUSTRIAL, + TRContent.StorageUnit.QUANTUM, + TRContent.StorageUnit.CREATIVE, + TRContent.TankUnit.BASIC, + TRContent.TankUnit.ADVANCED, + TRContent.TankUnit.INDUSTRIAL, + TRContent.TankUnit.QUANTUM, + TRContent.TankUnit.CREATIVE); + entries.addBefore(Items.SKELETON_SKULL, + // blocks + TRContent.MachineBlocks.BASIC.getCasing(), + TRContent.MachineBlocks.ADVANCED.getCasing(), + TRContent.MachineBlocks.INDUSTRIAL.getCasing(), + TRContent.Machine.FUSION_COIL, + // generators + TRContent.Machine.SOLID_FUEL_GENERATOR, + TRContent.Machine.SEMI_FLUID_GENERATOR, + TRContent.Machine.DIESEL_GENERATOR, + TRContent.Machine.GAS_TURBINE, + TRContent.Machine.PLASMA_GENERATOR, + TRContent.Machine.THERMAL_GENERATOR, + TRContent.Machine.WATER_MILL, + TRContent.Machine.WIND_MILL, + TRContent.Machine.DRAGON_EGG_SYPHON, + TRContent.Machine.FUSION_CONTROL_COMPUTER, + // batteries & transformers + TRContent.Machine.LOW_VOLTAGE_SU, + TRContent.Machine.LV_TRANSFORMER, + TRContent.Machine.MEDIUM_VOLTAGE_SU, + TRContent.Machine.MV_TRANSFORMER, + TRContent.Machine.HIGH_VOLTAGE_SU, + TRContent.Machine.HV_TRANSFORMER, + TRContent.Machine.CHARGE_O_MAT, + TRContent.Machine.LAPOTRONIC_SU, + TRContent.Machine.LSU_STORAGE, + TRContent.Machine.ADJUSTABLE_SU, + TRContent.Machine.EV_TRANSFORMER, + TRContent.Machine.INTERDIMENSIONAL_SU, + // cables + TRContent.Cables.TIN, + TRContent.Cables.COPPER, + TRContent.Cables.INSULATED_COPPER, + TRContent.Cables.GOLD, + TRContent.Cables.INSULATED_GOLD, + TRContent.Cables.HV, + TRContent.Cables.INSULATED_HV, + TRContent.Cables.GLASSFIBER, + TRContent.Cables.SUPERCONDUCTOR, + TRContent.Machine.WIRE_MILL); + } + + private static void addRedstoneBlocks(FabricItemGroupEntries entries) { + entries.addBefore(Items.SCULK_SENSOR, TRContent.Machine.ALARM); + entries.addAfter(Items.WHITE_WOOL, TRContent.Machine.PLAYER_DETECTOR); + } + + private static void addTools(FabricItemGroupEntries entries) { + entries.addBefore(Items.GOLDEN_SHOVEL, + TRContent.BRONZE_SPADE, + TRContent.BRONZE_PICKAXE, + TRContent.BRONZE_AXE, + TRContent.BRONZE_HOE); + entries.addBefore(Items.DIAMOND_SHOVEL, + TRContent.RUBY_SPADE, + TRContent.RUBY_PICKAXE, + TRContent.RUBY_AXE, + TRContent.RUBY_HOE, + TRContent.SAPPHIRE_SPADE, + TRContent.SAPPHIRE_PICKAXE, + TRContent.SAPPHIRE_AXE, + TRContent.SAPPHIRE_HOE, + TRContent.PERIDOT_SPADE, + TRContent.PERIDOT_PICKAXE, + TRContent.PERIDOT_AXE, + TRContent.PERIDOT_HOE); + // order very important here + entries.addBefore(Items.BUCKET, TRContent.TREE_TAP); + addPoweredItem(TRContent.ELECTRIC_TREE_TAP, entries, Items.BUCKET, false); + addPoweredItem(TRContent.ROCK_CUTTER, entries, Items.BUCKET, false); + addPoweredItem(TRContent.BASIC_DRILL, entries, Items.BUCKET, false); + addPoweredItem(TRContent.ADVANCED_DRILL, entries, Items.BUCKET, false); + addPoweredItem(TRContent.INDUSTRIAL_DRILL, entries, Items.BUCKET, false); + addPoweredItem(TRContent.BASIC_JACKHAMMER, entries, Items.BUCKET, false); + addPoweredItem(TRContent.ADVANCED_JACKHAMMER, entries, Items.BUCKET, false); + addPoweredItem(TRContent.INDUSTRIAL_JACKHAMMER, entries, Items.BUCKET, false); + addPoweredItem(TRContent.BASIC_CHAINSAW, entries, Items.BUCKET, false); + addPoweredItem(TRContent.ADVANCED_CHAINSAW, entries, Items.BUCKET, false); + addPoweredItem(TRContent.INDUSTRIAL_CHAINSAW, entries, Items.BUCKET, false); + addPoweredItem(TRContent.OMNI_TOOL, entries, Items.BUCKET, false); + entries.addBefore(Items.BUCKET, TRContent.CELL); + addPoweredItem(TRContent.RED_CELL_BATTERY, entries, Items.OAK_BOAT, false); + addPoweredItem(TRContent.LITHIUM_ION_BATTERY, entries, Items.OAK_BOAT, false); + addPoweredItem(TRContent.LITHIUM_ION_BATPACK, entries, Items.OAK_BOAT, false); + addPoweredItem(TRContent.ENERGY_CRYSTAL, entries, Items.OAK_BOAT, false); + addPoweredItem(TRContent.LAPOTRON_CRYSTAL, entries, Items.OAK_BOAT, false); + addPoweredItem(TRContent.LAPOTRONIC_ORB, entries, Items.OAK_BOAT, false); + addPoweredItem(TRContent.LAPOTRONIC_ORBPACK, entries, Items.OAK_BOAT, false); + // now order not important again + entries.addBefore(Items.SHEARS, + TRContent.SCRAP_BOX, + TRContent.Plates.WOOD, + TRContent.PAINTING_TOOL); + entries.addAfter(Items.RECOVERY_COMPASS, TRContent.GPS); + entries.addAfter(Items.SPYGLASS, TRContent.WRENCH); + } + + private static void addCombat(FabricItemGroupEntries entries) { + addNanosaber(entries, Items.WOODEN_AXE, true); + entries.addAfter(Items.IRON_BOOTS, + TRContent.STEEL_HELMET, + TRContent.STEEL_CHESTPLATE, + TRContent.STEEL_LEGGINGS, + TRContent.STEEL_BOOTS, + TRContent.BRONZE_HELMET, + TRContent.BRONZE_CHESTPLATE, + TRContent.BRONZE_LEGGINGS, + TRContent.BRONZE_BOOTS); + entries.addBefore(Items.GOLDEN_HELMET, + TRContent.SILVER_HELMET, + TRContent.SILVER_CHESTPLATE, + TRContent.SILVER_LEGGINGS, + TRContent.SILVER_BOOTS); + entries.addBefore(Items.DIAMOND_HELMET, + TRContent.RUBY_HELMET, + TRContent.RUBY_CHESTPLATE, + TRContent.RUBY_LEGGINGS, + TRContent.RUBY_BOOTS, + TRContent.SAPPHIRE_HELMET, + TRContent.SAPPHIRE_CHESTPLATE, + TRContent.SAPPHIRE_LEGGINGS, + TRContent.SAPPHIRE_BOOTS, + TRContent.PERIDOT_HELMET, + TRContent.PERIDOT_CHESTPLATE, + TRContent.PERIDOT_LEGGINGS, + TRContent.PERIDOT_BOOTS); + addPoweredItem(TRContent.QUANTUM_HELMET, entries, Items.TURTLE_HELMET, false); + addPoweredItem(TRContent.QUANTUM_CHESTPLATE, entries, Items.TURTLE_HELMET, false); + addPoweredItem(TRContent.QUANTUM_LEGGINGS, entries, Items.TURTLE_HELMET, false); + addPoweredItem(TRContent.QUANTUM_BOOTS, entries, Items.TURTLE_HELMET, false); + addPoweredItem(TRContent.CLOAKING_DEVICE, entries, Items.LEATHER_HORSE_ARMOR, false); + entries.addAfter(Items.END_CRYSTAL, TRContent.NUKE); + } + + private static void addIngredients(FabricItemGroupEntries entries) { + // raw / gem + entries.addBefore(Items.RAW_IRON, TRContent.RawMetals.TIN); + entries.addAfter(Items.RAW_COPPER, + TRContent.RawMetals.LEAD, + TRContent.RawMetals.SILVER); + entries.addBefore(Items.EMERALD, + TRContent.Gems.RUBY, + TRContent.Gems.SAPPHIRE, + TRContent.Gems.PERIDOT, + TRContent.Gems.RED_GARNET, + TRContent.Gems.YELLOW_GARNET); + entries.addAfter(Items.DIAMOND, + TRContent.RawMetals.IRIDIUM, + TRContent.RawMetals.TUNGSTEN); + // nuggets + entries.addBefore(Items.IRON_NUGGET, + TRContent.Nuggets.TIN, + TRContent.Nuggets.ZINC); + entries.addAfter(Items.IRON_NUGGET, + TRContent.Nuggets.REFINED_IRON, + TRContent.Nuggets.STEEL, + TRContent.Nuggets.COPPER, + TRContent.Nuggets.LEAD, + TRContent.Nuggets.NICKEL, + TRContent.Nuggets.BRONZE, + TRContent.Nuggets.BRASS, + TRContent.Nuggets.INVAR); + entries.addBefore(Items.GOLD_NUGGET, TRContent.Nuggets.SILVER); + entries.addAfter(Items.GOLD_NUGGET, + TRContent.Nuggets.ELECTRUM, + TRContent.Nuggets.ALUMINUM, + TRContent.Nuggets.TITANIUM, + TRContent.Nuggets.CHROME, + TRContent.Nuggets.EMERALD, + TRContent.Nuggets.DIAMOND, + TRContent.Nuggets.IRIDIUM, + TRContent.Nuggets.TUNGSTEN, + TRContent.Nuggets.NETHERITE); + // ingots + entries.addBefore(Items.IRON_INGOT, + TRContent.Ingots.TIN, + TRContent.Ingots.ZINC); + entries.addAfter(Items.IRON_INGOT, + TRContent.Ingots.REFINED_IRON, + TRContent.Ingots.STEEL); + entries.addAfter(Items.COPPER_INGOT, + TRContent.Ingots.LEAD, + TRContent.Ingots.NICKEL, + TRContent.Ingots.BRONZE, + TRContent.Ingots.BRASS, + TRContent.Ingots.MIXED_METAL, + TRContent.Ingots.ADVANCED_ALLOY, + TRContent.Ingots.INVAR); + entries.addBefore(Items.GOLD_INGOT, TRContent.Ingots.SILVER); + entries.addAfter(Items.GOLD_INGOT, + TRContent.Ingots.ELECTRUM, + TRContent.Ingots.ALUMINUM, + TRContent.Ingots.TITANIUM, + TRContent.Ingots.CHROME, + TRContent.Ingots.IRIDIUM, + TRContent.Ingots.IRIDIUM_ALLOY, + TRContent.Ingots.TUNGSTEN, + TRContent.Ingots.TUNGSTENSTEEL, + TRContent.Ingots.HOT_TUNGSTENSTEEL); + // dusts and small dusts + // misc + entries.addAfter(Items.STICK, + TRContent.Parts.PLANTBALL, + TRContent.Parts.COMPRESSED_PLANTBALL); + entries.addAfter(Items.HONEYCOMB, + TRContent.Parts.SAP, + TRContent.Parts.RUBBER, + TRContent.Parts.SCRAP); + entries.addBefore(Items.PRISMARINE_SHARD, TRContent.Parts.SPONGE_PIECE); + entries.addBefore(Items.BRICK, + TRContent.Parts.CARBON_FIBER, + TRContent.Parts.CARBON_MESH); + entries.addBefore(Items.NETHER_STAR, TRContent.Parts.SYNTHETIC_REDSTONE_CRYSTAL); + entries.addAfter(Items.NETHERITE_INGOT, TRContent.Parts.UU_MATTER); + // machine parts + entries.addAfter(Items.NETHER_BRICK, + TRContent.Parts.ELECTRONIC_CIRCUIT, + TRContent.Parts.ADVANCED_CIRCUIT, + TRContent.Parts.INDUSTRIAL_CIRCUIT, + TRContent.Parts.DATA_STORAGE_CORE, + TRContent.Parts.DATA_STORAGE_CHIP, + TRContent.Parts.ENERGY_FLOW_CHIP, + TRContent.Parts.SUPERCONDUCTOR, + TRContent.Parts.CUPRONICKEL_HEATING_COIL, + TRContent.Parts.NICHROME_HEATING_COIL, + TRContent.Parts.KANTHAL_HEATING_COIL, + TRContent.Parts.NEUTRON_REFLECTOR, + TRContent.Parts.THICK_NEUTRON_REFLECTOR, + TRContent.Parts.IRIDIUM_NEUTRON_REFLECTOR, + TRContent.Parts.DIAMOND_SAW_BLADE, + TRContent.Parts.DIAMOND_GRINDING_HEAD, + TRContent.Parts.TUNGSTEN_GRINDING_HEAD); + entries.addBefore(Items.FIREWORK_STAR, + TRContent.Parts.BASIC_DISPLAY, + TRContent.Parts.DIGITAL_DISPLAY); + // cell-parts + entries.addAfter(Items.PHANTOM_MEMBRANE, + TRContent.Parts.WATER_COOLANT_CELL_10K, + TRContent.Parts.WATER_COOLANT_CELL_30K, + TRContent.Parts.WATER_COOLANT_CELL_60K, + TRContent.Parts.NAK_COOLANT_CELL_60K, + TRContent.Parts.NAK_COOLANT_CELL_180K, + TRContent.Parts.NAK_COOLANT_CELL_360K, + TRContent.Parts.HELIUM_COOLANT_CELL_60K, + TRContent.Parts.HELIUM_COOLANT_CELL_180K, + TRContent.Parts.HELIUM_COOLANT_CELL_360K); + } + + private static void addContent(ItemConvertible[] items, FabricItemGroupEntries entries) { + for (ItemConvertible item : items) { + entries.add(item); + } + } + + private static void addCells(FabricItemGroupEntries entries) { + entries.add(DynamicCellItem.getEmptyCell(1)); + for (Fluid fluid : FluidUtils.getAllFluids()) { + if (fluid.isStill(fluid.getDefaultState())) { + entries.add(DynamicCellItem.getCellWithFluid(fluid)); + } + } + } + + private static void addPoweredItem(Item item, FabricItemGroupEntries entries, ItemConvertible before, boolean includeUncharged) { + ItemStack uncharged = new ItemStack(item); + ItemStack charged = new ItemStack(item); + RcEnergyItem energyItem = (RcEnergyItem) item; + + energyItem.setStoredEnergy(charged, energyItem.getEnergyCapacity()); + + if (before == null) { + if (includeUncharged) { + entries.add(uncharged); + } + entries.add(charged); + } + else { + if (includeUncharged) { + entries.addBefore(before, uncharged, charged); + } + else { + entries.addBefore(before, charged); + } + } + } + + private static void addRockCutter(FabricItemGroupEntries entries, ItemConvertible before, boolean includeUncharged) { + RockCutterItem rockCutter = (RockCutterItem) TRContent.ROCK_CUTTER; + + ItemStack uncharged = new ItemStack(rockCutter); + uncharged.addEnchantment(Enchantments.SILK_TOUCH, 1); + ItemStack charged = new ItemStack(rockCutter); + charged.addEnchantment(Enchantments.SILK_TOUCH, 1); + rockCutter.setStoredEnergy(charged, rockCutter.getEnergyCapacity()); + + if (before == null) { + if (includeUncharged) { + entries.add(uncharged); + } + entries.add(charged); + } + else { + if (includeUncharged) { + entries.addBefore(before, uncharged, charged); + } + else { + entries.addBefore(before, charged); + } + } + } + + private static void addNanosaber(FabricItemGroupEntries entries, ItemConvertible before, boolean onlyPoweredAndActive) { + NanosaberItem nanosaber = (NanosaberItem) TRContent.NANOSABER; + + ItemStack inactiveUncharged = new ItemStack(nanosaber); + inactiveUncharged.setNbt(new NbtCompound()); + inactiveUncharged.getOrCreateNbt().putBoolean("isActive", false); + + ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER); + inactiveCharged.setNbt(new NbtCompound()); + inactiveCharged.getOrCreateNbt().putBoolean("isActive", false); + nanosaber.setStoredEnergy(inactiveCharged, nanosaber.getEnergyCapacity()); + + ItemStack activeCharged = new ItemStack(TRContent.NANOSABER); + activeCharged.setNbt(new NbtCompound()); + activeCharged.getOrCreateNbt().putBoolean("isActive", true); + nanosaber.setStoredEnergy(activeCharged, nanosaber.getEnergyCapacity()); + + if (before == null) { + if (!onlyPoweredAndActive) { + entries.add(inactiveUncharged); + entries.add(inactiveCharged); + } + entries.add(activeCharged); + } + else { + if (!onlyPoweredAndActive) { + entries.addBefore(before, inactiveUncharged, inactiveCharged, activeCharged); + } + else { + entries.addBefore(before, activeCharged); + } + } + } +} diff --git a/src/main/java/techreborn/init/TRVillager.java b/src/main/java/techreborn/init/TRVillager.java index c2d26aea0..f92710b42 100644 --- a/src/main/java/techreborn/init/TRVillager.java +++ b/src/main/java/techreborn/init/TRVillager.java @@ -1,22 +1,27 @@ package techreborn.init; +import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; import net.fabricmc.fabric.api.object.builder.v1.villager.VillagerProfessionBuilder; import net.fabricmc.fabric.api.object.builder.v1.world.poi.PointOfInterestHelper; import net.minecraft.item.Items; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; import net.minecraft.sound.SoundEvents; +import net.minecraft.structure.pool.StructurePool; +import net.minecraft.structure.pool.StructurePoolElement; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.village.TradeOffer; import net.minecraft.village.VillagerProfession; import net.minecraft.world.poi.PointOfInterestType; import reborncore.common.util.TradeUtils; import techreborn.TechReborn; +import techreborn.config.TechRebornConfig; import java.util.LinkedList; import java.util.List; -import java.util.stream.Collectors; public class TRVillager { @@ -30,18 +35,18 @@ public class TRVillager { ELECTRICIAN_ID, 1, 1, TRContent.Machine.SOLID_FUEL_GENERATOR.block ); - public static final VillagerProfession METALLURGIST_PROFESSION = Registry.register(Registry.VILLAGER_PROFESSION, METALLURGIST_ID, + public static final VillagerProfession METALLURGIST_PROFESSION = Registry.register(Registries.VILLAGER_PROFESSION, METALLURGIST_ID, VillagerProfessionBuilder.create() .id(METALLURGIST_ID) - .workstation(RegistryKey.of(Registry.POINT_OF_INTEREST_TYPE_KEY, METALLURGIST_ID)) + .workstation(RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE, METALLURGIST_ID)) .workSound(SoundEvents.ENTITY_VILLAGER_WORK_TOOLSMITH) .build() ); - public static final VillagerProfession ELECTRICIAN_PROFESSION = Registry.register(Registry.VILLAGER_PROFESSION, ELECTRICIAN_ID, + public static final VillagerProfession ELECTRICIAN_PROFESSION = Registry.register(Registries.VILLAGER_PROFESSION, ELECTRICIAN_ID, VillagerProfessionBuilder.create() .id(ELECTRICIAN_ID) - .workstation(RegistryKey.of(Registry.POINT_OF_INTEREST_TYPE_KEY, ELECTRICIAN_ID)) + .workstation(RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE, ELECTRICIAN_ID)) .workSound(ModSounds.CABLE_SHOCK) .build() ); @@ -105,10 +110,28 @@ public class TRVillager { extraCommonTrades.add(TradeUtils.createSell(TRContent.RUBBER_SAPLING, 5, 1, 8, 1)); // registration of the trades, no changes necessary for new trades TradeOfferHelper.registerWanderingTraderOffers(1, allTradesList -> allTradesList.addAll( - extraCommonTrades.stream().map(TradeUtils::asFactory).collect(Collectors.toList()) + extraCommonTrades.stream().map(TradeUtils::asFactory).toList() )); TradeOfferHelper.registerWanderingTraderOffers(2, allTradesList -> allTradesList.addAll( - extraRareTrades.stream().map(TradeUtils::asFactory).collect(Collectors.toList()) + extraRareTrades.stream().map(TradeUtils::asFactory).toList() )); } + + public static void registerVillagerHouses() { + final String[] types = new String[] {"desert", "plains", "savanna", "snowy", "taiga"}; + for (String type : types) { + DynamicRegistrySetupCallback.EVENT.register(registryManager -> + registryManager.registerEntryAdded(RegistryKeys.TEMPLATE_POOL, ((rawId, id, pool) -> { + if (id.equals(new Identifier("minecraft", "village/"+type+"/houses"))) { + if (TechRebornConfig.enableMetallurgistGeneration) { + pool.elements.add(StructurePoolElement.ofSingle(TechReborn.MOD_ID + ":village/" + type + "/houses/" + type + "_metallurgist").apply(StructurePool.Projection.RIGID)); + } + if (TechRebornConfig.enableElectricianGeneration) { + pool.elements.add(StructurePoolElement.ofSingle(TechReborn.MOD_ID + ":village/" + type + "/houses/" + type + "_electrician").apply(StructurePool.Projection.RIGID)); + } + } + })) + ); + } + } } diff --git a/src/main/java/techreborn/init/template/TemplateProcessor.java b/src/main/java/techreborn/init/template/TemplateProcessor.java index 9bab453bb..da719b74d 100644 --- a/src/main/java/techreborn/init/template/TemplateProcessor.java +++ b/src/main/java/techreborn/init/template/TemplateProcessor.java @@ -24,9 +24,13 @@ package techreborn.init.template; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import net.minecraft.block.Block; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registries; import java.io.FileNotFoundException; import java.io.IOException; @@ -51,7 +55,7 @@ public class TemplateProcessor { public void processSimpleBlocks(String template, List blocks) throws IOException { for (Block block : blocks) { Map values = new HashMap<>(); - values.put("name", Registry.BLOCK.getId(block).getPath()); + values.put("name", Registries.BLOCK.getId(block).getPath()); process(template, values); } diff --git a/src/main/java/techreborn/items/BatteryItem.java b/src/main/java/techreborn/items/BatteryItem.java index e4053f5ca..1b45b10b7 100644 --- a/src/main/java/techreborn/items/BatteryItem.java +++ b/src/main/java/techreborn/items/BatteryItem.java @@ -28,20 +28,16 @@ import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; -import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; -import techreborn.utils.InitUtils; import java.util.List; @@ -51,7 +47,7 @@ public class BatteryItem extends Item implements RcEnergyItem { private final RcEnergyTier tier; public BatteryItem(int maxEnergy, RcEnergyTier tier) { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1)); + super(new Item.Settings().maxCount(1)); this.maxEnergy = maxEnergy; this.tier = tier; } @@ -86,14 +82,6 @@ public class BatteryItem extends Item implements RcEnergyItem { ItemUtils.buildActiveTooltip(stack, tooltip); } - @Override - public void appendStacks(ItemGroup group, DefaultedList stacks) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, stacks); - } - // EnergyHolder @Override public long getEnergyCapacity() { diff --git a/src/main/java/techreborn/items/DynamicCellItem.java b/src/main/java/techreborn/items/DynamicCellItem.java index 36400a329..78e9e226c 100644 --- a/src/main/java/techreborn/items/DynamicCellItem.java +++ b/src/main/java/techreborn/items/DynamicCellItem.java @@ -40,25 +40,23 @@ import net.minecraft.fluid.FlowableFluid; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsage; import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.Registries; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; -import net.minecraft.tag.FluidTags; import net.minecraft.text.Text; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.TypedActionResult; -import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; import net.minecraft.world.RaycastContext; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; @@ -68,7 +66,6 @@ import org.jetbrains.annotations.Nullable; import reborncore.common.fluid.FluidUtils; import reborncore.common.fluid.container.ItemFluidInfo; import reborncore.common.util.ItemNBTHelper; -import techreborn.TechReborn; import techreborn.init.TRContent; /** @@ -77,7 +74,7 @@ import techreborn.init.TRContent; public class DynamicCellItem extends Item implements ItemFluidInfo { public DynamicCellItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(16)); + super(new Item.Settings().maxCount(16)); } // Thanks vanilla :) @@ -90,7 +87,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) { Validate.notNull(fluid); ItemStack stack = new ItemStack(TRContent.CELL); - ItemNBTHelper.getNBT(stack).putString("fluid", Registry.FLUID.getId(fluid).toString()); + ItemNBTHelper.getNBT(stack).putString("fluid", Registries.FLUID.getId(fluid).toString()); stack.setCount(stackSize); return stack; } @@ -148,19 +145,6 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { } } - @Override - public void appendStacks(ItemGroup tab, DefaultedList subItems) { - if (!isIn(tab)) { - return; - } - subItems.add(getEmptyCell(1)); - for (Fluid fluid : FluidUtils.getAllFluids()) { - if (fluid.isStill(fluid.getDefaultState())) { - subItems.add(getCellWithFluid(fluid)); - } - } - } - @Override public Text getName(ItemStack itemStack) { Fluid fluid = getFluid(itemStack); @@ -253,7 +237,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { private Fluid getFluid(@Nullable NbtCompound tag) { if (tag != null && tag.contains("fluid")) { - return Registry.FLUID.get(new Identifier(tag.getString("fluid"))); + return Registries.FLUID.get(new Identifier(tag.getString("fluid"))); } return Fluids.EMPTY; } diff --git a/src/main/java/techreborn/items/FrequencyTransmitterItem.java b/src/main/java/techreborn/items/FrequencyTransmitterItem.java index dc832b309..b56aa7c43 100644 --- a/src/main/java/techreborn/items/FrequencyTransmitterItem.java +++ b/src/main/java/techreborn/items/FrequencyTransmitterItem.java @@ -30,16 +30,19 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; import net.minecraft.nbt.NbtOps; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; -import net.minecraft.util.*; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Formatting; +import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; +import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.GlobalPos; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import reborncore.common.chunkloading.ChunkLoaderManager; -import techreborn.TechReborn; import java.util.List; import java.util.Optional; @@ -47,7 +50,7 @@ import java.util.Optional; public class FrequencyTransmitterItem extends Item { public FrequencyTransmitterItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1)); + super(new Item.Settings().maxCount(1)); } @Override diff --git a/src/main/java/techreborn/items/GpsItem.java b/src/main/java/techreborn/items/GpsItem.java index 7d6663347..c10682398 100644 --- a/src/main/java/techreborn/items/GpsItem.java +++ b/src/main/java/techreborn/items/GpsItem.java @@ -35,12 +35,11 @@ import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import techreborn.TechReborn; public class GpsItem extends Item { public GpsItem() { - super(new Settings().group(TechReborn.ITEMGROUP)); + super(new Settings()); } @Override diff --git a/src/main/java/techreborn/items/ManualItem.java b/src/main/java/techreborn/items/ManualItem.java index be87c74a8..60ff6037d 100644 --- a/src/main/java/techreborn/items/ManualItem.java +++ b/src/main/java/techreborn/items/ManualItem.java @@ -33,13 +33,12 @@ import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import reborncore.common.network.NetworkManager; -import techreborn.TechReborn; import techreborn.packets.ClientboundPackets; public class ManualItem extends Item { public ManualItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1)); + super(new Item.Settings().maxCount(1)); } @Override diff --git a/src/main/java/techreborn/items/ScrapBoxItem.java b/src/main/java/techreborn/items/ScrapBoxItem.java index bb0f966b8..419b0418c 100644 --- a/src/main/java/techreborn/items/ScrapBoxItem.java +++ b/src/main/java/techreborn/items/ScrapBoxItem.java @@ -41,7 +41,7 @@ import java.util.List; public class ScrapBoxItem extends Item { public ScrapBoxItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP)); + super(new Item.Settings()); } @Override diff --git a/src/main/java/techreborn/items/UpgradeItem.java b/src/main/java/techreborn/items/UpgradeItem.java index 93b94d61c..b84a051e0 100644 --- a/src/main/java/techreborn/items/UpgradeItem.java +++ b/src/main/java/techreborn/items/UpgradeItem.java @@ -39,7 +39,7 @@ public class UpgradeItem extends Item implements IUpgrade { public final IUpgrade behavior; public UpgradeItem(String name, IUpgrade process) { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(16)); + super(new Item.Settings().maxCount(16)); this.name = name; this.behavior = process; } diff --git a/src/main/java/techreborn/items/UpgraderItem.java b/src/main/java/techreborn/items/UpgraderItem.java index ea94cb03f..0cabf2807 100644 --- a/src/main/java/techreborn/items/UpgraderItem.java +++ b/src/main/java/techreborn/items/UpgraderItem.java @@ -10,7 +10,6 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.blockentity.MachineBaseBlockEntity; -import techreborn.TechReborn; import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity; import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity; import techreborn.init.TRContent.StorageUnit; @@ -19,7 +18,7 @@ import techreborn.init.TRContent.TankUnit; public class UpgraderItem extends Item { public UpgraderItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP)); + super(new Item.Settings()); } @Override diff --git a/src/main/java/techreborn/items/armor/BatpackItem.java b/src/main/java/techreborn/items/armor/BatpackItem.java index fc3db1992..bd363baea 100644 --- a/src/main/java/techreborn/items/armor/BatpackItem.java +++ b/src/main/java/techreborn/items/armor/BatpackItem.java @@ -36,7 +36,6 @@ import net.minecraft.world.World; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; import techreborn.utils.InitUtils; public class BatpackItem extends ArmorItem implements RcEnergyItem { @@ -45,7 +44,7 @@ public class BatpackItem extends ArmorItem implements RcEnergyItem { public final RcEnergyTier tier; public BatpackItem(int maxCharge, ArmorMaterial material, RcEnergyTier tier) { - super(material, EquipmentSlot.CHEST, new Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(material, EquipmentSlot.CHEST, new Settings().maxCount(1).maxDamage(-1)); this.maxCharge = maxCharge; this.tier = tier; } @@ -71,14 +70,6 @@ public class BatpackItem extends ArmorItem implements RcEnergyItem { return true; } - @Override - public void appendStacks(ItemGroup group, DefaultedList itemList) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, itemList); - } - // EnergyHolder @Override public long getEnergyCapacity() { diff --git a/src/main/java/techreborn/items/armor/CloakingDeviceItem.java b/src/main/java/techreborn/items/armor/CloakingDeviceItem.java index afa6f7997..b429cfdef 100644 --- a/src/main/java/techreborn/items/armor/CloakingDeviceItem.java +++ b/src/main/java/techreborn/items/armor/CloakingDeviceItem.java @@ -48,7 +48,7 @@ public class CloakingDeviceItem extends TRArmourItem implements RcEnergyItem, Ar // 40M FE capacity with 10k FE\t charge rate public CloakingDeviceItem() { - super(TRArmorMaterials.CLOAKING_DEVICE, EquipmentSlot.CHEST, new Item.Settings().group(TechReborn.ITEMGROUP).maxDamage(-1).maxCount(1)); + super(TRArmorMaterials.CLOAKING_DEVICE, EquipmentSlot.CHEST, new Item.Settings().maxDamage(-1).maxCount(1)); } @Override @@ -77,15 +77,6 @@ public class CloakingDeviceItem extends TRArmourItem implements RcEnergyItem, Ar return ItemUtils.getColorForDurabilityBar(stack); } - // Item - @Override - public void appendStacks(ItemGroup group, DefaultedList itemList) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, itemList); - } - // EnergyHolder @Override public long getEnergyCapacity() { diff --git a/src/main/java/techreborn/items/armor/QuantumSuitItem.java b/src/main/java/techreborn/items/armor/QuantumSuitItem.java index 1d29d02f3..38c8bc5f0 100644 --- a/src/main/java/techreborn/items/armor/QuantumSuitItem.java +++ b/src/main/java/techreborn/items/armor/QuantumSuitItem.java @@ -37,17 +37,13 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ArmorMaterial; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.collection.DefaultedList; import reborncore.api.items.ArmorBlockEntityTicker; import reborncore.api.items.ArmorRemoveHandler; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; import techreborn.config.TechRebornConfig; -import techreborn.utils.InitUtils; public class QuantumSuitItem extends TRArmourItem implements ArmorBlockEntityTicker, ArmorRemoveHandler, RcEnergyItem { @@ -62,7 +58,7 @@ public class QuantumSuitItem extends TRArmourItem implements ArmorBlockEntityTic public QuantumSuitItem(ArmorMaterial material, EquipmentSlot slot) { - super(material, slot, new Item.Settings().group(TechReborn.ITEMGROUP).maxDamage(-1).maxCount(1)); + super(material, slot, new Item.Settings().maxDamage(-1).maxCount(1)); } @Override @@ -178,12 +174,4 @@ public class QuantumSuitItem extends TRArmourItem implements ArmorBlockEntityTic public RcEnergyTier getTier() { return RcEnergyTier.EXTREME; } - - @Override - public void appendStacks(ItemGroup group, DefaultedList itemList) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, itemList); - } } diff --git a/src/main/java/techreborn/items/armor/TRArmourItem.java b/src/main/java/techreborn/items/armor/TRArmourItem.java index ce2cb5456..bf4e5c38a 100644 --- a/src/main/java/techreborn/items/armor/TRArmourItem.java +++ b/src/main/java/techreborn/items/armor/TRArmourItem.java @@ -28,7 +28,6 @@ import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ArmorItem; import net.minecraft.item.ArmorMaterial; import net.minecraft.item.Item; -import techreborn.TechReborn; import java.util.UUID; @@ -46,7 +45,7 @@ public class TRArmourItem extends ArmorItem { }; public TRArmourItem(ArmorMaterial material, EquipmentSlot slot) { - this(material, slot, new Item.Settings().group(TechReborn.ITEMGROUP)); + this(material, slot, new Item.Settings()); } public TRArmourItem(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) { diff --git a/src/main/java/techreborn/items/tool/ChainsawItem.java b/src/main/java/techreborn/items/tool/ChainsawItem.java index 78b57adc9..0a31c4e9e 100644 --- a/src/main/java/techreborn/items/tool/ChainsawItem.java +++ b/src/main/java/techreborn/items/tool/ChainsawItem.java @@ -28,16 +28,16 @@ import net.minecraft.block.BlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.LivingEntity; -import net.minecraft.item.*; -import net.minecraft.tag.BlockTags; -import net.minecraft.util.collection.DefaultedList; +import net.minecraft.item.AxeItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ToolMaterial; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; -import techreborn.utils.InitUtils; public class ChainsawItem extends AxeItem implements RcEnergyItem { @@ -50,7 +50,7 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem { public ChainsawItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, Item referenceTool) { // combat stats same as for diamond axe. Fix for #2468 - super(material, 5.0F, -3.0F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(material, 5.0F, -3.0F, new Item.Settings().maxCount(1).maxDamage(-1)); this.maxCharge = energyCapacity; this.tier = tier; this.cost = cost; @@ -112,14 +112,6 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem { return true; } - @Override - public void appendStacks(ItemGroup group, DefaultedList stacks) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, stacks); - } - @Override public int getItemBarStep(ItemStack stack) { return ItemUtils.getPowerForDurabilityBar(stack); diff --git a/src/main/java/techreborn/items/tool/DebugToolItem.java b/src/main/java/techreborn/items/tool/DebugToolItem.java index cffb977f9..f490fd8f0 100644 --- a/src/main/java/techreborn/items/tool/DebugToolItem.java +++ b/src/main/java/techreborn/items/tool/DebugToolItem.java @@ -30,16 +30,15 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.command.BlockDataObject; import net.minecraft.item.Item; import net.minecraft.item.ItemUsageContext; +import net.minecraft.registry.Registries; import net.minecraft.state.property.Property; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import net.minecraft.util.Util; -import net.minecraft.util.registry.Registry; import reborncore.common.powerSystem.PowerSystem; import team.reborn.energy.api.EnergyStorage; -import techreborn.TechReborn; import java.util.Map.Entry; @@ -49,7 +48,7 @@ import java.util.Map.Entry; public class DebugToolItem extends Item { public DebugToolItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP)); + super(new Item.Settings()); } @Override @@ -109,7 +108,7 @@ public class DebugToolItem extends Item { String s = "" + Formatting.GREEN; s += "Block Registry Name: "; s += Formatting.BLUE; - s += Registry.BLOCK.getId(block); + s += Registries.BLOCK.getId(block); return s; } diff --git a/src/main/java/techreborn/items/tool/DrillItem.java b/src/main/java/techreborn/items/tool/DrillItem.java index c48ba204a..fd288b108 100644 --- a/src/main/java/techreborn/items/tool/DrillItem.java +++ b/src/main/java/techreborn/items/tool/DrillItem.java @@ -29,20 +29,16 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.MiningToolItem; import net.minecraft.item.ToolMaterial; -import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; import techreborn.init.TRContent; -import techreborn.utils.InitUtils; public class DrillItem extends MiningToolItem implements RcEnergyItem { public final int maxCharge; @@ -54,7 +50,7 @@ public class DrillItem extends MiningToolItem implements RcEnergyItem { public DrillItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) { // combat stats same as for diamond pickaxe. Fix for #2468 - super(1, -2.8F, material, TRContent.BlockTags.DRILL_MINEABLE, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(1, -2.8F, material, TRContent.BlockTags.DRILL_MINEABLE, new Item.Settings().maxCount(1).maxDamage(-1)); this.maxCharge = energyCapacity; this.cost = cost; this.poweredSpeed = poweredSpeed; @@ -125,14 +121,6 @@ public class DrillItem extends MiningToolItem implements RcEnergyItem { return true; } - @Override - public void appendStacks(ItemGroup group, DefaultedList stacks) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, stacks); - } - @Override public int getItemBarStep(ItemStack stack) { return ItemUtils.getPowerForDurabilityBar(stack); diff --git a/src/main/java/techreborn/items/tool/JackhammerItem.java b/src/main/java/techreborn/items/tool/JackhammerItem.java index 5e2027d39..6b95ebe43 100644 --- a/src/main/java/techreborn/items/tool/JackhammerItem.java +++ b/src/main/java/techreborn/items/tool/JackhammerItem.java @@ -48,7 +48,7 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem { public JackhammerItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost) { // combat stats same as for diamond pickaxe. Fix for #2468 - super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(material, 1, -2.8F, new Item.Settings().maxCount(1).maxDamage(-1)); this.maxCharge = energyCapacity; this.tier = tier; this.cost = cost; @@ -111,14 +111,6 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem { return true; } - @Override - public void appendStacks(ItemGroup group, DefaultedList stacks) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, stacks); - } - // EnergyHolder @Override public long getEnergyCapacity() { diff --git a/src/main/java/techreborn/items/tool/PaintingToolItem.java b/src/main/java/techreborn/items/tool/PaintingToolItem.java index 0e7f95724..ba1a85dca 100644 --- a/src/main/java/techreborn/items/tool/PaintingToolItem.java +++ b/src/main/java/techreborn/items/tool/PaintingToolItem.java @@ -39,6 +39,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; +import reborncore.common.util.WorldUtils; import techreborn.TechReborn; import techreborn.blockentity.cable.CableBlockEntity; import techreborn.blocks.cable.CableBlock; @@ -49,7 +50,7 @@ import java.util.List; public class PaintingToolItem extends Item { public PaintingToolItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamageIfAbsent(64)); + super(new Item.Settings().maxCount(1).maxDamageIfAbsent(64)); } public ActionResult useOnBlock(ItemUsageContext context) { @@ -69,7 +70,7 @@ public class PaintingToolItem extends Item { } return ActionResult.FAIL; } else { - BlockState cover = getCover(context.getStack()); + BlockState cover = getCover(context.getWorld(), context.getStack()); if (cover != null && blockState.getBlock() instanceof CableBlock && blockState.get(CableBlock.COVERED)) { BlockEntity blockEntity = context.getWorld().getBlockEntity(context.getBlockPos()); if (blockEntity == null) { @@ -89,15 +90,15 @@ public class PaintingToolItem extends Item { return ActionResult.FAIL; } - public static BlockState getCover(ItemStack stack) { + public static BlockState getCover(World world, ItemStack stack) { if (stack.hasNbt() && stack.getOrCreateNbt().contains("cover")) { - return NbtHelper.toBlockState(stack.getOrCreateNbt().getCompound("cover")); + return NbtHelper.toBlockState(WorldUtils.getBlockRegistryWrapper(world), stack.getOrCreateNbt().getCompound("cover")); } return null; } public void appendTooltip(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context) { - BlockState blockState = getCover(stack); + BlockState blockState = getCover(world, stack); if (blockState != null) { tooltip.add((Text.translatable(blockState.getBlock().getTranslationKey())).formatted(Formatting.GRAY)); tooltip.add((Text.translatable("techreborn.tooltip.painting_tool.apply")).formatted(Formatting.GOLD)); diff --git a/src/main/java/techreborn/items/tool/TreeTapItem.java b/src/main/java/techreborn/items/tool/TreeTapItem.java index 755c07d46..4681b4123 100644 --- a/src/main/java/techreborn/items/tool/TreeTapItem.java +++ b/src/main/java/techreborn/items/tool/TreeTapItem.java @@ -25,11 +25,10 @@ package techreborn.items.tool; import net.minecraft.item.Item; -import techreborn.TechReborn; public class TreeTapItem extends Item { public TreeTapItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamageIfAbsent(20)); + super(new Item.Settings().maxCount(1).maxDamageIfAbsent(20)); } } diff --git a/src/main/java/techreborn/items/tool/WrenchItem.java b/src/main/java/techreborn/items/tool/WrenchItem.java index ac3b2a13b..5dee79ff0 100644 --- a/src/main/java/techreborn/items/tool/WrenchItem.java +++ b/src/main/java/techreborn/items/tool/WrenchItem.java @@ -32,7 +32,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.api.IToolHandler; -import techreborn.TechReborn; /** * Created by modmuss50 on 26/02/2016. @@ -40,7 +39,7 @@ import techreborn.TechReborn; public class WrenchItem extends Item implements IToolHandler { public WrenchItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1)); + super(new Item.Settings().maxCount(1)); } @Override diff --git a/src/main/java/techreborn/items/tool/basic/ElectricTreetapItem.java b/src/main/java/techreborn/items/tool/basic/ElectricTreetapItem.java index 2bd7d65b6..d3719214f 100644 --- a/src/main/java/techreborn/items/tool/basic/ElectricTreetapItem.java +++ b/src/main/java/techreborn/items/tool/basic/ElectricTreetapItem.java @@ -45,7 +45,7 @@ public class ElectricTreetapItem extends Item implements RcEnergyItem { public RcEnergyTier tier = RcEnergyTier.MEDIUM; public ElectricTreetapItem() { - super(new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(new Item.Settings().maxCount(1).maxDamage(-1)); } // Item @@ -54,14 +54,6 @@ public class ElectricTreetapItem extends Item implements RcEnergyItem { return false; } - @Override - public void appendStacks(ItemGroup group, DefaultedList stacks) { - if (!isIn(group)) { - return; - } - InitUtils.initPoweredItems(this, stacks); - } - @Override public int getItemBarStep(ItemStack stack) { return ItemUtils.getPowerForDurabilityBar(stack); diff --git a/src/main/java/techreborn/items/tool/basic/RockCutterItem.java b/src/main/java/techreborn/items/tool/basic/RockCutterItem.java index 864ebe0cc..8b069a83f 100644 --- a/src/main/java/techreborn/items/tool/basic/RockCutterItem.java +++ b/src/main/java/techreborn/items/tool/basic/RockCutterItem.java @@ -29,16 +29,16 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.*; -import net.minecraft.util.collection.DefaultedList; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.PickaxeItem; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; import techreborn.config.TechRebornConfig; -import techreborn.init.TRContent; import techreborn.init.TRToolMaterials; public class RockCutterItem extends PickaxeItem implements RcEnergyItem { @@ -49,7 +49,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem { // 10k Energy with 128 E\t charge rate public RockCutterItem() { // combat stats same as for diamond pickaxe. Fix for #2468 - super(TRToolMaterials.ROCK_CUTTER, 1, -2.8f, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(TRToolMaterials.ROCK_CUTTER, 1, -2.8f, new Item.Settings().maxCount(1).maxDamage(-1)); } // PickaxeItem @@ -105,21 +105,6 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem { return true; } - @Override - public void appendStacks(ItemGroup group, DefaultedList stacks) { - if (!isIn(group)) { - return; - } - ItemStack uncharged = new ItemStack(this); - uncharged.addEnchantment(Enchantments.SILK_TOUCH, 1); - ItemStack charged = new ItemStack(TRContent.ROCK_CUTTER); - charged.addEnchantment(Enchantments.SILK_TOUCH, 1); - setStoredEnergy(charged, getEnergyCapacity()); - - stacks.add(uncharged); - stacks.add(charged); - } - // ItemDurabilityExtensions @Override public int getItemBarStep(ItemStack stack) { diff --git a/src/main/java/techreborn/items/tool/industrial/IndustrialChainsawItem.java b/src/main/java/techreborn/items/tool/industrial/IndustrialChainsawItem.java index 766c1ff97..0fec2af7d 100644 --- a/src/main/java/techreborn/items/tool/industrial/IndustrialChainsawItem.java +++ b/src/main/java/techreborn/items/tool/industrial/IndustrialChainsawItem.java @@ -31,7 +31,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.tag.BlockTags; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; diff --git a/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java b/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java index e318968a1..6d96ac270 100644 --- a/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java +++ b/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java @@ -114,12 +114,4 @@ public class IndustrialDrillItem extends DrillItem { public void appendTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { ItemUtils.buildActiveTooltip(stack, tooltip); } - - @Override - public void appendStacks(ItemGroup par2ItemGroup, DefaultedList itemList) { - if (!isIn(par2ItemGroup)) { - return; - } - InitUtils.initPoweredItems(TRContent.INDUSTRIAL_DRILL, itemList); - } } diff --git a/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java b/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java index 7ec274671..bf69ee5ff 100644 --- a/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java +++ b/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java @@ -38,23 +38,18 @@ import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; -import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; -import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; import techreborn.config.TechRebornConfig; -import techreborn.init.TRContent; import techreborn.init.TRToolMaterials; import java.util.List; @@ -65,7 +60,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem { // 4ME max charge with 1k charge rate public NanosaberItem() { - super(TRToolMaterials.NANOSABER, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(TRToolMaterials.NANOSABER, 1, 1, new Item.Settings().maxCount(1).maxDamage(-1)); } // SwordItem @@ -106,31 +101,6 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem { return true; } - @Override - public void appendStacks( - ItemGroup par2ItemGroup, DefaultedList itemList) { - if (!isIn(par2ItemGroup)) { - return; - } - ItemStack inactiveUncharged = new ItemStack(this); - inactiveUncharged.setNbt(new NbtCompound()); - inactiveUncharged.getOrCreateNbt().putBoolean("isActive", false); - - ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER); - inactiveCharged.setNbt(new NbtCompound()); - inactiveCharged.getOrCreateNbt().putBoolean("isActive", false); - setStoredEnergy(inactiveCharged, getEnergyCapacity()); - - ItemStack activeCharged = new ItemStack(TRContent.NANOSABER); - activeCharged.setNbt(new NbtCompound()); - activeCharged.getOrCreateNbt().putBoolean("isActive", true); - setStoredEnergy(activeCharged, getEnergyCapacity()); - - itemList.add(inactiveUncharged); - itemList.add(inactiveCharged); - itemList.add(activeCharged); - } - @Environment(EnvType.CLIENT) @Override public void appendTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { diff --git a/src/main/java/techreborn/items/tool/industrial/OmniToolItem.java b/src/main/java/techreborn/items/tool/industrial/OmniToolItem.java index 65a76d141..34e183a83 100644 --- a/src/main/java/techreborn/items/tool/industrial/OmniToolItem.java +++ b/src/main/java/techreborn/items/tool/industrial/OmniToolItem.java @@ -57,7 +57,7 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem { // 4M FE max charge with 1k charge rate public OmniToolItem() { - super(3, 1, TRToolMaterials.OMNI_TOOL, TRContent.BlockTags.OMNI_TOOL_MINEABLE, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1)); + super(3, 1, TRToolMaterials.OMNI_TOOL, TRContent.BlockTags.OMNI_TOOL_MINEABLE, new Item.Settings().maxCount(1).maxDamage(-1)); this.miningLevel = MiningLevel.DIAMOND.intLevel; } @@ -114,14 +114,6 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem { return true; } - @Override - public void appendStacks(ItemGroup par2ItemGroup, DefaultedList itemList) { - if (!isIn(par2ItemGroup)) { - return; - } - InitUtils.initPoweredItems(TRContent.OMNI_TOOL, itemList); - } - @Override public int getItemBarStep(ItemStack stack) { return ItemUtils.getPowerForDurabilityBar(stack); diff --git a/src/main/java/techreborn/items/tool/vanilla/TRAxeItem.java b/src/main/java/techreborn/items/tool/vanilla/TRAxeItem.java index be7f4ca20..d99c43f33 100644 --- a/src/main/java/techreborn/items/tool/vanilla/TRAxeItem.java +++ b/src/main/java/techreborn/items/tool/vanilla/TRAxeItem.java @@ -29,7 +29,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; public class TRAxeItem extends AxeItem { @@ -40,7 +39,7 @@ public class TRAxeItem extends AxeItem { } public TRAxeItem(ToolMaterial material, String repairOreDict) { - super(material, material.getAttackDamage(), -3.0F, new Item.Settings().group(TechReborn.ITEMGROUP)); + super(material, material.getAttackDamage(), -3.0F, new Item.Settings()); this.repairOreDict = repairOreDict; } diff --git a/src/main/java/techreborn/items/tool/vanilla/TRHoeItem.java b/src/main/java/techreborn/items/tool/vanilla/TRHoeItem.java index 12f2a9034..b446b018f 100644 --- a/src/main/java/techreborn/items/tool/vanilla/TRHoeItem.java +++ b/src/main/java/techreborn/items/tool/vanilla/TRHoeItem.java @@ -40,7 +40,7 @@ public class TRHoeItem extends HoeItem { } public TRHoeItem(ToolMaterial material, String repairOreDict) { - super(material, 0, 0F, new Item.Settings().group(TechReborn.ITEMGROUP)); + super(material, 0, 0F, new Item.Settings()); this.repairOreDict = repairOreDict; } diff --git a/src/main/java/techreborn/items/tool/vanilla/TRPickaxeItem.java b/src/main/java/techreborn/items/tool/vanilla/TRPickaxeItem.java index 4712f07fe..18dba3514 100644 --- a/src/main/java/techreborn/items/tool/vanilla/TRPickaxeItem.java +++ b/src/main/java/techreborn/items/tool/vanilla/TRPickaxeItem.java @@ -29,7 +29,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.PickaxeItem; import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; public class TRPickaxeItem extends PickaxeItem { @@ -40,7 +39,7 @@ public class TRPickaxeItem extends PickaxeItem { } public TRPickaxeItem(ToolMaterial material, String repairOreDict) { - super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP)); + super(material, 1, -2.8F, new Item.Settings()); this.repairOreDict = repairOreDict; } diff --git a/src/main/java/techreborn/items/tool/vanilla/TRSpadeItem.java b/src/main/java/techreborn/items/tool/vanilla/TRSpadeItem.java index f18605b37..4a5e71d77 100644 --- a/src/main/java/techreborn/items/tool/vanilla/TRSpadeItem.java +++ b/src/main/java/techreborn/items/tool/vanilla/TRSpadeItem.java @@ -40,7 +40,7 @@ public class TRSpadeItem extends ShovelItem { } public TRSpadeItem(ToolMaterial material, String repairOreDict) { - super(material, 1.5F, -3.0F, new Item.Settings().group(TechReborn.ITEMGROUP)); + super(material, 1.5F, -3.0F, new Item.Settings()); this.repairOreDict = repairOreDict; } diff --git a/src/main/java/techreborn/items/tool/vanilla/TRSwordItem.java b/src/main/java/techreborn/items/tool/vanilla/TRSwordItem.java index 6af495adf..ab3166275 100644 --- a/src/main/java/techreborn/items/tool/vanilla/TRSwordItem.java +++ b/src/main/java/techreborn/items/tool/vanilla/TRSwordItem.java @@ -29,7 +29,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; -import techreborn.TechReborn; public class TRSwordItem extends SwordItem { @@ -40,7 +39,7 @@ public class TRSwordItem extends SwordItem { } public TRSwordItem(ToolMaterial material, String repairOreDict) { - super(material, 3, -2.4F, new Item.Settings().group(TechReborn.ITEMGROUP)); + super(material, 3, -2.4F, new Item.Settings()); this.repairOreDict = repairOreDict; } diff --git a/src/main/java/techreborn/utils/InitUtils.java b/src/main/java/techreborn/utils/InitUtils.java index 6c7dbb305..4242781c1 100644 --- a/src/main/java/techreborn/utils/InitUtils.java +++ b/src/main/java/techreborn/utils/InitUtils.java @@ -24,6 +24,7 @@ package techreborn.utils; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; @@ -31,11 +32,12 @@ import net.minecraft.block.MapColor; import net.minecraft.block.Material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registry; import reborncore.RebornRegistry; import reborncore.common.powerSystem.RcEnergyItem; import techreborn.TechReborn; @@ -53,18 +55,7 @@ public class InitUtils { public static SoundEvent setup(String name) { Identifier identifier = new Identifier(TechReborn.MOD_ID, name); - return Registry.register(Registry.SOUND_EVENT, identifier, new SoundEvent(identifier)); - } - - public static void initPoweredItems(Item item, DefaultedList itemList) { - ItemStack uncharged = new ItemStack(item); - ItemStack charged = new ItemStack(item); - RcEnergyItem energyItem = (RcEnergyItem) item; - - energyItem.setStoredEnergy(charged, energyItem.getEnergyCapacity()); - - itemList.add(uncharged); - itemList.add(charged); + return Registry.register(Registries.SOUND_EVENT, identifier, SoundEvent.of(identifier)); } public static AbstractBlock.Settings setupRubberBlockSettings(boolean noCollision, float hardness, float resistance) { diff --git a/src/main/java/techreborn/utils/MaterialComparator.java b/src/main/java/techreborn/utils/MaterialComparator.java new file mode 100644 index 000000000..7c6f35c31 --- /dev/null +++ b/src/main/java/techreborn/utils/MaterialComparator.java @@ -0,0 +1,110 @@ +package techreborn.utils; + +import java.util.Comparator; +import java.util.List; + +public class MaterialComparator implements Comparator> { + + private static final List ORDER = List.of( + "SAW", + "WOOD", + "ASHES", + "DARK_ASHES", + "ANDESITE", + "DIORITE", + "GRANITE", + "BASALT", + "CALCITE", + "MARBLE", + "COAL", + "CARBON", + "CARBON_FIBER", + "CHARCOAL", + "CLAY", + "FLINT", + "SILICON", + "TIN", + "ZINC", + "IRON", + "REFINED_IRON", + "STEEL", + "COPPER", + "LEAD", + "NICKEL", + "BRONZE", + "BRASS", + "MIXED_METAL", + "ADVANCED_ALLOY", + "INVAR", + "SILVER", + "GOLD", + "ELECTRUM", + "GALENA", + "BAUXITE", + "ALUMINUM", + "TITANIUM", + "CHROME", + "REDSTONE", + "RUBY", + "SAPPHIRE", + "PERIDOT", + "RED_GARNET", + "YELLOW_GARNET", + "EMERALD", + "AMETHYST", + "LAPIS", + "LAZURITE", + "DIAMOND", + "IRIDIUM", + "IRIDIUM_ALLOY", + "PLATINUM", + "OBSIDIAN", + "NETHERRACK", + "GLOWSTONE", + "QUARTZ", + "CINNABAR", + "PYRITE", + "PYROPE", + "SPHALERITE", + "ALMANDINE", + "ANDRADITE", + "GROSSULAR", + "SPESSARTINE", + "MAGNESIUM", + "MANGANESE", + "MAGNALIUM", + "PHOSPHOROUS", + "SULFUR", + "SALTPETER", + "OLIVINE", + "UVAROVITE", + "ENDER_PEARL", + "ENDER_EYE", + "ENDSTONE", + "SODALITE", + "SHELDONITE", + "TUNGSTEN", + "TUNGSTENSTEEL", + "HOT_TUNGSTENSTEEL", + "IRIDIUM_REINFORCED_STONE", + "IRIDIUM_REINFORCED_TUNGSTENSTEEL", + "NETHERITE" + ); + + @Override + public int compare(Enum o1, Enum o2) { + if (o1 == o2) { + return 0; + } + if (o1 == null) { + return Integer.MIN_VALUE; + } + if (o2 == null) { + return Integer.MAX_VALUE; + } + if (o1.name().equals(o2.name())) { + return 0; + } + return ORDER.indexOf(o1.name()) - ORDER.indexOf(o2.name()); + } +} diff --git a/src/main/java/techreborn/utils/MaterialTypeComparator.java b/src/main/java/techreborn/utils/MaterialTypeComparator.java new file mode 100644 index 000000000..b1144ea23 --- /dev/null +++ b/src/main/java/techreborn/utils/MaterialTypeComparator.java @@ -0,0 +1,38 @@ +package techreborn.utils; + +import techreborn.init.TRContent; + +import java.util.Comparator; +import java.util.List; + +public class MaterialTypeComparator implements Comparator> { + + private static final List ORDER = List.of( + TRContent.Ores.class.getName(), + TRContent.Nuggets.class.getName(), + TRContent.SmallDusts.class.getName(), + TRContent.Dusts.class.getName(), + TRContent.RawMetals.class.getName(), + TRContent.Ingots.class.getName(), + TRContent.Gems.class.getName(), + TRContent.Plates.class.getName(), + TRContent.StorageBlocks.class.getName() + ); + + @Override + public int compare(Enum o1, Enum o2) { + if (o1 == o2) { + return 0; + } + if (o1 == null) { + return Integer.MIN_VALUE; + } + if (o2 == null) { + return Integer.MAX_VALUE; + } + if (o1.getClass().getName().equals(o2.getClass().getName())) { + return 0; + } + return ORDER.indexOf(o1.getClass().getName()) - ORDER.indexOf(o2.getClass().getName()); + } +} diff --git a/src/main/java/techreborn/utils/PoweredCraftingHandler.java b/src/main/java/techreborn/utils/PoweredCraftingHandler.java index 270fe9ef8..9248a9ecf 100644 --- a/src/main/java/techreborn/utils/PoweredCraftingHandler.java +++ b/src/main/java/techreborn/utils/PoweredCraftingHandler.java @@ -30,7 +30,8 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import reborncore.api.events.ItemCraftCallback; import reborncore.common.powerSystem.RcEnergyItem; import techreborn.TechReborn; @@ -65,7 +66,7 @@ public final class PoweredCraftingHandler implements ItemCraftCallback { energyItem.setStoredEnergy(stack, Math.min(totalEnergy, energyItem.getEnergyCapacity())); } - if (!Registry.ITEM.getId(stack.getItem()).getNamespace().equalsIgnoreCase(TechReborn.MOD_ID)) { + if (!Registries.ITEM.getId(stack.getItem()).getNamespace().equalsIgnoreCase(TechReborn.MOD_ID)) { return; } Map map = Maps.newLinkedHashMap(); diff --git a/src/main/java/techreborn/utils/ToolsUtil.java b/src/main/java/techreborn/utils/ToolsUtil.java index 76bd1d53d..4e476193e 100644 --- a/src/main/java/techreborn/utils/ToolsUtil.java +++ b/src/main/java/techreborn/utils/ToolsUtil.java @@ -25,12 +25,14 @@ package techreborn.utils; import com.google.common.collect.ImmutableSet; +import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBlockTags; import net.minecraft.block.*; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; @@ -177,7 +179,7 @@ public class ToolsUtil { if (blockState.getMaterial().isLiquid()) { return true; } - if (blockState.getBlock() instanceof OreBlock) { + if (blockState.isIn(ConventionalBlockTags.ORES)) { return true; } if (blockState.isOf(Blocks.OBSIDIAN) || blockState.isOf(Blocks.CRYING_OBSIDIAN)){ diff --git a/src/main/java/techreborn/world/OreDepth.java b/src/main/java/techreborn/world/OreDepth.java index 980a16248..796e140c3 100644 --- a/src/main/java/techreborn/world/OreDepth.java +++ b/src/main/java/techreborn/world/OreDepth.java @@ -26,11 +26,12 @@ package techreborn.world; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.registry.Registries; import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.world.World; import net.minecraft.world.gen.HeightContext; import org.jetbrains.annotations.Nullable; @@ -62,7 +63,7 @@ public record OreDepth(Identifier identifier, int minY, int maxY, TargetDimensio if (ore.isDeepslate()) continue; if (ore.distribution != null) { - final Identifier blockId = Registry.BLOCK.getId(ore.block); + final Identifier blockId = Registries.BLOCK.getId(ore.block); final HeightContext heightContext = getHeightContext(server, ore.distribution.dimension); if (heightContext == null) { @@ -77,7 +78,7 @@ public record OreDepth(Identifier identifier, int minY, int maxY, TargetDimensio TRContent.Ores deepslate = ore.getDeepslate(); if (deepslate == null) continue; - final Identifier deepSlateBlockId = Registry.BLOCK.getId(deepslate.block); + final Identifier deepSlateBlockId = Registries.BLOCK.getId(deepslate.block); depths.add(new OreDepth(deepSlateBlockId, minY, maxY, ore.distribution.dimension)); } } diff --git a/src/main/java/techreborn/world/OreFeature.java b/src/main/java/techreborn/world/OreFeature.java deleted file mode 100644 index 4e96e84e5..000000000 --- a/src/main/java/techreborn/world/OreFeature.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2020 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.world; - -import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; -import net.minecraft.block.Blocks; -import net.minecraft.structure.rule.BlockStateMatchRuleTest; -import net.minecraft.structure.rule.RuleTest; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.gen.YOffset; -import net.minecraft.world.gen.feature.*; -import net.minecraft.world.gen.placementmodifier.*; -import techreborn.init.TRContent; - -import java.util.List; -import java.util.function.Predicate; - -public class OreFeature { - private final TRContent.Ores ore; - private final ConfiguredFeature configuredFeature; - private final PlacedFeature placedFeature; - - public OreFeature(TRContent.Ores ore) { - this.ore = ore; - - this.configuredFeature = configureAndRegisterFeature(); - this.placedFeature = configureAndRegisterPlacedFeature(); - } - - private ConfiguredFeature configureAndRegisterFeature() { - final OreFeatureConfig oreFeatureConfig = switch (ore.distribution.dimension) { - case OVERWORLD -> createOverworldFeatureConfig(); - case NETHER -> createSimpleFeatureConfig(OreConfiguredFeatures.BASE_STONE_NETHER); - case END -> createSimpleFeatureConfig(new BlockStateMatchRuleTest(Blocks.END_STONE.getDefaultState())); - }; - - ConfiguredFeature configuredFeature = new ConfiguredFeature<>(Feature.ORE, oreFeatureConfig); - Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, getId(), configuredFeature); - return configuredFeature; - } - - private OreFeatureConfig createOverworldFeatureConfig() { - if (this.ore.getDeepslate() != null) { - return new OreFeatureConfig(List.of( - OreFeatureConfig.createTarget(OreConfiguredFeatures.STONE_ORE_REPLACEABLES, this.ore.block.getDefaultState()), - OreFeatureConfig.createTarget(OreConfiguredFeatures.DEEPSLATE_ORE_REPLACEABLES, this.ore.getDeepslate().block.getDefaultState()) - ), ore.distribution.veinSize); - } - - return createSimpleFeatureConfig(OreConfiguredFeatures.STONE_ORE_REPLACEABLES); - } - - private OreFeatureConfig createSimpleFeatureConfig(RuleTest test) { - return new OreFeatureConfig(test, this.ore.block.getDefaultState(), ore.distribution.veinSize); - } - - private PlacedFeature configureAndRegisterPlacedFeature() { - PlacedFeature placedFeature = new PlacedFeature(WorldGenerator.getEntry(BuiltinRegistries.CONFIGURED_FEATURE, configuredFeature), getPlacementModifiers()); - Registry.register(BuiltinRegistries.PLACED_FEATURE, getId(), placedFeature); - return placedFeature; - } - - private List getPlacementModifiers() { - return modifiers( - CountPlacementModifier.of(ore.distribution.veinsPerChunk), - HeightRangePlacementModifier.uniform( - ore.distribution.minOffset, - YOffset.fixed(ore.distribution.maxY) - ) - ); - } - - private static List modifiers(PlacementModifier first, PlacementModifier second) { - return List.of(first, SquarePlacementModifier.of(), second, BiomePlacementModifier.of()); - } - - public final Identifier getId() { - return new Identifier("techreborn", ore.name + "_ore"); - } - - public Predicate getBiomeSelector() { - return ore.distribution.dimension.biomeSelector; - } - - public RegistryKey getPlacedFeatureRegistryKey() { - return BuiltinRegistries.PLACED_FEATURE.getKey(this.placedFeature).orElseThrow(); - } -} diff --git a/src/main/java/techreborn/world/RubberSaplingGenerator.java b/src/main/java/techreborn/world/RubberSaplingGenerator.java index cfa6dbf17..14f4fdbd2 100644 --- a/src/main/java/techreborn/world/RubberSaplingGenerator.java +++ b/src/main/java/techreborn/world/RubberSaplingGenerator.java @@ -25,16 +25,15 @@ package techreborn.world; import net.minecraft.block.sapling.SaplingGenerator; +import net.minecraft.registry.RegistryKey; import net.minecraft.util.math.random.Random; -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.gen.feature.ConfiguredFeature; import org.jetbrains.annotations.Nullable; public class RubberSaplingGenerator extends SaplingGenerator { @Nullable @Override - protected RegistryEntry> getTreeFeature(Random random, boolean bees) { - return WorldGenerator.getEntry(BuiltinRegistries.CONFIGURED_FEATURE, WorldGenerator.RUBBER_TREE_FEATURE); + protected RegistryKey> getTreeFeature(Random random, boolean bees) { + return WorldGenerator.RUBBER_TREE_FEATURE; } } diff --git a/src/main/java/techreborn/world/RubberTreeSpikeDecorator.java b/src/main/java/techreborn/world/RubberTreeSpikeDecorator.java index 61d0a30ee..66d389a15 100644 --- a/src/main/java/techreborn/world/RubberTreeSpikeDecorator.java +++ b/src/main/java/techreborn/world/RubberTreeSpikeDecorator.java @@ -26,9 +26,7 @@ package techreborn.world; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; import net.minecraft.world.gen.stateprovider.BlockStateProvider; import net.minecraft.world.gen.treedecorator.TreeDecorator; import net.minecraft.world.gen.treedecorator.TreeDecoratorType; @@ -43,8 +41,6 @@ public class RubberTreeSpikeDecorator extends TreeDecorator { ).apply(instance, RubberTreeSpikeDecorator::new) ); - public static final TreeDecoratorType RUBBER_TREE_SPIKE = Registry.register(Registry.TREE_DECORATOR_TYPE, new Identifier("techreborn", "rubber_tree_spike"), new TreeDecoratorType<>(CODEC)); - private final int spireHeight; private final BlockStateProvider provider; @@ -55,7 +51,7 @@ public class RubberTreeSpikeDecorator extends TreeDecorator { @Override protected TreeDecoratorType getType() { - return RUBBER_TREE_SPIKE; + return WorldGenerator.RUBBER_TREE_SPIKE; } @Override @@ -65,7 +61,7 @@ public class RubberTreeSpikeDecorator extends TreeDecorator { .ifPresent(blockPos -> { for (int i = 0; i < spireHeight; i++) { BlockPos sPos = blockPos.up(i); - generator.replace(sPos, provider.getBlockState(generator.getRandom(), sPos)); + generator.replace(sPos, provider.get(generator.getRandom(), sPos)); } }); } diff --git a/src/datagen/groovy/techreborn/datagen/tags/WaterExplosionTagProvider.groovy b/src/main/java/techreborn/world/TROreFeatureConfig.java similarity index 55% rename from src/datagen/groovy/techreborn/datagen/tags/WaterExplosionTagProvider.groovy rename to src/main/java/techreborn/world/TROreFeatureConfig.java index 6b14cb935..893fb0a73 100644 --- a/src/datagen/groovy/techreborn/datagen/tags/WaterExplosionTagProvider.groovy +++ b/src/main/java/techreborn/world/TROreFeatureConfig.java @@ -22,21 +22,30 @@ * SOFTWARE. */ -package techreborn.datagen.tags +package techreborn.world; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider -import reborncore.common.misc.RebornCoreTags -import techreborn.init.ModFluids +import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.PlacedFeature; +import techreborn.init.TRContent; -class WaterExplosionTagProvider extends FabricTagProvider.ItemTagProvider { - WaterExplosionTagProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator) - } +import java.util.function.Predicate; - @Override - protected void generateTags() { - getOrCreateTagBuilder(RebornCoreTags.WATER_EXPLOSION_ITEM) - .add(ModFluids.SODIUM.getBucket()) - } +public record TROreFeatureConfig(Identifier id, TRContent.Ores ore, RegistryKey> configuredFeature, RegistryKey placedFeature) { + public static TROreFeatureConfig of(TRContent.Ores ore) { + Identifier id = new Identifier("techreborn", ore.name + "_ore"); + return new TROreFeatureConfig( + id, + ore, + RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, id), + RegistryKey.of(RegistryKeys.PLACED_FEATURE, id) + ); + } + + public Predicate biomeSelector() { + return ore.distribution.dimension.biomeSelector; + } } diff --git a/src/main/java/techreborn/world/WorldGenerator.java b/src/main/java/techreborn/world/WorldGenerator.java index 30c3b7909..99dfbda27 100644 --- a/src/main/java/techreborn/world/WorldGenerator.java +++ b/src/main/java/techreborn/world/WorldGenerator.java @@ -24,35 +24,23 @@ package techreborn.world; -import net.fabricmc.fabric.api.biome.v1.*; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.tag.BiomeTags; +import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext; +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import net.fabricmc.fabric.api.biome.v1.ModificationPhase; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.BiomeTags; import net.minecraft.util.Identifier; -import net.minecraft.util.collection.DataPool; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.Heightmap; import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.YOffset; -import net.minecraft.world.gen.blockpredicate.BlockPredicate; -import net.minecraft.world.gen.feature.*; -import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize; -import net.minecraft.world.gen.foliage.BlobFoliagePlacer; -import net.minecraft.world.gen.heightprovider.UniformHeightProvider; -import net.minecraft.world.gen.placementmodifier.*; -import net.minecraft.world.gen.stateprovider.BlockStateProvider; -import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; -import net.minecraft.world.gen.trunk.StraightTrunkPlacer; -import techreborn.blocks.misc.BlockRubberLog; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.world.gen.treedecorator.TreeDecoratorType; import techreborn.config.TechRebornConfig; -import techreborn.init.ModFluids; import techreborn.init.TRContent; import java.util.Arrays; @@ -62,18 +50,23 @@ import java.util.function.Consumer; // /fill ~ ~ ~ ~20 ~20 ~20 air replace #minecraft:base_stone_overworld public class WorldGenerator { - public static ConfiguredFeature RUBBER_TREE_FEATURE; - public static PlacedFeature RUBBER_TREE_PLACED_FEATURE; - public static ConfiguredFeature RUBBER_TREE_PATCH_FEATURE; - public static PlacedFeature RUBBER_TREE_PATCH_PLACED_FEATURE; - public static final List ORE_FEATURES = getOreFeatures(); - public static ConfiguredFeature OIL_LAKE_FEATURE; - public static PlacedFeature OIL_LAKE_PLACED_FEATURE; + public static final List ORE_FEATURES = getOreFeatures(); + + public static final Identifier OIL_LAKE_ID = new Identifier("techreborn", "oil_lake"); + public static final RegistryKey> OIL_LAKE_FEATURE = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, OIL_LAKE_ID); + public static final RegistryKey OIL_LAKE_PLACED_FEATURE = RegistryKey.of(RegistryKeys.PLACED_FEATURE, OIL_LAKE_ID); + + public static final Identifier RUBBER_TREE_ID = new Identifier("techreborn", "rubber_tree"); + public static final RegistryKey> RUBBER_TREE_FEATURE = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, RUBBER_TREE_ID); + public static final RegistryKey RUBBER_TREE_PLACED_FEATURE = RegistryKey.of(RegistryKeys.PLACED_FEATURE, RUBBER_TREE_ID); + + public static final Identifier RUBBER_TREE_PATCH_ID = new Identifier("techreborn", "rubber_tree_patch"); + public static final RegistryKey> RUBBER_TREE_PATCH_FEATURE = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, RUBBER_TREE_PATCH_ID); + public static final RegistryKey RUBBER_TREE_PATCH_PLACED_FEATURE = RegistryKey.of(RegistryKeys.PLACED_FEATURE, RUBBER_TREE_PATCH_ID); + + public static final TreeDecoratorType RUBBER_TREE_SPIKE = Registry.register(Registries.TREE_DECORATOR_TYPE, new Identifier("techreborn", "rubber_tree_spike"), new TreeDecoratorType<>(RubberTreeSpikeDecorator.CODEC)); public static void initWorldGen() { - registerTreeDecorators(); - registerOilLakes(); - if (!TechRebornConfig.enableOreGeneration && !TechRebornConfig.enableRubberTreeGeneration && !TechRebornConfig.enableOilLakeGeneration) { return; } @@ -92,108 +85,28 @@ public class WorldGenerator { return; } - for (OreFeature feature : ORE_FEATURES) { - if (feature.getBiomeSelector().test(biomeSelectionContext)) { - biomeModificationContext.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, feature.getPlacedFeatureRegistryKey()); + for (TROreFeatureConfig feature : ORE_FEATURES) { + if (feature.biomeSelector().test(biomeSelectionContext)) { + biomeModificationContext.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, feature.placedFeature()); } } }; } - private static List getOreFeatures() { + private static List getOreFeatures() { return Arrays.stream(TRContent.Ores.values()) .filter(ores -> ores.distribution != null) - .map(OreFeature::new) + .map(TROreFeatureConfig::of) .toList(); } - private static void registerTreeDecorators() { - Identifier treeId = new Identifier("techreborn", "rubber_tree"); - Identifier patchId = new Identifier("techreborn", "rubber_tree_patch"); - - RUBBER_TREE_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, treeId, - new ConfiguredFeature<>(Feature.TREE, rubber().build()) - ); - RUBBER_TREE_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, treeId, - new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, RUBBER_TREE_FEATURE), List.of( - PlacedFeatures.wouldSurvive(TRContent.RUBBER_SAPLING) - )) - ); - - RUBBER_TREE_PATCH_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, patchId, - new ConfiguredFeature<>(Feature.RANDOM_PATCH, - ConfiguredFeatures.createRandomPatchFeatureConfig( - 6, getEntry(BuiltinRegistries.PLACED_FEATURE, RUBBER_TREE_PLACED_FEATURE) - ) - ) - ); - - RUBBER_TREE_PATCH_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, patchId, - new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, RUBBER_TREE_PATCH_FEATURE), List.of( - RarityFilterPlacementModifier.of(3), - SquarePlacementModifier.of(), - PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, - BiomePlacementModifier.of()) - ) - ); - } - private static BiConsumer rubberTreeModifier() { if (!TechRebornConfig.enableRubberTreeGeneration) { return (biomeSelectionContext, biomeModificationContext) -> {}; } - final RegistryKey registryKey = BuiltinRegistries.PLACED_FEATURE.getKey(RUBBER_TREE_PATCH_PLACED_FEATURE).orElseThrow(); - return (biomeSelectionContext, biomeModificationContext) -> - biomeModificationContext.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, registryKey); - } - - private static TreeFeatureConfig.Builder rubber() { - final DataPool.Builder logDataPool = DataPool.builder() - .add(TRContent.RUBBER_LOG.getDefaultState(), 6); - - Arrays.stream(Direction.values()) - .filter(direction -> direction.getAxis().isHorizontal()) - .map(direction -> TRContent.RUBBER_LOG.getDefaultState() - .with(BlockRubberLog.HAS_SAP, true) - .with(BlockRubberLog.SAP_SIDE, direction) - ) - .forEach(state -> logDataPool.add(state, 1)); - - return new TreeFeatureConfig.Builder( - new WeightedBlockStateProvider(logDataPool), - new StraightTrunkPlacer(6, 3, 0), - BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState()), - new BlobFoliagePlacer( - ConstantIntProvider.create(2), - ConstantIntProvider.create(0), - 3 - ), - new TwoLayersFeatureSize( - 1, - 0, - 1 - )) - .decorators(List.of( - new RubberTreeSpikeDecorator(4, BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState())) - )); - } - - @SuppressWarnings("deprecation") - private static void registerOilLakes() { - Identifier lakeId = new Identifier("techreborn", "oil_lake"); - OIL_LAKE_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, lakeId, - new ConfiguredFeature<>(Feature.LAKE, - new LakeFeature.Config(BlockStateProvider.of(ModFluids.OIL.getBlock().getDefaultState()), BlockStateProvider.of(Blocks.STONE.getDefaultState())) - )); - OIL_LAKE_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, lakeId, - new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, OIL_LAKE_FEATURE), List.of( - RarityFilterPlacementModifier.of(20), - HeightRangePlacementModifier.of(UniformHeightProvider.create(YOffset.fixed(0), YOffset.getTop())), - EnvironmentScanPlacementModifier.of(Direction.DOWN, BlockPredicate.bothOf(BlockPredicate.not(BlockPredicate.IS_AIR), BlockPredicate.insideWorldBounds(new BlockPos(0, -5, 0))), 32), - SurfaceThresholdFilterPlacementModifier.of(Heightmap.Type.OCEAN_FLOOR_WG, Integer.MIN_VALUE, -5) - ))); + biomeModificationContext.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, RUBBER_TREE_PATCH_PLACED_FEATURE); } private static Consumer oilLakeModifier(){ @@ -201,12 +114,6 @@ public class WorldGenerator { return (biomeModificationContext) -> {}; } - final RegistryKey registryKey = BuiltinRegistries.PLACED_FEATURE.getKey(OIL_LAKE_PLACED_FEATURE).orElseThrow(); - - return (biomeModificationContext) -> biomeModificationContext.getGenerationSettings().addFeature(GenerationStep.Feature.LAKES, registryKey); - } - - public static RegistryEntry getEntry(Registry registry, T value) { - return registry.getEntry(registry.getKey(value).orElseThrow()).orElseThrow(); + return (biomeModificationContext) -> biomeModificationContext.getGenerationSettings().addFeature(GenerationStep.Feature.LAKES, OIL_LAKE_PLACED_FEATURE); } } \ No newline at end of file diff --git a/src/main/resources/assets/techreborn/lang/en_us.json b/src/main/resources/assets/techreborn/lang/en_us.json index f58326502..8bc037b37 100644 --- a/src/main/resources/assets/techreborn/lang/en_us.json +++ b/src/main/resources/assets/techreborn/lang/en_us.json @@ -1126,6 +1126,6 @@ "gui.techreborn.block.progress.paused": "Idle (%s)", "_comment28": "Villagers", - "entity.minecraft.villager.metallurgist": "Metallurgist", - "entity.minecraft.villager.electrician": "Electrician" -} \ No newline at end of file + "entity.minecraft.villager.techreborn.metallurgist": "Metallurgist", + "entity.minecraft.villager.techreborn.electrician": "Electrician" +} diff --git a/src/main/resources/assets/techreborn/sounds/Alarm credits.txt b/src/main/resources/assets/techreborn/sounds/alarm_credits.txt similarity index 100% rename from src/main/resources/assets/techreborn/sounds/Alarm credits.txt rename to src/main/resources/assets/techreborn/sounds/alarm_credits.txt diff --git a/src/main/resources/data/techreborn/structures/village/desert/houses/desert_electrician.nbt b/src/main/resources/data/techreborn/structures/village/desert/houses/desert_electrician.nbt new file mode 100644 index 000000000..0dca0cea6 Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/desert/houses/desert_electrician.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/desert/houses/desert_metallurgist.nbt b/src/main/resources/data/techreborn/structures/village/desert/houses/desert_metallurgist.nbt new file mode 100644 index 000000000..fdf7b6317 Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/desert/houses/desert_metallurgist.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/plains/houses/plains_electrician.nbt b/src/main/resources/data/techreborn/structures/village/plains/houses/plains_electrician.nbt new file mode 100644 index 000000000..0b3451392 Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/plains/houses/plains_electrician.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/plains/houses/plains_metallurgist.nbt b/src/main/resources/data/techreborn/structures/village/plains/houses/plains_metallurgist.nbt new file mode 100644 index 000000000..c23e4ecaa Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/plains/houses/plains_metallurgist.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/savanna/houses/savanna_electrician.nbt b/src/main/resources/data/techreborn/structures/village/savanna/houses/savanna_electrician.nbt new file mode 100644 index 000000000..563d03108 Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/savanna/houses/savanna_electrician.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/savanna/houses/savanna_metallurgist.nbt b/src/main/resources/data/techreborn/structures/village/savanna/houses/savanna_metallurgist.nbt new file mode 100644 index 000000000..482a575b8 Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/savanna/houses/savanna_metallurgist.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/snowy/houses/snowy_electrician.nbt b/src/main/resources/data/techreborn/structures/village/snowy/houses/snowy_electrician.nbt new file mode 100644 index 000000000..ed4b7d0dc Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/snowy/houses/snowy_electrician.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/snowy/houses/snowy_metallurgist.nbt b/src/main/resources/data/techreborn/structures/village/snowy/houses/snowy_metallurgist.nbt new file mode 100644 index 000000000..6ba63ef0a Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/snowy/houses/snowy_metallurgist.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/taiga/houses/taiga_electrician.nbt b/src/main/resources/data/techreborn/structures/village/taiga/houses/taiga_electrician.nbt new file mode 100644 index 000000000..974d08c8e Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/taiga/houses/taiga_electrician.nbt differ diff --git a/src/main/resources/data/techreborn/structures/village/taiga/houses/taiga_metallurgist.nbt b/src/main/resources/data/techreborn/structures/village/taiga/houses/taiga_metallurgist.nbt new file mode 100644 index 000000000..9b351afce Binary files /dev/null and b/src/main/resources/data/techreborn/structures/village/taiga/houses/taiga_metallurgist.nbt differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9a46d51a2..6a91d9838 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,12 +30,12 @@ ] }, "depends": { - "fabricloader": ">=0.14.8", - "fabric-api": ">=0.66.0", + "fabricloader": ">=0.14.11", + "fabric-api": ">=0.68.1", "reborncore": "*", "team_reborn_energy": ">=2.3.0", "fabric-biome-api-v1": ">=3.0.0", - "minecraft": "~1.19.2" + "minecraft": ">=1.19.3- <1.19.4-" }, "accessWidener": "techreborn.accesswidener", "authors": [ diff --git a/src/main/resources/techreborn.accesswidener b/src/main/resources/techreborn.accesswidener index 6a1963772..8a4c99175 100644 --- a/src/main/resources/techreborn.accesswidener +++ b/src/main/resources/techreborn.accesswidener @@ -8,7 +8,7 @@ accessible class net/minecraft/recipe/Ingredient$Entry accessible class net/minecraft/recipe/Ingredient$TagEntry accessible class net/minecraft/recipe/Ingredient$StackEntry accessible field net/minecraft/recipe/Ingredient entries [Lnet/minecraft/recipe/Ingredient$Entry; -accessible field net/minecraft/recipe/Ingredient$TagEntry tag Lnet/minecraft/tag/TagKey; +accessible field net/minecraft/recipe/Ingredient$TagEntry tag Lnet/minecraft/registry/tag/TagKey; accessible method net/minecraft/client/gui/screen/ingame/HandledScreen getSlotAt (DD)Lnet/minecraft/screen/slot/Slot; @@ -16,7 +16,6 @@ accessible method net/minecraft/client/render/WorldRenderer drawShapeOu accessible method net/minecraft/world/gen/treedecorator/TreeDecoratorType (Lcom/mojang/serialization/Codec;)V -accessible method net/minecraft/client/item/ModelPredicateProviderRegistry register (Lnet/minecraft/item/Item;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/item/UnclampedModelPredicateProvider;)V accessible field net/minecraft/client/gui/screen/Screen selectables Ljava/util/List; accessible field net/minecraft/block/FluidBlock fluid Lnet/minecraft/fluid/FlowableFluid; accessible method net/minecraft/world/gen/foliage/FoliagePlacerType register (Ljava/lang/String;Lcom/mojang/serialization/Codec;)Lnet/minecraft/world/gen/foliage/FoliagePlacerType; @@ -24,5 +23,9 @@ accessible method net/minecraft/recipe/RecipeManager getAllOfType (L accessible field net/minecraft/screen/ScreenHandler listeners Ljava/util/List; accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/inventory/CraftingInventory;IIZ)Z +accessible field net/minecraft/structure/pool/StructurePool elements Lit/unimi/dsi/fastutil/objects/ObjectArrayList; + +extendable method net/minecraft/data/server/recipe/RecipeProvider getName ()Ljava/lang/String; + # DO NOT EDIT THIS FILE, edit the RebornCore AW, it will automatically be coped to this one. \ No newline at end of file