diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e523ed2..3b8e10c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,28 +75,6 @@ jobs: release_version: ${{ steps.version.outputs.version }} github_token: ${{ secrets.TEAM_RESOURCEFUL_BOT }} -# ### Need to duplicate this block for fabric -# - name: Upload Forge Releases (Curse/Modrinth/Github) -# if: contains(steps.props.outputs.enabled_platforms, 'forge') -# uses: Kir-Antipov/mc-publish@v3.3 -# with: -# curseforge-id: ${{ vars.CURSE_ID }} -# curseforge-token: ${{ secrets.CURSE_API_KEY }} -# -# modrinth-id: ${{ vars.MODRINTH_ID }} -# modrinth-token: ${{ secrets.MODRINTH_API_KEY }} -# -# github-tag: "v${{ steps.version.outputs.version }}" -# github-token: ${{ secrets.TEAM_RESOURCEFUL_BOT }} -# -# files: ./forge/build/libs/!(*-@(dev|sources|dev-shadow)).jar -# name: "[Forge] Resourceful Lib ${{ steps.version.outputs.version }}" -# version: ${{ steps.version.outputs.version }} -# changelog-file: changelog.md -# loaders: forge -# game-versions: ${{ steps.props.outputs.mc_version }} -# version-resolver: exact - - name: Upload NeoForge Releases (Curse/Modrinth/Github) id: forge_release if: contains(steps.props.outputs.enabled_platforms, 'neoforge') diff --git a/build.gradle b/build.gradle index bd24267..74a76fe 100644 --- a/build.gradle +++ b/build.gradle @@ -106,7 +106,7 @@ resourcefulGradle { "neoforge_version": neoforge_version, "fabric_version": fabric_loader_version, "fabric_link": fabricLink, - "forge_link": forgeLink + "neoforge_link": forgeLink ] def template = nightly.toBoolean() ? "nightly_embed.json.template" : "release_embed.json.template" diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java index efc11ef..1e8596c 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java @@ -44,18 +44,20 @@ default void renderOverlay(Minecraft minecraft, PoseStack stack) { BlockPos blockpos = BlockPos.containing(player.getX(), player.getEyeY(), player.getZ()); float brightness = LightTexture.getBrightness(player.level().dimensionType(), player.level().getMaxLocalRawBrightness(blockpos)); - BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder(); + BufferBuilder bufferbuilder = Tesselator.getInstance().begin( + VertexFormat.Mode.QUADS, + DefaultVertexFormat.POSITION_TEX + ); RenderSystem.enableBlend(); RenderSystem.setShaderColor(brightness, brightness, brightness, 0.1F); float f7 = -player.getYRot() / 64.0F; float f8 = player.getXRot() / 64.0F; Matrix4f matrix4f = stack.last().pose(); - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - bufferbuilder.vertex(matrix4f, -1.0F, -1.0F, -0.5F).uv(4.0F + f7, 4.0F + f8).endVertex(); - bufferbuilder.vertex(matrix4f, 1.0F, -1.0F, -0.5F).uv(0.0F + f7, 4.0F + f8).endVertex(); - bufferbuilder.vertex(matrix4f, 1.0F, 1.0F, -0.5F).uv(0.0F + f7, 0.0F + f8).endVertex(); - bufferbuilder.vertex(matrix4f, -1.0F, 1.0F, -0.5F).uv(4.0F + f7, 0.0F + f8).endVertex(); - BufferUploader.drawWithShader(bufferbuilder.end()); + bufferbuilder.addVertex(matrix4f, -1.0F, -1.0F, -0.5F).setUv(4.0F + f7, 4.0F + f8); + bufferbuilder.addVertex(matrix4f, 1.0F, -1.0F, -0.5F).setUv(0.0F + f7, 4.0F + f8); + bufferbuilder.addVertex(matrix4f, 1.0F, 1.0F, -0.5F).setUv(0.0F + f7, 0.0F + f8); + bufferbuilder.addVertex(matrix4f, -1.0F, 1.0F, -0.5F).setUv(4.0F + f7, 0.0F + f8); + BufferUploader.drawWithShader(bufferbuilder.buildOrThrow()); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); } diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/registry/ResourcefulClientFluidRegistry.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/registry/ResourcefulClientFluidRegistry.java index e257154..ab78242 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/registry/ResourcefulClientFluidRegistry.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/registry/ResourcefulClientFluidRegistry.java @@ -30,8 +30,8 @@ public RegistryEntry register(String id, ClientFluidPrope @Override public RegistryEntry register(String id, Supplier supplier) { - REGISTRY.put(new ResourceLocation(this.modid, id), supplier.get()); - return entries.add(new Entry<>(new ResourceLocation(this.modid, id), supplier.get())); + REGISTRY.put(ResourceLocation.fromNamespaceAndPath(this.modid, id), supplier.get()); + return entries.add(new Entry<>(ResourceLocation.fromNamespaceAndPath(this.modid, id), supplier.get())); } /** diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/highlights/base/HighlightLine.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/highlights/base/HighlightLine.java index f497925..bf83672 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/highlights/base/HighlightLine.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/client/highlights/base/HighlightLine.java @@ -11,56 +11,60 @@ public record HighlightLine(Vector3f start, Vector3f end, Vector3f normal) { - public static final Codec CODEC = Codec.FLOAT.listOf().comapFlatMap((floats) -> Util.fixedSize(floats, 6).map(HighlightLine::new), HighlightLine::getAsList); + public static final Codec CODEC = Codec.FLOAT.listOf().comapFlatMap((floats) -> Util.fixedSize(floats, 6).map(HighlightLine::new), HighlightLine::getAsList); - public HighlightLine(Vector3f start, Vector3f end) { - this(start, end, normal(start, end)); - } + public HighlightLine(Vector3f start, Vector3f end) { + this(start, end, normal(start, end)); + } - public HighlightLine(List list) { - this(new Vector3f(list.get(0), list.get(1), list.get(2)), new Vector3f(list.get(3), list.get(4), list.get(5))); - } + public HighlightLine(List list) { + this(new Vector3f(list.get(0), list.get(1), list.get(2)), new Vector3f(list.get(3), list.get(4), list.get(5))); + } - public List getAsList() { - return List.of(start.x(), start.y(), start.z(), end.x(), end.y(), end.z()); - } + public List getAsList() { + return List.of(start.x(), start.y(), start.z(), end.x(), end.y(), end.z()); + } - public HighlightLine copy() { - return new HighlightLine(new Vector3f(start), new Vector3f(end)); - } + public HighlightLine copy() { + return new HighlightLine(new Vector3f(start), new Vector3f(end)); + } - public void recalculateNormal() { - Vector3f normal = normal(start, end); - this.normal.set(normal.x(), normal.y(), normal.z()); - } + public void recalculateNormal() { + Vector3f normal = normal(start, end); + this.normal.set(normal.x(), normal.y(), normal.z()); + } - public void render(PoseStack poseStack, VertexConsumer consumer, float x, float y, float z) { - render( - poseStack, consumer, - 0f, 0f, 0f, 0.4f, - x, y, z, - start.x(), start.y(), start.z(), - end.x(), end.y(), end.z(), - normal.x(), normal.y(), normal.z() - ); - } + public void render(PoseStack poseStack, VertexConsumer consumer, float x, float y, float z) { + render( + poseStack, consumer, + 0f, 0f, 0f, 0.4f, + x, y, z, + start.x(), start.y(), start.z(), + end.x(), end.y(), end.z(), + normal.x(), normal.y(), normal.z() + ); + } - public static void render( + public static void render( PoseStack stack, VertexConsumer consumer, float r, float g, float b, float a, float x, float y, float z, float x1, float y1, float z1, float x2, float y2, float z2, float normalX, float normalY, float normalZ - ) { - PoseStack.Pose last = stack.last(); - consumer.vertex(last.pose(), x + x1, y + y1, z + z1).color(r, g, b, a).normal(last, normalX, normalY, normalZ).endVertex(); - consumer.vertex(last.pose(), x + x2, y + y2, z + z2).color(r, g, b, a).normal(last, normalX, normalY, normalZ).endVertex(); - } + ) { + PoseStack.Pose last = stack.last(); + consumer.addVertex(last.pose(), x + x1, y + y1, z + z1) + .setColor(r, g, b, a) + .setNormal(last, normalX, normalY, normalZ); + consumer.addVertex(last.pose(), x + x2, y + y2, z + z2) + .setColor(r, g, b, a) + .setNormal(last, normalX, normalY, normalZ); + } - private static Vector3f normal(Vector3f start, Vector3f end) { - Vector3f diff = new Vector3f(start.x() - end.x(), start.y() - end.y(), start.z() - end.z()); - float sqrt = Mth.sqrt(diff.x() * diff.x() + diff.y() * diff.y() + diff.z() * diff.z()); - return new Vector3f(diff.x() / sqrt, diff.y() / sqrt, diff.z() / sqrt); - } - } \ No newline at end of file + private static Vector3f normal(Vector3f start, Vector3f end) { + Vector3f diff = new Vector3f(start.x() - end.x(), start.y() - end.y(), start.z() - end.z()); + float sqrt = Mth.sqrt(diff.x() * diff.x() + diff.y() * diff.y() + diff.z() * diff.z()); + return new Vector3f(diff.x() / sqrt, diff.y() / sqrt, diff.z() / sqrt); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/screens/CursorScreen.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/screens/CursorScreen.java index 36dae21..963a639 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/screens/CursorScreen.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/client/screens/CursorScreen.java @@ -5,7 +5,6 @@ import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.MultiLineEditBox; import net.minecraft.client.gui.components.events.GuiEventListener; -import org.jetbrains.annotations.ApiStatus; import java.util.List; @@ -15,21 +14,12 @@ public interface CursorScreen { default void setCursor(List listeners, double mouseX, double mouseY) { - setCursor(listeners); for (GuiEventListener child : listeners) { + boolean hovered = child.isMouseOver(mouseX, mouseY); if (child instanceof CursorWidget widget && child.isMouseOver(mouseX, mouseY) && widget.getCursor() != Cursor.DEFAULT) { setCursor(widget.getCursor()); break; - } - } - } - - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "21.0") - default void setCursor(List listeners) { - for (GuiEventListener child : listeners) { - if (child instanceof CursorWidget) continue; - if (child instanceof AbstractWidget widget && widget.isHovered() && widget.visible) { + } else if (child instanceof AbstractWidget widget && hovered && widget.visible) { if (widget.active) { setCursor(widget instanceof EditBox || widget instanceof MultiLineEditBox ? Cursor.TEXT : Cursor.POINTER); } else { diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/CodecMetadataSectionSerializer.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/CodecMetadataSectionSerializer.java deleted file mode 100644 index 90f9ee9..0000000 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/CodecMetadataSectionSerializer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.teamresourceful.resourcefullib.client.utils; - -import com.google.gson.JsonObject; -import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.JsonOps; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.metadata.MetadataSectionSerializer; -import net.minecraft.server.packs.metadata.MetadataSectionType; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -/** - * @deprecated Use {@link MetadataSectionType#fromCodec(String, Codec)} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "21.0") -public record CodecMetadataSectionSerializer(Codec codec, ResourceLocation id) implements MetadataSectionSerializer { - - @Override - public @NotNull String getMetadataSectionName() { - return id.toString(); - } - - @Override - public @NotNull T fromJson(JsonObject json) { - DataResult result = codec.parse(JsonOps.INSTANCE, json); - if (result.error().isPresent()) { - throw new IllegalStateException("Failed to parse " + id + " metadata section: " + result.error().get()); - } - if (result.result().isEmpty()) { - throw new IllegalStateException("Failed to parse " + id + " metadata section: Empty result"); - } - return result.result().get(); - } -} diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/MouseLocationFix.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/MouseLocationFix.java deleted file mode 100644 index 5a8e80d..0000000 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/MouseLocationFix.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.teamresourceful.resourcefullib.client.utils; - -import com.teamresourceful.resourcefullib.common.menu.ContentMenuProvider; -import net.minecraft.client.Minecraft; -import org.jetbrains.annotations.ApiStatus; -import org.lwjgl.glfw.GLFW; - -import java.util.function.Predicate; - -/** - * This class copies the mouse position and sets it back when fix is called if it's been less than a second since the last call. - * This is used to fix the mouse position when a menu is opened and closed. - * - * @deprecated use {@link ContentMenuProvider#resetMouseOnOpen()} instead - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "21.0") -public record MouseLocationFix(double x, double y, Predicate> checker, long time) { - - private static MouseLocationFix fix = null; - - public static void fix(Class screen) { - if (fix != null && fix.checker.test(screen) && System.currentTimeMillis() - fix.time() < 1000) { - GLFW.glfwSetCursorPos(Minecraft.getInstance().getWindow().getWindow(), fix.x(), fix.y()); - fix = null; - } - } - - public static void setFix(Predicate> checker) { - double x = Minecraft.getInstance().mouseHandler.xpos(); - double y = Minecraft.getInstance().mouseHandler.ypos(); - fix = new MouseLocationFix(x, y, checker, System.currentTimeMillis()); - } -} diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/RenderUtils.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/RenderUtils.java index e982642..1efec56 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/RenderUtils.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/client/utils/RenderUtils.java @@ -5,11 +5,9 @@ import com.teamresourceful.resourcefullib.client.scissor.ClosingScissorBox; import com.teamresourceful.resourcefullib.client.scissor.ScissorBoxStack; import com.teamresourceful.resourcefullib.common.exceptions.UtilityClassException; -import com.teamresourceful.resourcefullib.common.utils.types.Bound; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.Rect2i; -import org.jetbrains.annotations.ApiStatus; import org.joml.Matrix4f; import org.joml.Vector2i; import org.joml.Vector2ic; @@ -21,20 +19,6 @@ private RenderUtils() throws UtilityClassException { throw new UtilityClassException(); } - /** - * Get the current bounds for a GL scissor. - * @deprecated Use {@link #getScissorRect(Minecraft, PoseStack, int, int, int, int)} instead. - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "21.0") - public static Bound getScissorBounds(Minecraft minecraft, PoseStack stack, int x, int y, int width, int height) { - float guiScale = (float) minecraft.getWindow().getGuiScale(); - Vector2ic translation = getTranslation(stack); - float translationX = translation.x() * guiScale; - float translationY = translation.y() * guiScale; - return new Bound((int) (translationX + x * guiScale), (int) (Minecraft.getInstance().getWindow().getHeight() - y * guiScale - translationY - height * guiScale), (int) (width * guiScale), (int) (height * guiScale)); - } - /** * Get the current bounds for a GL scissor. */ diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ExtraByteCodecs.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ExtraByteCodecs.java index 2a1d191..e889ae7 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ExtraByteCodecs.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ExtraByteCodecs.java @@ -32,7 +32,7 @@ private ExtraByteCodecs() throws UtilityClassException { throw new UtilityClassException(); } - public static final ByteCodec RESOURCE_LOCATION = ByteCodec.STRING.map(ResourceLocation::new, ResourceLocation::toString); + public static final ByteCodec RESOURCE_LOCATION = ByteCodec.STRING.map(ResourceLocation::parse, ResourceLocation::toString); public static final ByteCodec> DIMENSION = resourceKey(Registries.DIMENSION); public static final ByteCodec BLOCK_POS = ByteCodec.LONG.map(BlockPos::of, BlockPos::asLong); diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ItemStackByteCodec.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ItemStackByteCodec.java deleted file mode 100644 index 0e188e2..0000000 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/bytecodecs/ItemStackByteCodec.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.teamresourceful.resourcefullib.common.bytecodecs; - -import com.teamresourceful.bytecodecs.base.ByteCodec; -import com.teamresourceful.bytecodecs.base.object.ObjectByteCodec; -import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; - -/** - * Use {@link ExtraByteCodecs#ITEM_STACK} instead. - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "21.0") -public class ItemStackByteCodec { - - public static final ByteCodec CODEC = StreamCodecByteCodec.ofRegistry(ItemStack.STREAM_CODEC); - - public static final ByteCodec EMPTY_ITEM = ByteCodec.unit(ItemStack.EMPTY); - public static final ByteCodec SINGLE_ITEM = ExtraByteCodecs.ITEM.map(ItemStack::new, ItemStack::getItem); - public static final ByteCodec ITEM_WITH_COUNT = ObjectByteCodec.create( - ExtraByteCodecs.ITEM.fieldOf(ItemStack::getItem), - ByteCodec.INT.fieldOf(ItemStack::getCount), - ItemStack::new - ); - public static final ByteCodec ITEM_WITH_COUNT_AND_TAG = CODEC; -} diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/predicates/EnchantmentPredicate.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/predicates/EnchantmentPredicate.java deleted file mode 100644 index 0a820da..0000000 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/predicates/EnchantmentPredicate.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.teamresourceful.resourcefullib.common.codecs.predicates; - -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import com.teamresourceful.resourcefullib.common.codecs.tags.HolderSetCodec; -import net.minecraft.advancements.critereon.MinMaxBounds; -import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.item.enchantment.Enchantment; - -import java.util.Map; - -public record EnchantmentPredicate(HolderSet enchantments, MinMaxBounds.Ints level) { - - public static final EnchantmentPredicate ANY = new EnchantmentPredicate(HolderSet.direct(), MinMaxBounds.Ints.ANY); - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - HolderSetCodec.of(BuiltInRegistries.ENCHANTMENT).fieldOf("enchantments").orElse(HolderSet.direct()).forGetter(EnchantmentPredicate::enchantments), - MinMaxBounds.Ints.CODEC.fieldOf("level").orElse(MinMaxBounds.Ints.ANY).forGetter(EnchantmentPredicate::level) - ).apply(instance, EnchantmentPredicate::new)); - - public boolean matches(Enchantment enchantment) { - Holder holder = BuiltInRegistries.ENCHANTMENT.wrapAsHolder(enchantment); - return this == ANY || (enchantments != null && enchantments.contains(holder)); - } - - public boolean matches(Enchantment enchantment, int level) { - if (enchantments.size() == 0) { - return this.level.matches(level); - } - return this.matches(enchantment) && this.level.matches(level); - } - - public boolean matches(Map enchantments) { - if (this == ANY) return true; - for (Map.Entry entry : enchantments.entrySet()) { - if (this.matches(entry.getKey(), entry.getValue())) return true; - } - return false; - } - -} diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/recipes/ItemStackCodec.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/recipes/ItemStackCodec.java index 2b2130e..57e6fa3 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/recipes/ItemStackCodec.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/common/codecs/recipes/ItemStackCodec.java @@ -1,14 +1,12 @@ package com.teamresourceful.resourcefullib.common.codecs.recipes; import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; import com.teamresourceful.resourcefullib.common.codecs.CodecExtras; import com.teamresourceful.resourcefullib.common.exceptions.UtilityClassException; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; -import org.jetbrains.annotations.ApiStatus; public final class ItemStackCodec { @@ -18,17 +16,6 @@ public final class ItemStackCodec { public static final Codec CODEC = CodecExtras.eitherRight(Codec.either(STRING_EITHER, STACK_CODEC)); - /** - * @deprecated Use {@link com.teamresourceful.resourcefullib.common.bytecodecs.ExtraByteCodecs#ITEM_STACK} instead. - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "21.0") - public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - CodecExtras.registryId(BuiltInRegistries.ITEM).fieldOf("id").forGetter(ItemStack::getItem), - Codec.INT.fieldOf("count").orElse(1).forGetter(ItemStack::getCount), - DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter(ItemStack::getComponentsPatch) - ).apply(instance, ItemStackCodec::createItemStack)); - private ItemStackCodec() throws UtilityClassException { throw new UtilityClassException(); } diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/ResourcefulCreativeTab.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/ResourcefulCreativeTab.java deleted file mode 100644 index 71774d1..0000000 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/ResourcefulCreativeTab.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.teamresourceful.resourcefullib.common.item.tabs; - -import com.teamresourceful.resourcefullib.common.exceptions.NotImplementedException; -import com.teamresourceful.resourcefullib.common.registry.ResourcefulRegistry; -import dev.architectury.injectables.annotations.ExpectPlatform; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.ItemLike; -import org.jetbrains.annotations.ApiStatus; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Stream; - -/** - * @deprecated Use {@link ResourcefulCreativeModeTab} instead. - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "21.0") -public class ResourcefulCreativeTab { - - public final ResourceLocation id; - public Supplier icon; - public boolean hideScrollBar; - public boolean hideTitle; - - public final List> registries = new ArrayList<>(); - public final List> stacks = new ArrayList<>(); - - public final List>> contents = new ArrayList<>(); - - public ResourcefulCreativeTab(ResourceLocation id) { - this.id = id; - } - - public ResourcefulCreativeTab setItemIcon(Supplier icon) { - return setStackIcon(() -> new ItemStack(icon.get())); - } - - public ResourcefulCreativeTab setStackIcon(Supplier icon) { - this.icon = icon; - return this; - } - - public ResourcefulCreativeTab hideTitle() { - this.hideTitle = true; - return this; - } - - public ResourcefulCreativeTab hideScrollBar() { - this.hideScrollBar = true; - return this; - } - - public > ResourcefulCreativeTab addRegistry(T registry) { - return addContent(() -> registry.boundStream().map(ItemStack::new)); - } - - public ResourcefulCreativeTab addStack(Supplier stack) { - return addContent(() -> Stream.of(stack.get())); - } - - public ResourcefulCreativeTab addStack(ItemStack stack) { - return addStack(() -> stack); - } - - public ResourcefulCreativeTab addStack(ItemLike item) { - return addStack(new ItemStack(item)); - } - - public ResourcefulCreativeTab addContent(Supplier> content) { - this.contents.add(content); - return this; - } - - public Supplier build() { - return create(this); - } - - @ExpectPlatform - private static Supplier create(ResourcefulCreativeTab tab) { - throw new NotImplementedException(); - } - - -} diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/menu/ContentMenuProvider.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/menu/ContentMenuProvider.java index dd2346d..e2a0459 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/menu/ContentMenuProvider.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/common/menu/ContentMenuProvider.java @@ -2,19 +2,10 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; -import org.jetbrains.annotations.ApiStatus; public interface ContentMenuProvider> extends MenuProvider { - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "21.0") - default C createContent() { - throw new UnsupportedOperationException("createContent"); - } - - default C createContent(ServerPlayer player) { - return createContent(); - } + C createContent(ServerPlayer player); default void openMenu(ServerPlayer player) { MenuContentHelper.open(player, this); diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/network/Network.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/network/Network.java index b203f41..5d05b35 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/network/Network.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/common/network/Network.java @@ -15,6 +15,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.LevelChunk; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; import java.util.Collection; @@ -33,13 +34,15 @@ public Network(ResourceLocation channel, int protocolVersion, boolean optional) } @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "1.22") public Network(String modid, int protocolVersion, String channel) { this(modid, protocolVersion, channel, false); } @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "1.22") public Network(String modid, int protocolVersion, String channel, boolean optional) { - this.networking = getNetwork(new ResourceLocation(modid, channel), protocolVersion, optional); + this.networking = getNetwork(ResourceLocation.fromNamespaceAndPath(modid, channel), protocolVersion, optional); this.optional = optional; } @@ -116,6 +119,7 @@ public final boolean canSendToPlayer(Player player, PacketType type) { @ExpectPlatform @ApiStatus.Internal + @Contract(pure = true) public static Networking getNetwork(ResourceLocation channel, int protocolVersion, boolean optional) { throw new NotImplementedException(); } diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/recipe/CodecRecipe.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/recipe/CodecRecipe.java index a5fde03..ca9e4c7 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/recipe/CodecRecipe.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/common/recipe/CodecRecipe.java @@ -1,13 +1,13 @@ package com.teamresourceful.resourcefullib.common.recipe; import net.minecraft.core.HolderLookup; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import org.jetbrains.annotations.NotNull; -public interface CodecRecipe extends Recipe { +public interface CodecRecipe extends Recipe { @Override default boolean isSpecial() { diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/common/utils/types/Bound.java b/common/src/main/java/com/teamresourceful/resourcefullib/common/utils/types/Bound.java deleted file mode 100644 index 8baa727..0000000 --- a/common/src/main/java/com/teamresourceful/resourcefullib/common/utils/types/Bound.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.teamresourceful.resourcefullib.common.utils.types; - -import org.jetbrains.annotations.ApiStatus; - -/** - * @deprecated Use {@link net.minecraft.client.renderer.Rect2i} instead. - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "21.0") -public record Bound(int x, int y, int width, int height) {} \ No newline at end of file diff --git a/fabric/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/fabric/ResourcefulCreativeTabImpl.java b/fabric/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/fabric/ResourcefulCreativeTabImpl.java deleted file mode 100644 index c66e938..0000000 --- a/fabric/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/fabric/ResourcefulCreativeTabImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.teamresourceful.resourcefullib.common.item.tabs.fabric; - -import com.teamresourceful.resourcefullib.common.item.tabs.ResourcefulCreativeTab; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.CreativeModeTab; - -import java.util.function.Supplier; - -public class ResourcefulCreativeTabImpl { - public static Supplier create(ResourcefulCreativeTab tab) { - var group = FabricItemGroup.builder() - .icon(() -> tab.icon.get()) - .title(Component.translatable("itemGroup." + tab.id.getNamespace() + "." + tab.id.getPath())); - if (tab.hideScrollBar) group.noScrollBar(); - if (tab.hideTitle) group.hideTitle(); - group.displayItems((params, output) -> { - tab.registries.forEach(registry -> registry.boundStream().forEach(output::accept)); - tab.stacks.stream().map(Supplier::get).forEach(output::accept); - - tab.contents.stream().flatMap(Supplier::get).forEach(output::accept); - }); - CreativeModeTab tab1 = group.build(); - Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, tab.id, tab1); - return () -> tab1; - } -} diff --git a/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulFluidRegistry.java b/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulFluidRegistry.java index fb1eee0..301dc28 100644 --- a/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulFluidRegistry.java +++ b/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulFluidRegistry.java @@ -24,7 +24,7 @@ public FabricResourcefulFluidRegistry(String id) { @Override public RegistryEntry register(String name, FluidProperties properties) { - ResourceLocation id = new ResourceLocation(this.id, name); + ResourceLocation id = ResourceLocation.fromNamespaceAndPath(this.id, name); return this.entries.add(new Entry(id, new InternalFluidData(id, properties))); } diff --git a/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulRegistry.java b/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulRegistry.java index 54a9772..3455a92 100644 --- a/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulRegistry.java +++ b/fabric/src/main/java/com/teamresourceful/resourcefullib/common/registry/fabric/FabricResourcefulRegistry.java @@ -23,12 +23,12 @@ public FabricResourcefulRegistry(Registry registry, String id) { @Override public RegistryEntry register(String id, Supplier supplier) { - return entries.add(FabricRegistryEntry.of(this.registry, new ResourceLocation(this.id, id), supplier)); + return entries.add(FabricRegistryEntry.of(this.registry, ResourceLocation.fromNamespaceAndPath(this.id, id), supplier)); } @Override public HolderRegistryEntry registerHolder(String id, Supplier supplier) { - return entries.add(FabricHolderRegistryEntry.of(this.registry, new ResourceLocation(this.id, id), supplier)); + return entries.add(FabricHolderRegistryEntry.of(this.registry, ResourceLocation.fromNamespaceAndPath(this.id, id), supplier)); } @Override diff --git a/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricHighlightHandler.java b/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricHighlightHandler.java index 2b699b8..12c3778 100644 --- a/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricHighlightHandler.java +++ b/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricHighlightHandler.java @@ -9,6 +9,6 @@ public class FabricHighlightHandler extends HighlightHandler implements Identifi @Override public ResourceLocation getFabricId() { - return new ResourceLocation(ResourcefulLib.MOD_ID, "highlights"); + return ResourceLocation.fromNamespaceAndPath(ResourcefulLib.MOD_ID, "highlights"); } } diff --git a/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricResourcePackHandler.java b/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricResourcePackHandler.java index a3a811f..f7e4a9f 100644 --- a/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricResourcePackHandler.java +++ b/fabric/src/main/java/com/teamresourceful/resourcefullib/fabric/FabricResourcePackHandler.java @@ -40,7 +40,7 @@ private static void loadPack(ModContainer container, CustomValue value) { try { String name = value.getAsString(); ResourceManagerHelper.registerBuiltinResourcePack( - new ResourceLocation(container.getMetadata().getId(), name), + ResourceLocation.fromNamespaceAndPath(container.getMetadata().getId(), name), container, createDescription(null, name), ResourcePackActivationType.NORMAL @@ -48,7 +48,7 @@ private static void loadPack(ModContainer container, CustomValue value) { } catch (Exception ignored) { var object = value.getAsObject(); String name = object.get("name").getAsString(); - ResourceLocation id = new ResourceLocation(container.getMetadata().getId(), name); + ResourceLocation id = ResourceLocation.fromNamespaceAndPath(container.getMetadata().getId(), name); Component description = createDescription(Optionull.map(object.get("description"), CustomValue::getAsString), name); ResourcePackActivationType type = Optionull.mapOrDefault(object.get("required"), CustomValue::getAsBoolean, false) ? ResourcePackActivationType.ALWAYS_ENABLED : ResourcePackActivationType.NORMAL; ResourceManagerHelper.registerBuiltinResourcePack(id, container, description, type); diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 9b6b91f..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,67 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" -} - -architectury { - platformSetupLoomIde() - forge() -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common -} - -dependencies { - forge "net.minecraftforge:forge:$forge_version" - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - - include implementation("com.teamresourceful:yabn:$yabn_version") - include implementation("com.teamresourceful:bytecodecs:$bytecodecs_version") -} - -processResources { - inputs.property "version", version - - filesMatching("META-INF/mods.toml") { - expand "version": version - } -} - -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveAppendix.set "$project.name-$mc_version" - archiveClassifier.set "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar - archiveAppendix.set "$project.name-$mc_version" - archiveClassifier.set null -} - -jar { - archiveAppendix.set "$project.name-$mc_version" - archiveClassifier.set "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index 32f842a..0000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/forge/ResourcefulCreativeModeTabImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/forge/ResourcefulCreativeModeTabImpl.java deleted file mode 100644 index 8dba0e6..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/forge/ResourcefulCreativeModeTabImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.teamresourceful.resourcefullib.common.item.tabs.forge; - -import com.teamresourceful.resourcefullib.common.item.tabs.ResourcefulCreativeModeTab; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.CreativeModeTab; - -import java.util.function.Supplier; - -public class ResourcefulCreativeModeTabImpl { - public static CreativeModeTab create(ResourcefulCreativeModeTab tab) { - var creativeTab = CreativeModeTab.builder() - .icon(() -> tab.icon.get()) - .title(Component.translatable("itemGroup." + tab.id.getNamespace() + "." + tab.id.getPath())); - if (tab.hideScrollBar) creativeTab.noScrollBar(); - if (tab.hideTitle) creativeTab.hideTitle(); - creativeTab.displayItems((params, output) -> tab.contents.stream().flatMap(Supplier::get).forEach(output::accept)); - return creativeTab.build(); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/forge/ResourcefulCreativeTabImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/forge/ResourcefulCreativeTabImpl.java deleted file mode 100644 index 25f10ba..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/forge/ResourcefulCreativeTabImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.teamresourceful.resourcefullib.common.item.tabs.forge; - -import com.teamresourceful.resourcefullib.common.item.tabs.ResourcefulCreativeTab; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.RegistryObject; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; - -public class ResourcefulCreativeTabImpl { - - private static final Map> CREATIVE_TABS = new ConcurrentHashMap<>(); - - public static Supplier create(ResourcefulCreativeTab tab) { - return Entry.of(tab); - } - - private static RegistryObject register(ResourceLocation id, Supplier tab) { - var register = CREATIVE_TABS.computeIfAbsent(id.getNamespace(), namespace -> { - var registry = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, namespace); - registry.register(FMLJavaModLoadingContext.get().getModEventBus()); - return registry; - }); - return register.register(id.getPath(), tab); - } - - private record Entry(RegistryObject builtTab) implements Supplier { - - public static Entry of(ResourcefulCreativeTab tab) { - var creativeTab = CreativeModeTab.builder() - .icon(() -> tab.icon.get()) - .title(Component.translatable("itemGroup." + tab.id.getNamespace() + "." + tab.id.getPath())); - if (tab.hideScrollBar) creativeTab.noScrollBar(); - if (tab.hideTitle) creativeTab.hideTitle(); - creativeTab.displayItems((params, output) -> { - tab.registries.forEach(registry -> registry.boundStream().forEach(output::accept)); - tab.stacks.stream().map(Supplier::get).forEach(output::accept); - - tab.contents.stream().flatMap(Supplier::get).forEach(output::accept); - }); - return new Entry(register(tab.id, creativeTab::build)); - } - - @Override - public CreativeModeTab get() { - return builtTab.get(); - } - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/menu/forge/MenuContentHelperImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/menu/forge/MenuContentHelperImpl.java deleted file mode 100644 index 7be963c..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/menu/forge/MenuContentHelperImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.teamresourceful.resourcefullib.common.menu.forge; - -import com.teamresourceful.resourcefullib.common.menu.ContentMenuProvider; -import com.teamresourceful.resourcefullib.common.menu.MenuContent; -import com.teamresourceful.resourcefullib.common.menu.MenuContentHelper; -import com.teamresourceful.resourcefullib.common.menu.MenuContentSerializer; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.MenuType; -import net.minecraftforge.common.extensions.IForgeMenuType; - -import java.util.Optional; - -public class MenuContentHelperImpl { - public static > MenuType create(MenuContentHelper.MenuFactory factory, MenuContentSerializer serializer) { - return IForgeMenuType.create((id, inventory, data) -> { - if (serializer != null) { - return factory.create(id, inventory, Optional.ofNullable(serializer.from(data))); - } - return factory.create(id, inventory, Optional.empty()); - }); - } - - public static > void open(ServerPlayer player, ContentMenuProvider provider) { - player.openMenu(provider, buf -> { - C content = provider.createContent(player); - if (content != null) { - content.serializer().to(buf, content); - } - }); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/network/forge/ForgeNetworking.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/network/forge/ForgeNetworking.java deleted file mode 100644 index f0b66cd..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/network/forge/ForgeNetworking.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.teamresourceful.resourcefullib.common.network.forge; - -import com.teamresourceful.resourcefullib.common.network.Packet; -import com.teamresourceful.resourcefullib.common.network.base.ClientboundPacketType; -import com.teamresourceful.resourcefullib.common.network.base.Networking; -import com.teamresourceful.resourcefullib.common.network.base.PacketType; -import com.teamresourceful.resourcefullib.common.network.base.ServerboundPacketType; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.network.Channel; -import net.minecraftforge.network.ChannelBuilder; -import net.minecraftforge.network.PacketDistributor; -import net.minecraftforge.network.SimpleChannel; - -public class ForgeNetworking implements Networking { - - private final SimpleChannel channel; - - public ForgeNetworking(ResourceLocation name, int protocolVersion, boolean optional) { - Channel.VersionTest test = optional ? - Channel.VersionTest.ACCEPT_MISSING.or(Channel.VersionTest.ACCEPT_VANILLA) : - Channel.VersionTest.exact(protocolVersion); - - this.channel = ChannelBuilder.named(name) - .networkProtocolVersion(protocolVersion) - .acceptedVersions(test) - .simpleChannel(); - } - - @Override - public > void register(ClientboundPacketType type) { - this.channel.messageBuilder(type.type()) - .decoder(type::decode) - .encoder(type::encode) - .consumerNetworkThread((msg, ctx) -> { - ctx.enqueueWork(() -> type.handle(msg).run()); - ctx.setPacketHandled(true); - }) - .add(); - } - - @Override - public > void register(ServerboundPacketType type) { - this.channel.messageBuilder(type.type()) - .decoder(type::decode) - .encoder(type::encode) - .consumerNetworkThread((msg, ctx) -> { - ctx.enqueueWork(() -> type.handle(msg).accept(ctx.getSender())); - ctx.setPacketHandled(true); - }) - .add(); - } - - @Override - public > void sendToServer(T message) { - this.channel.send(message, PacketDistributor.SERVER.noArg()); - } - - @Override - public > void sendToPlayer(T message, ServerPlayer player) { - this.channel.send(message, PacketDistributor.PLAYER.with(player)); - } - - @Override - public boolean canSendToPlayer(ServerPlayer player, PacketType type) { - return channel.isRemotePresent(player.connection.getConnection()); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/network/forge/NetworkImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/network/forge/NetworkImpl.java deleted file mode 100644 index 70b49a0..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/network/forge/NetworkImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.teamresourceful.resourcefullib.common.network.forge; - -import com.teamresourceful.resourcefullib.common.network.base.Networking; -import net.minecraft.resources.ResourceLocation; - -public class NetworkImpl { - public static Networking getNetwork(ResourceLocation channel, int protocolVersion, boolean optional) { - return new ForgeNetworking(channel, protocolVersion, optional); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/networking/forge/PacketChannelHelperImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/networking/forge/PacketChannelHelperImpl.java deleted file mode 100644 index 233e1eb..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/networking/forge/PacketChannelHelperImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.teamresourceful.resourcefullib.common.networking.forge; - -import com.teamresourceful.resourcefullib.common.networking.base.Packet; -import com.teamresourceful.resourcefullib.common.networking.base.PacketHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.network.Channel; -import net.minecraftforge.network.ChannelBuilder; -import net.minecraftforge.network.PacketDistributor; -import net.minecraftforge.network.SimpleChannel; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.BooleanSupplier; - -public class PacketChannelHelperImpl { - - public static final Map CHANNELS = new HashMap<>(); - - public static void registerChannel(ResourceLocation name, int protocolVersion, BooleanSupplier optional) { - Channel.VersionTest test = optional.getAsBoolean() ? - Channel.VersionTest.ACCEPT_MISSING.or(Channel.VersionTest.ACCEPT_VANILLA) : - Channel.VersionTest.exact(protocolVersion); - - CHANNELS.put(name, ChannelBuilder.named(name) - .networkProtocolVersion(protocolVersion) - .acceptedVersions(test) - .simpleChannel()); - } - - public static > void registerS2CPacket(ResourceLocation name, ResourceLocation id, PacketHandler handler, Class packetClass) { - SimpleChannel channel = CHANNELS.get(name); - if (channel == null) { - throw new IllegalStateException("Channel " + name + " not registered"); - } - channel.messageBuilder(packetClass) - .decoder(handler::decode) - .encoder(handler::encode) - .consumerNetworkThread((msg, context) -> { - Player player = context.getSender() == null ? getPlayer() : null; - if (player != null) { - context.enqueueWork(() -> handler.handle(msg).apply(player, player.level())); - } - context.setPacketHandled(true); - }) - .add(); - } - - public static > void registerC2SPacket(ResourceLocation name, ResourceLocation id, PacketHandler handler, Class packetClass) { - SimpleChannel channel = CHANNELS.get(name); - if (channel == null) { - throw new IllegalStateException("Channel " + name + " not registered"); - } - channel.messageBuilder(packetClass) - .decoder(handler::decode) - .encoder(handler::encode) - .consumerNetworkThread((msg, context) -> { - Player player = context.getSender(); - if (player != null) { - context.enqueueWork(() -> handler.handle(msg).apply(player, player.level())); - } - context.setPacketHandled(true); - }) - .add(); - } - - @OnlyIn(Dist.CLIENT) - private static Player getPlayer() { - return Minecraft.getInstance().player; - } - - public static > void sendToServer(ResourceLocation name, T packet) { - SimpleChannel channel = CHANNELS.get(name); - if (channel == null) { - throw new IllegalStateException("Channel " + name + " not registered"); - } - channel.send(packet, PacketDistributor.SERVER.noArg()); - } - - public static > void sendToPlayer(ResourceLocation name, T packet, Player player) { - SimpleChannel channel = CHANNELS.get(name); - if (channel == null) { - throw new IllegalStateException("Channel " + name + " not registered"); - } - if (player instanceof ServerPlayer serverPlayer) { - channel.send(packet, PacketDistributor.PLAYER.with(serverPlayer)); - } - } - - public static boolean canSendPlayerPackets(ResourceLocation name, Player player) { - SimpleChannel channel = CHANNELS.get(name); - if (channel != null && player instanceof ServerPlayer serverPlayer) { - return channel.isRemotePresent(serverPlayer.connection.getConnection()); - } - return false; - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/ForgeIngredient.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/ForgeIngredient.java deleted file mode 100644 index fbc5891..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/ForgeIngredient.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.teamresourceful.resourcefullib.common.recipe.ingredient.forge; - -import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredient; -import it.unimi.dsi.fastutil.ints.IntList; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.stream.Stream; - -public class ForgeIngredient> extends Ingredient { - - private final T ingredient; - @Nullable private ItemStack[] stacks; - @Nullable private IntList stackingIds; - - protected ForgeIngredient(T ingredient) { - super(Stream.of()); - this.ingredient = ingredient; - } - - public T getIngredient() { - return this.ingredient; - } - - @Override - public ItemStack @NotNull [] getItems() { - if (this.stacks == null) this.stacks = this.ingredient.getStacksAsArray(); - return this.stacks; - } - - @Override - public boolean isSimple() { - return !this.ingredient.isComplex(); - } - - @Override - public boolean test(@Nullable ItemStack stack) { - return this.ingredient.test(stack); - } - - @Override - public boolean isEmpty() { - return this.ingredient.isEmpty(); - } - - @Override - public @NotNull IntList getStackingIds() { - if (this.stackingIds == null) { - this.stackingIds = Ingredient.of(getItems()).getStackingIds(); - } - return this.stackingIds; - } - -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/ForgeIngredientSerializer.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/ForgeIngredientSerializer.java deleted file mode 100644 index 71ecbcf..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/ForgeIngredientSerializer.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.teamresourceful.resourcefullib.common.recipe.ingredient.forge; - -import com.mojang.serialization.Codec; -import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredient; -import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredientSerializer; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.crafting.ingredients.IIngredientSerializer; -import org.jetbrains.annotations.NotNull; - -public class ForgeIngredientSerializer> implements IIngredientSerializer> { - - private final CodecIngredientSerializer serializer; - private final Codec> codec; - - public ForgeIngredientSerializer(CodecIngredientSerializer serializer) { - this.serializer = serializer; - this.codec = this.serializer.codec().xmap(ForgeIngredient::new, ForgeIngredient::getIngredient); - } - - public ResourceLocation id() { - return serializer.id(); - } - - @Override - public Codec> codec() { - return codec; - } - - @Override - public ForgeIngredient read(FriendlyByteBuf buf) { - return new ForgeIngredient<>(serializer.network().decode(buf)); - } - - @Override - public void write(@NotNull FriendlyByteBuf buf, @NotNull ForgeIngredient ingredient) { - serializer.network().encode(ingredient.getIngredient(), buf); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/IngredientHelperImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/IngredientHelperImpl.java deleted file mode 100644 index 273f196..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/forge/IngredientHelperImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.teamresourceful.resourcefullib.common.recipe.ingredient.forge; - -import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredient; -import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredientSerializer; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraftforge.common.crafting.ingredients.IIngredientSerializer; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; - -import java.util.HashMap; -import java.util.Map; - -public class IngredientHelperImpl { - - private static final Map>> REGISTRIES = new HashMap<>(); - - public static DeferredRegister> getOrCreate(String namespace) { - return REGISTRIES.computeIfAbsent(namespace, s -> { - var registry = DeferredRegister.create(ForgeRegistries.INGREDIENT_SERIALIZERS.get(), s); - registry.register(FMLJavaModLoadingContext.get().getModEventBus()); - return registry; - }); - } - - public static > Ingredient getIngredient(T ingredient) { - return new ForgeIngredient<>(ingredient); - } - - public static , T extends CodecIngredientSerializer> void registerIngredient(T serializer) { - DeferredRegister> registry = getOrCreate(serializer.id().getNamespace()); - registry.register(serializer.id().getPath(), () -> new ForgeIngredientSerializer<>(serializer)); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ForgeRegistryEntry.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ForgeRegistryEntry.java deleted file mode 100644 index 3e55efc..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ForgeRegistryEntry.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.teamresourceful.resourcefullib.common.registry.forge; - -import com.teamresourceful.resourcefullib.common.registry.RegistryEntry; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.RegistryObject; - -public class ForgeRegistryEntry implements RegistryEntry { - - private final RegistryObject object; - - public ForgeRegistryEntry(RegistryObject object) { - this.object = object; - } - - @Override - public T get() { - return object.get(); - } - - @Override - public ResourceLocation getId() { - return object.getId(); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ForgeResourcefulRegistry.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ForgeResourcefulRegistry.java deleted file mode 100644 index 5a15eab..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ForgeResourcefulRegistry.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.teamresourceful.resourcefullib.common.registry.forge; - -import com.teamresourceful.resourcefullib.common.registry.RegistryEntries; -import com.teamresourceful.resourcefullib.common.registry.RegistryEntry; -import com.teamresourceful.resourcefullib.common.registry.ResourcefulRegistry; -import net.minecraft.core.Registry; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; - -import java.util.Collection; -import java.util.function.Supplier; - -public class ForgeResourcefulRegistry implements ResourcefulRegistry { - - private final DeferredRegister register; - private final RegistryEntries entries = new RegistryEntries<>(); - - public ForgeResourcefulRegistry(Registry registry, String id) { - this.register = DeferredRegister.create(registry.key(), id); - } - - @Override - public RegistryEntry register(String id, Supplier supplier) { - return this.entries.add(new ForgeRegistryEntry<>(register.register(id, supplier))); - } - - @Override - public Collection> getEntries() { - return this.entries.getEntries(); - } - - @Override - public void init() { - IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); - register.register(bus); - } -} \ No newline at end of file diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ResourcefulRegistriesImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ResourcefulRegistriesImpl.java deleted file mode 100644 index 2367ac6..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/registry/forge/ResourcefulRegistriesImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.teamresourceful.resourcefullib.common.registry.forge; - -import com.teamresourceful.resourcefullib.common.registry.ResourcefulRegistry; -import net.minecraft.core.Registry; - -public class ResourcefulRegistriesImpl { - public static ResourcefulRegistry create(Registry registry, String id) { - return new ForgeResourcefulRegistry<>(registry, id); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/forge/HiddenGenericMemoryPack.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/forge/HiddenGenericMemoryPack.java deleted file mode 100644 index c6f72d4..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/forge/HiddenGenericMemoryPack.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.teamresourceful.resourcefullib.common.utils.forge; - -import com.google.gson.JsonObject; -import com.teamresourceful.resourcefullib.common.utils.GenericMemoryPack; -import net.minecraft.server.packs.PackType; - -public class HiddenGenericMemoryPack extends GenericMemoryPack { - protected HiddenGenericMemoryPack(PackType type, String id, JsonObject meta) { - super(type, id, meta); - } - - @Override - public boolean isHidden() { - return true; - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/modinfo/forge/ForgeModInfo.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/modinfo/forge/ForgeModInfo.java deleted file mode 100644 index 9da6b49..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/modinfo/forge/ForgeModInfo.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.teamresourceful.resourcefullib.common.utils.modinfo.forge; - -import com.teamresourceful.resourcefullib.common.utils.modinfo.ModInfo; -import net.minecraftforge.forgespi.language.IModInfo; - -import java.nio.file.Path; -import java.util.List; - -public record ForgeModInfo(IModInfo info) implements ModInfo { - - @Override - public String displayName() { - return info.getDisplayName(); - } - - @Override - public String id() { - return info.getModId(); - } - - @Override - public String version() { - return info.getVersion().toString(); - } - - public List getPaths() { - return List.of(info.getOwningFile().getFile().getFilePath()); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/modinfo/forge/ModInfoUtilsImpl.java b/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/modinfo/forge/ModInfoUtilsImpl.java deleted file mode 100644 index 2abe31f..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/common/utils/modinfo/forge/ModInfoUtilsImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.teamresourceful.resourcefullib.common.utils.modinfo.forge; - -import com.teamresourceful.resourcefullib.common.utils.modinfo.ModInfo; -import net.minecraftforge.fml.ModList; -import org.jetbrains.annotations.Nullable; - -public class ModInfoUtilsImpl { - @Nullable - public static ModInfo getModInfo(String id) { - return ModList.get() - .getModContainerById(id) - .map(modContainer -> new ForgeModInfo(modContainer.getModInfo())) - .orElse(null); - } - - public static int getLoadedMods() { - return ModList.get().size(); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ForgeResourcePackHandler.java b/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ForgeResourcePackHandler.java deleted file mode 100644 index 50164a5..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ForgeResourcePackHandler.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.teamresourceful.resourcefullib.forge; - -import com.electronwill.nightconfig.core.UnmodifiableConfig; -import com.teamresourceful.resourcefullib.common.lib.Constants; -import net.minecraft.SharedConstants; -import net.minecraft.network.chat.CommonComponents; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.PathPackResources; -import net.minecraft.server.packs.repository.Pack; -import net.minecraft.server.packs.repository.PackCompatibility; -import net.minecraft.server.packs.repository.PackSource; -import net.minecraft.world.flag.FeatureFlagSet; -import net.minecraftforge.event.AddPackFindersEvent; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.forgespi.language.IModInfo; -import org.jetbrains.annotations.Nullable; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public final class ForgeResourcePackHandler { - - private static final List PACKS = new ArrayList<>(); - private static final String RESOURCE_PACK_KEY = "resourcefullib:resourcepack"; - - public static void load() { - for (IModInfo mod : ModList.get().getMods()) { - if (mod.getModProperties().containsKey(RESOURCE_PACK_KEY)) { - try { - initMod(mod, mod.getModProperties()); - } catch (Exception e) { - Constants.LOGGER.error("Resourceful Lib failed to load resource pack for mod: " + mod.getDisplayName(), e); - } - } - } - } - - private static void initMod(IModInfo mod, Map metadata) { - for (Object pack : (List) metadata.get(RESOURCE_PACK_KEY)) { - loadPack(mod, pack); - } - } - - private static void loadPack(IModInfo mod, Object value) { - if (value instanceof String string) { - PACKS.add(new ResourcePack(mod, string, null, false)); - } else if (value instanceof UnmodifiableConfig config) { - Map map = config.valueMap(); - String name = getOrThrow(map, "name"); - String description = (String) map.get("description"); - boolean required = (boolean) map.getOrDefault("required", false); - PACKS.add(new ResourcePack(mod, name, description, required)); - } - } - - @SuppressWarnings({"unchecked", "SameParameterValue"}) - private static T getOrThrow(Map map, String id) { - if (!map.containsKey(id)) throw new IllegalStateException("Missing key: " + id); - return (T) map.get(id); - } - - public static void onRegisterPackFinders(AddPackFindersEvent event) { - for (ResourcePack resourcePack : PACKS) { - try { - Path path = resourcePack.mod().getOwningFile() - .getFile().findResource("resourcepacks/" + resourcePack.name()); - - if (!Files.isDirectory(path.resolve(event.getPackType().getDirectory()))) continue; - - final String id = new ResourceLocation(resourcePack.mod().getModId(), resourcePack.name()).toString(); - final Pack.ResourcesSupplier supplier = new PathPackResources.PathResourcesSupplier(path, false); - final Pack.Info info = getInfo(id, supplier, event.getPackType(), resourcePack.required()); - - final Pack pack = Pack.create( - "builtin/" + id, - createDescription(resourcePack.description(), resourcePack.name()), - resourcePack.required(), - new PathPackResources.PathResourcesSupplier(path, false), - info, - Pack.Position.TOP, - resourcePack.required(), - PackSource.create(PackSource.NO_DECORATION, resourcePack.required()) - ); - - event.addRepositorySource((source) -> source.accept(pack)); - } catch (Exception ignored) { - Constants.LOGGER.error("Resourceful Lib failed to init resource pack for mod: " + resourcePack.mod().getDisplayName()); - } - } - } - - private static Pack.Info getInfo(String id, Pack.ResourcesSupplier supplier, PackType type, boolean hidden) { - if (!hidden) { - Pack.Info info = Pack.readPackInfo(id, supplier, SharedConstants.getCurrentVersion().getPackVersion(type)); - if (info != null) { - return info; - } - } - return new Pack.Info(CommonComponents.EMPTY, PackCompatibility.COMPATIBLE, FeatureFlagSet.of(), List.of(), hidden); - } - - private static Component createDescription(@Nullable String description, String name) { - if (description != null) { - return Component.literal(description); - } - return Component.translatableWithFallback("resourcefullib.resourcepack." + name, name); - } - - private record ResourcePack( - IModInfo mod, - String name, - @Nullable String description, - boolean required - ) { - - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ResourcefulLibForge.java b/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ResourcefulLibForge.java deleted file mode 100644 index a467c99..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ResourcefulLibForge.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.teamresourceful.resourcefullib.forge; - -import com.teamresourceful.resourcefullib.ResourcefulLib; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.common.Mod; - -@Mod(ResourcefulLib.MOD_ID) -public class ResourcefulLibForge { - - public ResourcefulLibForge() { - ResourcefulLib.init(); - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ResourcefulLibForgeClient::init); - } -} diff --git a/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ResourcefulLibForgeClient.java b/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ResourcefulLibForgeClient.java deleted file mode 100644 index 9ddb3be..0000000 --- a/forge/src/main/java/com/teamresourceful/resourcefullib/forge/ResourcefulLibForgeClient.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.teamresourceful.resourcefullib.forge; - -import com.teamresourceful.resourcefullib.client.highlights.HighlightHandler; -import com.teamresourceful.resourcefullib.client.sysinfo.SystemInfo; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.commands.Commands; -import net.minecraft.network.chat.Component; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.event.RegisterClientCommandsEvent; -import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; -import net.minecraftforge.client.event.RenderHighlightEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; - -public class ResourcefulLibForgeClient { - - public static void init() { - ForgeResourcePackHandler.load(); - MinecraftForge.EVENT_BUS.addListener(ResourcefulLibForgeClient::onHighlight); - MinecraftForge.EVENT_BUS.addListener(ResourcefulLibForgeClient::onClientCommandRegister); - FMLJavaModLoadingContext.get().getModEventBus().addListener(ResourcefulLibForgeClient::onClientReloadListeners); - FMLJavaModLoadingContext.get().getModEventBus().addListener(ForgeResourcePackHandler::onRegisterPackFinders); - } - - public static void onClientReloadListeners(RegisterClientReloadListenersEvent event) { - event.registerReloadListener(new HighlightHandler()); - } - - public static void onHighlight(RenderHighlightEvent.Block event) { - BlockState state = event.getCamera().getEntity().level().getBlockState(event.getTarget().getBlockPos()); - event.setCanceled(HighlightHandler.onBlockHighlight(event.getCamera().getPosition(), event.getCamera().getEntity(), event.getPoseStack(), event.getTarget().getBlockPos(), state, event.getMultiBufferSource().getBuffer(RenderType.lines()))); - } - - public static void onClientCommandRegister(RegisterClientCommandsEvent event) { - event.getDispatcher().register(Commands.literal("rlib") - .then(Commands.literal("info") - .executes(context -> { - String info = SystemInfo.buildForDiscord(); - Minecraft.getInstance().keyboardHandler.setClipboard(info); - context.getSource().sendSystemMessage(Component.literal("[Resourceful Lib]: Info copied to clipboard!")); - return 1; - }) - )); - } -} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index efaf203..0000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,25 +0,0 @@ -modLoader = "javafml" -loaderVersion = "[48,)" -license = "MIT" -issueTrackerURL="https://github.com/Team-Resourceful/ResoucefulLib/issues/new/choose" - -[[mods]] - modId = "resourcefullib" - version = "${version}" - displayName = "Resourceful Lib" - authors = "ThatGravyBoat, Epic_Oreo" - description = "Team Resourceful Library" - -[[dependencies.resourcefullib]] - modId = "forge" - mandatory = true - versionRange = "[48,)" - ordering = "NONE" - side = "BOTH" - -[[dependencies.resourcefullib]] - modId = "minecraft" - mandatory = true - versionRange = "[1.20.2,)" - ordering = "NONE" - side = "BOTH" \ No newline at end of file diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index a043d18..0000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Resourceful Lib", - "pack_format": 13 - } -} diff --git a/gradle.properties b/gradle.properties index 4b1e792..84c90ba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ org.gradle.jvmargs=-Xmx2048M -mc_version=1.20.6 +mc_version=1.21 enabled_platforms=fabric,neoforge archives_base_name=resourcefullib maven_group=com.teamresourceful.resourcefullib fabric_loader_version=0.15.11 -fabric_api_version=0.100.0+1.20.6 +fabric_api_version=0.100.1+1.21 -neoforge_version=20.6.115 +neoforge_version=21.0.0-beta yabn_version=1.0.3 bytecodecs_version=1.1.0 diff --git a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/neoforge/ResourcefulCreativeTabImpl.java b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/neoforge/ResourcefulCreativeTabImpl.java deleted file mode 100644 index 040a1bd..0000000 --- a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/item/tabs/neoforge/ResourcefulCreativeTabImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.teamresourceful.resourcefullib.common.item.tabs.neoforge; - -import com.teamresourceful.resourcefullib.common.item.tabs.ResourcefulCreativeTab; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; -import net.neoforged.neoforge.registries.DeferredHolder; -import net.neoforged.neoforge.registries.DeferredRegister; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; - -public class ResourcefulCreativeTabImpl { - - private static final Map> CREATIVE_TABS = new ConcurrentHashMap<>(); - - public static Supplier create(ResourcefulCreativeTab tab) { - return Entry.of(tab); - } - - private static DeferredHolder register(ResourceLocation id, Supplier tab) { - var register = CREATIVE_TABS.computeIfAbsent(id.getNamespace(), namespace -> { - var registry = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, namespace); - registry.register(FMLJavaModLoadingContext.get().getModEventBus()); - return registry; - }); - return register.register(id.getPath(), tab); - } - - private record Entry(DeferredHolder builtTab) implements Supplier { - - public static Entry of(ResourcefulCreativeTab tab) { - var creativeTab = CreativeModeTab.builder() - .icon(() -> tab.icon.get()) - .title(Component.translatable("itemGroup." + tab.id.getNamespace() + "." + tab.id.getPath())); - if (tab.hideScrollBar) creativeTab.noScrollBar(); - if (tab.hideTitle) creativeTab.hideTitle(); - creativeTab.displayItems((params, output) -> { - tab.registries.forEach(registry -> registry.boundStream().forEach(output::accept)); - tab.stacks.stream().map(Supplier::get).forEach(output::accept); - - tab.contents.stream().flatMap(Supplier::get).forEach(output::accept); - }); - return new Entry(register(tab.id, creativeTab::build)); - } - - @Override - public CreativeModeTab get() { - return builtTab.get(); - } - } -} diff --git a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/neoforge/IngredientHelperImpl.java b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/neoforge/IngredientHelperImpl.java index 871ce06..8ee82f0 100644 --- a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/neoforge/IngredientHelperImpl.java +++ b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/recipe/ingredient/neoforge/IngredientHelperImpl.java @@ -6,7 +6,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.crafting.Ingredient; -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; +import net.neoforged.fml.ModLoadingContext; import net.neoforged.neoforge.common.crafting.IngredientType; import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.NeoForgeRegistries; @@ -21,7 +21,7 @@ public class IngredientHelperImpl { private static DeferredRegister> getOrCreate(String namespace) { return REGISTRIES.computeIfAbsent(namespace, s -> { var registry = DeferredRegister.create(NeoForgeRegistries.INGREDIENT_TYPES, s); - registry.register(FMLJavaModLoadingContext.get().getModEventBus()); + registry.register(ModLoadingContext.get().getActiveContainer().getEventBus()); return registry; }); } diff --git a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulFluidRegistry.java b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulFluidRegistry.java index cbba5e4..b95eb6f 100644 --- a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulFluidRegistry.java +++ b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulFluidRegistry.java @@ -8,7 +8,7 @@ import com.teamresourceful.resourcefullib.common.registry.RegistryEntries; import com.teamresourceful.resourcefullib.common.registry.RegistryEntry; import net.minecraft.resources.ResourceLocation; -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; +import net.neoforged.fml.ModLoadingContext; import net.neoforged.neoforge.fluids.FluidType; import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.NeoForgeRegistries; @@ -28,7 +28,7 @@ public NeoForgeResourcefulFluidRegistry(String id) { @Override public RegistryEntry register(String name, FluidProperties properties) { - ResourceLocation rid = new ResourceLocation(this.id, name); + ResourceLocation rid = ResourceLocation.fromNamespaceAndPath(this.id, name); return this.entries.add(new Entry( rid, new InternalFluidData( @@ -46,6 +46,6 @@ public Collection> getEntries() { @Override public void init() { - this.registry.register(FMLJavaModLoadingContext.get().getModEventBus()); + this.registry.register(ModLoadingContext.get().getActiveContainer().getEventBus()); } } diff --git a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulRegistry.java b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulRegistry.java index dc6411f..81ff344 100644 --- a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulRegistry.java +++ b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/registry/neoforge/NeoForgeResourcefulRegistry.java @@ -5,7 +5,7 @@ import com.teamresourceful.resourcefullib.common.registry.RegistryEntry; import com.teamresourceful.resourcefullib.common.registry.ResourcefulRegistry; import net.minecraft.core.Registry; -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; +import net.neoforged.fml.ModLoadingContext; import net.neoforged.neoforge.registries.DeferredRegister; import java.util.Collection; @@ -37,6 +37,6 @@ public Collection> getEntries() { @Override public void init() { - register.register(FMLJavaModLoadingContext.get().getModEventBus()); + register.register(ModLoadingContext.get().getActiveContainer().getEventBus()); } } \ No newline at end of file diff --git a/neoforge/src/main/java/com/teamresourceful/resourcefullib/neoforge/NeoForgeResourcePackHandler.java b/neoforge/src/main/java/com/teamresourceful/resourcefullib/neoforge/NeoForgeResourcePackHandler.java index e3254a6..946d989 100644 --- a/neoforge/src/main/java/com/teamresourceful/resourcefullib/neoforge/NeoForgeResourcePackHandler.java +++ b/neoforge/src/main/java/com/teamresourceful/resourcefullib/neoforge/NeoForgeResourcePackHandler.java @@ -75,7 +75,7 @@ public static void onRegisterPackFinders(AddPackFindersEvent event) { if (!Files.isDirectory(path.resolve(event.getPackType().getDirectory()))) continue; - final String id = new ResourceLocation(resourcePack.mod().getModId(), resourcePack.name()).toString(); + final String id = ResourceLocation.fromNamespaceAndPath(resourcePack.mod().getModId(), resourcePack.name()).toString(); final Pack.ResourcesSupplier supplier = new PathPackResources.PathResourcesSupplier(path); final PackLocationInfo locationInfo = new PackLocationInfo( id, diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index a85147d..7ad6544 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -16,13 +16,13 @@ issueTrackerURL="https://github.com/Team-Resourceful/ResoucefulLib/issues/new/ch [[dependencies.resourcefullib]] modId = "neoforge" type = "required" - versionRange = "[20.5.3-beta,)" + versionRange = "[21.0.0-beta,)" ordering = "NONE" side = "BOTH" [[dependencies.resourcefullib]] modId = "minecraft" type = "required" - versionRange = "[1.20.5,)" + versionRange = "[1.21,)" ordering = "NONE" side = "BOTH" diff --git a/settings.gradle b/settings.gradle index caaa45b..78aa05e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,7 @@ pluginManagement { maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } maven { url "https://maven.minecraftforge.net/" } - maven { url "https://maven.resourcefulbees.com/repository/maven-public/"} + maven { url "https://maven.teamresourceful.com/repository/maven-public/"} gradlePluginPortal() } } @@ -14,7 +14,6 @@ plugins { include("common") include("fabric") -//include("forge") include("neoforge") rootProject.name = "Resourceful Lib" diff --git a/templates/nightly_embed.json.template b/templates/nightly_embed.json.template index f40dae3..2186ac0 100644 --- a/templates/nightly_embed.json.template +++ b/templates/nightly_embed.json.template @@ -44,7 +44,7 @@ }, { "name": "Download", - "value": "[Forge](https://nexus.resourcefulbees.com/repository/maven-public/com/teamresourceful/resourcefullib/resourcefullib-forge-${mc_version}/${version}/resourcefullib-forge-${mc_version}-${version}.jar)\\n[Fabric](https://nexus.resourcefulbees.com/repository/maven-public/com/teamresourceful/resourcefullib/resourcefullib-fabric-${mc_version}/${version}/resourcefullib-fabric-${mc_version}-${version}.jar)" + "value": "[Forge](https://nexus.resourcefulbees.com/repository/maven-public/com/teamresourceful/resourcefullib/resourcefullib-neoforge-${mc_version}/${version}/resourcefullib-forge-${mc_version}-${version}.jar)\\n[Fabric](https://nexus.resourcefulbees.com/repository/maven-public/com/teamresourceful/resourcefullib/resourcefullib-fabric-${mc_version}/${version}/resourcefullib-fabric-${mc_version}-${version}.jar)" } ] } diff --git a/templates/release_embed.json.template b/templates/release_embed.json.template index d748823..9e2e0a5 100644 --- a/templates/release_embed.json.template +++ b/templates/release_embed.json.template @@ -14,9 +14,9 @@ }, { "type": 2, - "label": "Forge", + "label": "NeoForge", "style": 5, - "url": "https://modrinth.com/mod/resourceful-lib/version/${forge_link}" + "url": "https://modrinth.com/mod/resourceful-lib/version/${neoforge_link}" } ] diff --git a/version.properties b/version.properties index 2e7f5be..b45668e 100644 --- a/version.properties +++ b/version.properties @@ -2,6 +2,6 @@ patch=5 buildTime=0 build=0 releaseType=release -currentMCVersion=1.20.6 +currentMCVersion=1.21 initialMCVersion=1.19.1 version=2.5.5