Compare commits
5 Commits
old/1.19.3
...
old/1.20.2
Author | SHA1 | Date | |
---|---|---|---|
e8109b5c96 | |||
5497a18cf8 | |||
ab70d5c9e4 | |||
07b22ff95e | |||
68e6ca1e03 |
@@ -9,7 +9,7 @@ pipeline {
|
|||||||
stage("Notify Discord") {
|
stage("Notify Discord") {
|
||||||
steps {
|
steps {
|
||||||
discordSend webhookURL: env.FDD_WH_ADMIN,
|
discordSend webhookURL: env.FDD_WH_ADMIN,
|
||||||
title: "Deploy Started: CraterLib 1.19.3/4 Deploy #${BUILD_NUMBER}",
|
title: "Deploy Started: CraterLib 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||||
link: env.BUILD_URL,
|
link: env.BUILD_URL,
|
||||||
result: 'SUCCESS',
|
result: 'SUCCESS',
|
||||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
||||||
@@ -38,7 +38,7 @@ pipeline {
|
|||||||
deleteDir()
|
deleteDir()
|
||||||
|
|
||||||
discordSend webhookURL: env.FDD_WH_ADMIN,
|
discordSend webhookURL: env.FDD_WH_ADMIN,
|
||||||
title: "CraterLib 1.19.3/4 Deploy #${BUILD_NUMBER}",
|
title: "CraterLib 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||||
link: env.BUILD_URL,
|
link: env.BUILD_URL,
|
||||||
result: currentBuild.currentResult,
|
result: currentBuild.currentResult,
|
||||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})\nStatus: ${currentBuild.currentResult}"
|
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})\nStatus: ${currentBuild.currentResult}"
|
||||||
|
@@ -13,7 +13,7 @@ pipeline {
|
|||||||
stage("Notify Discord") {
|
stage("Notify Discord") {
|
||||||
steps {
|
steps {
|
||||||
discordSend webhookURL: env.SSS_WEBHOOK,
|
discordSend webhookURL: env.SSS_WEBHOOK,
|
||||||
title: "Deploy Started: ${projectName} 1.19.3/4 Deploy #${BUILD_NUMBER}",
|
title: "Deploy Started: ${projectName} 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||||
link: env.BUILD_URL,
|
link: env.BUILD_URL,
|
||||||
result: 'SUCCESS',
|
result: 'SUCCESS',
|
||||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
||||||
@@ -53,8 +53,8 @@ pipeline {
|
|||||||
projectIcon: "${projectIcon}",
|
projectIcon: "${projectIcon}",
|
||||||
versionName: "Snapshot 1.1.${BUILD_NUMBER}",
|
versionName: "Snapshot 1.1.${BUILD_NUMBER}",
|
||||||
version: "1.1.${BUILD_NUMBER}",
|
version: "1.1.${BUILD_NUMBER}",
|
||||||
modLoaders: "forge|fabric|quilt",
|
modLoaders: "forge|neoforge|fabric|quilt",
|
||||||
minecraftVersions: "1.19.3|1.19.4",
|
minecraftVersions: "1.20.2",
|
||||||
failWebhook: env.SSS_WEBHOOK,
|
failWebhook: env.SSS_WEBHOOK,
|
||||||
publishWebhooks: "${env.SSS_WEBHOOK}|${env.FDD_WH}"
|
publishWebhooks: "${env.SSS_WEBHOOK}|${env.FDD_WH}"
|
||||||
|
|
||||||
|
@@ -19,8 +19,15 @@ public class CraterAdvancementEvent extends CraterEvent {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
this.advancement = advancement;
|
this.advancement = advancement;
|
||||||
|
|
||||||
this.title = advancement.getDisplay().getTitle();
|
Optional<DisplayInfo> displayInfo = advancement.display();
|
||||||
this.description = advancement.getDisplay().getDescription();
|
|
||||||
|
if (displayInfo.isPresent()) {
|
||||||
|
this.title = displayInfo.get().getTitle();
|
||||||
|
this.description = displayInfo.get().getDescription();
|
||||||
|
} else {
|
||||||
|
this.title = Component.literal("Unknown");
|
||||||
|
this.description = Component.literal("Unknown");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Advancement getAdvancement() {
|
public Advancement getAdvancement() {
|
||||||
|
@@ -0,0 +1,28 @@
|
|||||||
|
package com.hypherionmc.craterlib.api.networking;
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public interface CraterNetworkHandler {
|
||||||
|
|
||||||
|
<T> void sendToServer(T packet);
|
||||||
|
|
||||||
|
<T> void sendToServer(T packet, boolean ignoreCheck);
|
||||||
|
|
||||||
|
<T> void sendToClient(T packet, ServerPlayer player);
|
||||||
|
|
||||||
|
default <T> void sendToClients(T packet, List<ServerPlayer> players) {
|
||||||
|
for (ServerPlayer player : players) {
|
||||||
|
sendToClient(packet, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T> void sendToAllClients(T packet, MinecraftServer server) {
|
||||||
|
sendToClients(packet, server.getPlayerList().getPlayers());
|
||||||
|
}
|
||||||
|
}
|
@@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.*;
|
|||||||
import me.hypherionmc.moonconfig.core.conversion.SpecComment;
|
import me.hypherionmc.moonconfig.core.conversion.SpecComment;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
@@ -176,19 +177,19 @@ public class CraterConfigScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(@NotNull PoseStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(@NotNull GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||||
overlayBackground(matrices, TOP, height - BOTTOM, 32);
|
overlayBackground(matrices.pose(), TOP, height - BOTTOM, 32);
|
||||||
|
|
||||||
renderScrollBar();
|
renderScrollBar();
|
||||||
|
|
||||||
matrices.pushPose();
|
matrices.pose().pushPose();
|
||||||
matrices.translate(0, 0, 500.0);
|
matrices.pose().translate(0, 0, 500.0);
|
||||||
overlayBackground(matrices, 0, TOP, 64);
|
overlayBackground(matrices.pose(), 0, TOP, 64);
|
||||||
overlayBackground(matrices, height - BOTTOM, height, 64);
|
overlayBackground(matrices.pose(), height - BOTTOM, height, 64);
|
||||||
renderShadow(matrices);
|
renderShadow(matrices.pose());
|
||||||
drawCenteredString(matrices, font, getTitle(), width / 2, 9, 0xFFFFFF);
|
matrices.drawCenteredString(font, getTitle(), width / 2, 9, 0xFFFFFF);
|
||||||
|
matrices.pose().popPose();
|
||||||
|
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
matrices.popPose();
|
|
||||||
|
|
||||||
int y = (int) (TOP + 4 - Math.round(scrollerAmount));
|
int y = (int) (TOP + 4 - Math.round(scrollerAmount));
|
||||||
for (Option<?> option : options) {
|
for (Option<?> option : options) {
|
||||||
@@ -265,12 +266,11 @@ public class CraterConfigScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void overlayBackground(Matrix4f matrix, int minX, int minY, int maxX, int maxY, int red, int green, int blue, int startAlpha, int endAlpha) {
|
protected void overlayBackground(Matrix4f matrix, int minX, int minY, int maxX, int maxY, int red, int green, int blue, int startAlpha, int endAlpha) {
|
||||||
|
|
||||||
Tesselator tesselator = Tesselator.getInstance();
|
Tesselator tesselator = Tesselator.getInstance();
|
||||||
BufferBuilder buffer = tesselator.getBuilder();
|
BufferBuilder buffer = tesselator.getBuilder();
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||||
RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION);
|
RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION);
|
||||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
|
||||||
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||||
buffer.vertex(matrix, minX, maxY, 0.0F).uv(minX / 32.0F, maxY / 32.0F).color(red, green, blue, endAlpha).endVertex();
|
buffer.vertex(matrix, minX, maxY, 0.0F).uv(minX / 32.0F, maxY / 32.0F).color(red, green, blue, endAlpha).endVertex();
|
||||||
buffer.vertex(matrix, maxX, maxY, 0.0F).uv(maxX / 32.0F, maxY / 32.0F).color(red, green, blue, endAlpha).endVertex();
|
buffer.vertex(matrix, maxX, maxY, 0.0F).uv(maxX / 32.0F, maxY / 32.0F).color(red, green, blue, endAlpha).endVertex();
|
||||||
@@ -334,12 +334,12 @@ public class CraterConfigScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double d, double e, double f) {
|
public boolean mouseScrolled(double d, double e, double f, double g) {
|
||||||
if (e >= TOP && e <= height - BOTTOM) {
|
if (e >= TOP && e <= height - BOTTOM) {
|
||||||
scrollerAmount = Mth.clamp(scrollerAmount - f * 16.0D, 0, scrollHeight());
|
scrollerAmount = Mth.clamp(scrollerAmount - f * 16.0D, 0, scrollHeight());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.mouseScrolled(d, e, f);
|
return super.mouseScrolled(d, e, f, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -378,7 +378,7 @@ public class CraterConfigScreen extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderConfigTooltip(PoseStack stack, Font font, int mouseX, int mouseY, int startX, int startY, int sizeX, int sizeY, String title, String... description) {
|
private void renderConfigTooltip(GuiGraphics stack, Font font, int mouseX, int mouseY, int startX, int startY, int sizeX, int sizeY, String title, String... description) {
|
||||||
if (mouseX > startX && mouseX < startX + sizeX) {
|
if (mouseX > startX && mouseX < startX + sizeX) {
|
||||||
if (mouseY > startY && mouseY < startY + sizeY) {
|
if (mouseY > startY && mouseY < startY + sizeY) {
|
||||||
List<Component> list = new ArrayList<>();
|
List<Component> list = new ArrayList<>();
|
||||||
@@ -386,7 +386,7 @@ public class CraterConfigScreen extends Screen {
|
|||||||
for (String desc : description) {
|
for (String desc : description) {
|
||||||
list.add(Component.translatable(desc));
|
list.add(Component.translatable(desc));
|
||||||
}
|
}
|
||||||
renderComponentTooltip(stack, list, mouseX, mouseY);
|
stack.renderComponentTooltip(font, list, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public class AbstractConfigWidget<T, W extends AbstractWidget> extends BaseWidge
|
|||||||
public W widget;
|
public W widget;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||||
int i = (widget instanceof EditBox ? 1 : 0);
|
int i = (widget instanceof EditBox ? 1 : 0);
|
||||||
widget.setX(x + width - 200 - resetButtonOffset + i);
|
widget.setX(x + width - 200 - resetButtonOffset + i);
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
@@ -39,7 +39,7 @@ public class BaseWidget<T> extends Option<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||||
MutableComponent text = Component.literal(this.text.getString());
|
MutableComponent text = Component.literal(this.text.getString());
|
||||||
boolean edited = isEdited() || hasErrors;
|
boolean edited = isEdited() || hasErrors;
|
||||||
if (edited) {
|
if (edited) {
|
||||||
@@ -50,7 +50,7 @@ public class BaseWidget<T> extends Option<T> {
|
|||||||
} else {
|
} else {
|
||||||
text.withStyle(ChatFormatting.GRAY);
|
text.withStyle(ChatFormatting.GRAY);
|
||||||
}
|
}
|
||||||
font.draw(matrices, text, x, y, 0xFFFFFF);
|
matrices.drawString(font, text, x, y + font.lineHeight - 2, 0xFFFFFF);
|
||||||
resetButton.setX(x + width - 46);
|
resetButton.setX(x + width - 46);
|
||||||
resetButton.setY(y + 1);
|
resetButton.setY(y + 1);
|
||||||
resetButton.active = isNotDefault();
|
resetButton.active = isNotDefault();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||||
|
|
||||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractButton;
|
import net.minecraft.client.gui.components.AbstractButton;
|
||||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
@@ -23,7 +23,7 @@ public class InternalConfigButton extends AbstractButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(@NotNull PoseStack poseStack, int i, int j, float f) {
|
public void render(@NotNull GuiGraphics poseStack, int i, int j, float f) {
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
setMessage(Component.translatable(screen.isEdited() ? "t.clc.cancel_discard" : "gui.cancel"));
|
setMessage(Component.translatable(screen.isEdited() ? "t.clc.cancel_discard" : "gui.cancel"));
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -38,7 +38,7 @@ public abstract class Option<T> extends AbstractContainerEventHandler {
|
|||||||
this.langKeys = langKeys;
|
this.langKeys = langKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta);
|
public abstract void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta);
|
||||||
|
|
||||||
public int height() {
|
public int height() {
|
||||||
return 22;
|
return 22;
|
||||||
|
@@ -2,9 +2,9 @@ package com.hypherionmc.craterlib.client.gui.config.widgets;
|
|||||||
|
|
||||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -27,7 +27,7 @@ public class SubConfigWidget<T> extends AbstractConfigWidget<T, Button> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||||
this.text = Component.literal(subConfig.getClass().getSimpleName().toLowerCase());
|
this.text = Component.literal(subConfig.getClass().getSimpleName().toLowerCase());
|
||||||
this.hideReset();
|
this.hideReset();
|
||||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ public class TextConfigOption<T> extends AbstractConfigWidget<T, WrappedEditBox>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||||
widget.setTextColor(hasErrors ? 16733525 : 14737632);
|
widget.setTextColor(hasErrors ? 16733525 : 14737632);
|
||||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ public class WrappedEditBox extends EditBox {
|
|||||||
for (GuiEventListener child : Minecraft.getInstance().screen.children()) {
|
for (GuiEventListener child : Minecraft.getInstance().screen.children()) {
|
||||||
if (child instanceof TextConfigOption<?> option) {
|
if (child instanceof TextConfigOption<?> option) {
|
||||||
WrappedEditBox box = option.widget;
|
WrappedEditBox box = option.widget;
|
||||||
box.setFocused(box == this);
|
super.setFocused(box == this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setFocused(bl);
|
super.setFocused(bl);
|
||||||
|
@@ -7,7 +7,7 @@ import net.minecraft.network.chat.MutableComponent;
|
|||||||
public class AbstractCommand {
|
public class AbstractCommand {
|
||||||
|
|
||||||
public static void replySuccess(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
public static void replySuccess(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
||||||
stack.getSource().sendSuccess(message, false);
|
stack.getSource().sendSuccess(() -> message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replyFailure(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
public static void replyFailure(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
||||||
|
@@ -25,13 +25,13 @@ public class AbstractFakePlayer extends CommandSourceStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendSuccess(Component component, boolean bl) {
|
public void sendSuccess(Supplier<Component> component, boolean bl) {
|
||||||
this.onSuccess(component, bl);
|
this.onSuccess(component.get(), bl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendFailure(Component component) {
|
public void sendFailure(Component component) {
|
||||||
sendSuccess(component, false);
|
sendSuccess(() -> component, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.hypherionmc.craterlib.core.abstraction.server;
|
package com.hypherionmc.craterlib.core.abstraction.server;
|
||||||
|
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
@@ -9,4 +10,7 @@ public class AbstractServer {
|
|||||||
server.getPlayerList().broadcastSystemMessage(message, false);
|
server.getPlayerList().broadcastSystemMessage(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void executeCommand(MinecraftServer server, CommandSourceStack stack, String command) {
|
||||||
|
server.getCommands().performPrefixedCommand(stack, command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,9 +10,10 @@ import java.util.function.Supplier;
|
|||||||
/**
|
/**
|
||||||
* @author HypherionSA
|
* @author HypherionSA
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public interface CraterNetworkHandler {
|
public interface CraterNetworkHandler {
|
||||||
|
|
||||||
<T extends CraterPacket<T>> void registerPacket(Class<? extends T> clazz, Supplier<T> supplier, PacketDirection packetDirection);
|
<T extends CraterPacket<T>> void registerPacket(Class<T> clazz, Supplier<T> supplier, PacketDirection packetDirection);
|
||||||
|
|
||||||
Packet<?> toServerBound(CraterPacket<?> packet);
|
Packet<?> toServerBound(CraterPacket<?> packet);
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
/**
|
/**
|
||||||
* @author HypherionSA
|
* @author HypherionSA
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public interface CraterPacket<T extends CraterPacket<T>> {
|
public interface CraterPacket<T extends CraterPacket<T>> {
|
||||||
|
|
||||||
void write(final FriendlyByteBuf buf);
|
void write(final FriendlyByteBuf buf);
|
||||||
|
@@ -3,6 +3,7 @@ package com.hypherionmc.craterlib.core.network;
|
|||||||
/**
|
/**
|
||||||
* @author HypherionSA
|
* @author HypherionSA
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public enum PacketDirection {
|
public enum PacketDirection {
|
||||||
TO_SERVER,
|
TO_SERVER,
|
||||||
TO_CLIENT
|
TO_CLIENT
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking;
|
||||||
|
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public class CraterPacketNetwork {
|
||||||
|
|
||||||
|
private final PacketRegistry packetRegistry;
|
||||||
|
public static CraterPacketNetwork INSTANCE;
|
||||||
|
private static DeferredPacketRegistrar delayedHandler;
|
||||||
|
|
||||||
|
public CraterPacketNetwork(PacketRegistry registry) {
|
||||||
|
INSTANCE = this;
|
||||||
|
this.packetRegistry = registry;
|
||||||
|
getDelayedHandler().registerQueuedPackets(registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DeferredPacketRegistrar getDelayedHandler() {
|
||||||
|
if (delayedHandler == null) {
|
||||||
|
delayedHandler = new DeferredPacketRegistrar();
|
||||||
|
}
|
||||||
|
return delayedHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> PacketRegistrar registerPacket(ResourceLocation id, Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) {
|
||||||
|
if (INSTANCE != null) {
|
||||||
|
return INSTANCE.packetRegistry.registerPacket(id, messageType, encoder, decoder, handler);
|
||||||
|
} else {
|
||||||
|
return getDelayedHandler().registerPacket(id, messageType, encoder, decoder, handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketRegistry getPacketRegistry() {
|
||||||
|
return packetRegistry;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking;
|
||||||
|
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public class DeferredPacketRegistrar implements PacketRegistrar {
|
||||||
|
|
||||||
|
private static final Map<Class<?>, PacketHolder<?>> QUEUED_PACKET_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketSide side() {
|
||||||
|
return PacketSide.CLIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> PacketRegistrar registerPacket(ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) {
|
||||||
|
PacketHolder<T> container = new PacketHolder<>(packetIdentifier, messageType, encoder, decoder, handler);
|
||||||
|
QUEUED_PACKET_MAP.put(messageType, container);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void registerQueuedPackets(PacketRegistry packetRegistration) {
|
||||||
|
if (!QUEUED_PACKET_MAP.isEmpty()) {
|
||||||
|
packetRegistration.PACKET_MAP.putAll(QUEUED_PACKET_MAP);
|
||||||
|
QUEUED_PACKET_MAP.forEach((aClass, container) -> packetRegistration.registerPacket(container));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,21 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking;
|
||||||
|
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public interface PacketRegistrar {
|
||||||
|
|
||||||
|
PacketSide side();
|
||||||
|
|
||||||
|
<T> PacketRegistrar registerPacket(ResourceLocation id, Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler);
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking;
|
||||||
|
|
||||||
|
import com.hypherionmc.craterlib.api.networking.CraterNetworkHandler;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public abstract class PacketRegistry implements CraterNetworkHandler, PacketRegistrar {
|
||||||
|
|
||||||
|
final Map<Class<?>, PacketHolder<?>> PACKET_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
protected final PacketSide side;
|
||||||
|
|
||||||
|
public PacketRegistry(PacketSide side) {
|
||||||
|
this.side = side;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> PacketRegistrar registerPacket(ResourceLocation id, Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) {
|
||||||
|
PacketHolder<T> holder = new PacketHolder<>(id, messageType, encoder, decoder, handler);
|
||||||
|
PACKET_MAP.put(messageType, holder);
|
||||||
|
registerPacket(holder);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketSide side() {
|
||||||
|
return side;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract <T> void registerPacket(PacketHolder<T> packetHolder);
|
||||||
|
}
|
@@ -0,0 +1,15 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking.data;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public record PacketContext<T>(@Nullable Player sender, T message, PacketSide side) {
|
||||||
|
|
||||||
|
public PacketContext(T message, PacketSide side) {
|
||||||
|
this(null, message, side);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking.data;
|
||||||
|
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public record PacketHolder<T>(ResourceLocation packetId,
|
||||||
|
Class<T> messageType,
|
||||||
|
BiConsumer<T, FriendlyByteBuf> encoder,
|
||||||
|
Function<FriendlyByteBuf, T> decoder,
|
||||||
|
Consumer<PacketContext<T>> handler) {
|
||||||
|
}
|
@@ -0,0 +1,13 @@
|
|||||||
|
package com.hypherionmc.craterlib.core.networking.data;
|
||||||
|
|
||||||
|
public enum PacketSide {
|
||||||
|
CLIENT,
|
||||||
|
SERVER;
|
||||||
|
|
||||||
|
public PacketSide flipped() {
|
||||||
|
if (CLIENT.equals(this))
|
||||||
|
return SERVER;
|
||||||
|
|
||||||
|
return CLIENT;
|
||||||
|
}
|
||||||
|
}
|
@@ -3,6 +3,7 @@ package com.hypherionmc.craterlib.mixin.events;
|
|||||||
import com.hypherionmc.craterlib.api.event.server.CraterAdvancementEvent;
|
import com.hypherionmc.craterlib.api.event.server.CraterAdvancementEvent;
|
||||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||||
import net.minecraft.advancements.Advancement;
|
import net.minecraft.advancements.Advancement;
|
||||||
|
import net.minecraft.advancements.AdvancementHolder;
|
||||||
import net.minecraft.server.PlayerAdvancements;
|
import net.minecraft.server.PlayerAdvancements;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -14,12 +15,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
@Mixin(PlayerAdvancements.class)
|
@Mixin(PlayerAdvancements.class)
|
||||||
public class PlayerAdvancementsMixin {
|
public class PlayerAdvancementsMixin {
|
||||||
|
|
||||||
@Shadow private ServerPlayer player;
|
@Shadow
|
||||||
|
private ServerPlayer player;
|
||||||
|
|
||||||
@Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V", shift = At.Shift.AFTER))
|
@Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V", shift = At.Shift.AFTER))
|
||||||
private void injectAdvancementEvent(Advancement advancement, String $$1, CallbackInfoReturnable<Boolean> cir) {
|
private void injectAdvancementEvent(AdvancementHolder advancementHolder, String string, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat()) {
|
CraterAdvancementEvent event = new CraterAdvancementEvent(this.player, advancementHolder.value());
|
||||||
CraterEventBus.INSTANCE.postEvent(new CraterAdvancementEvent(this.player, advancement));
|
|
||||||
|
Advancement advancement = advancementHolder.value();
|
||||||
|
|
||||||
|
if (advancement.display().isPresent() && advancement.display().get().shouldAnnounceChat()) {
|
||||||
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.server.network.CommonListenerCookie;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -29,7 +30,7 @@ public class PlayerListMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "placeNewPlayer", at = @At("TAIL"))
|
@Inject(method = "placeNewPlayer", at = @At("TAIL"))
|
||||||
private void injectPlayerLoginEvent(Connection connection, ServerPlayer serverPlayer, CallbackInfo ci) {
|
private void injectPlayerLoginEvent(Connection connection, ServerPlayer serverPlayer, CommonListenerCookie commonListenerCookie, CallbackInfo ci) {
|
||||||
CraterPlayerEvent.PlayerLoggedIn loggedIn = new CraterPlayerEvent.PlayerLoggedIn(serverPlayer);
|
CraterPlayerEvent.PlayerLoggedIn loggedIn = new CraterPlayerEvent.PlayerLoggedIn(serverPlayer);
|
||||||
CraterEventBus.INSTANCE.postEvent(loggedIn);
|
CraterEventBus.INSTANCE.postEvent(loggedIn);
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Mixin(value = ServerGamePacketListenerImpl.class, priority = Integer.MIN_VALUE)
|
@Mixin(value = ServerGamePacketListenerImpl.class, priority = Integer.MIN_VALUE)
|
||||||
public class ServerGamePacketListenerImplMixin {
|
public class ServerGamePacketListenerImplMixin {
|
||||||
|
|
||||||
@@ -22,11 +20,11 @@ public class ServerGamePacketListenerImplMixin {
|
|||||||
public ServerPlayer player;
|
public ServerPlayer player;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "lambda$handleChat$8",
|
method = "lambda$handleChat$6",
|
||||||
at = @At("HEAD"),
|
at = @At("HEAD"),
|
||||||
cancellable = true
|
cancellable = true
|
||||||
)
|
)
|
||||||
private void injectChatEvent(PlayerChatMessage arg, CompletableFuture completableFuture, CompletableFuture completableFuture2, Void void_, CallbackInfo ci) {
|
private void injectChatEvent(PlayerChatMessage arg, Component arg2, FilteredText arg3, CallbackInfo ci) {
|
||||||
CraterServerChatEvent event = new CraterServerChatEvent(this.player, arg.decoratedContent().getString(), arg.decoratedContent());
|
CraterServerChatEvent event = new CraterServerChatEvent(this.player, arg.decoratedContent().getString(), arg.decoratedContent());
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
if (event.wasCancelled())
|
if (event.wasCancelled())
|
||||||
|
@@ -3,7 +3,8 @@ package com.hypherionmc.craterlib.mixin.events.client;
|
|||||||
import com.hypherionmc.craterlib.api.event.client.CraterSinglePlayerEvent;
|
import com.hypherionmc.craterlib.api.event.client.CraterSinglePlayerEvent;
|
||||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -12,10 +13,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(ClientLevel.class)
|
@Mixin(ClientLevel.class)
|
||||||
public class ClientLevelMixin {
|
public class ClientLevelMixin {
|
||||||
|
|
||||||
@Inject(method = "addPlayer", at = @At("HEAD"))
|
@Inject(method = "addEntity", at = @At("HEAD"))
|
||||||
private void injectSinglePlayerJoinEvent(int $$0, AbstractClientPlayer player, CallbackInfo ci) {
|
private void injectSinglePlayerJoinEvent(Entity entity, CallbackInfo ci) {
|
||||||
CraterSinglePlayerEvent.PlayerLogin playerLogin = new CraterSinglePlayerEvent.PlayerLogin(player);
|
if (entity instanceof Player player) {
|
||||||
CraterEventBus.INSTANCE.postEvent(playerLogin);
|
CraterSinglePlayerEvent.PlayerLogin playerLogin = new CraterSinglePlayerEvent.PlayerLogin(player);
|
||||||
|
CraterEventBus.INSTANCE.postEvent(playerLogin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -4,18 +4,19 @@ import com.hypherionmc.craterlib.api.event.client.ScreenEvent;
|
|||||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
public class MinecraftMixin {
|
public class MinecraftMixin {
|
||||||
|
|
||||||
@Shadow @Nullable public Screen screen;
|
@Shadow
|
||||||
|
@Nullable
|
||||||
|
public Screen screen;
|
||||||
|
|
||||||
@Inject(method = "setScreen", at = @At(value = "TAIL"))
|
@Inject(method = "setScreen", at = @At(value = "TAIL"))
|
||||||
private void injectScreenOpeningEvent(Screen screen, CallbackInfo ci) {
|
private void injectScreenOpeningEvent(Screen screen, CallbackInfo ci) {
|
||||||
|
@@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public class RealmsMainScreenMixin {
|
public class RealmsMainScreenMixin {
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "play")
|
@Inject(at = @At("HEAD"), method = "play")
|
||||||
private void play(RealmsServer serverData, Screen parent, CallbackInfo ci) {
|
private static void play(RealmsServer serverData, Screen parent, CallbackInfo ci) {
|
||||||
PlayerJoinRealmEvent playerJoinRealm = new PlayerJoinRealmEvent(serverData);
|
PlayerJoinRealmEvent playerJoinRealm = new PlayerJoinRealmEvent(serverData);
|
||||||
CraterEventBus.INSTANCE.postEvent(playerJoinRealm);
|
CraterEventBus.INSTANCE.postEvent(playerJoinRealm);
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ public class RenderUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int renderColorFromDye(DyeColor color) {
|
public static int renderColorFromDye(DyeColor color) {
|
||||||
return color.getMaterialColor().col | 0xFF000000;
|
return color.getMapColor().col | 0xFF000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int alphaColorFromDye(DyeColor color, float alpha) {
|
public static int alphaColorFromDye(DyeColor color, float alpha) {
|
||||||
|
@@ -116,8 +116,8 @@ publisher {
|
|||||||
versionType = "release"
|
versionType = "release"
|
||||||
changelog = "https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-fabric.md"
|
changelog = "https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-fabric.md"
|
||||||
version = "${minecraft_version}-${project.version}"
|
version = "${minecraft_version}-${project.version}"
|
||||||
displayName = "[FABRIC/QUILT 1.19.3/4] CraterLib - ${project.version}"
|
displayName = "[FABRIC/QUILT 1.20.2] CraterLib - ${project.version}"
|
||||||
gameVersions = ["1.19.3", "1.19.4"]
|
gameVersions = ["1.20.2"]
|
||||||
loaders = ["fabric", "quilt"]
|
loaders = ["fabric", "quilt"]
|
||||||
artifact = remapJar
|
artifact = remapJar
|
||||||
|
|
||||||
|
@@ -4,6 +4,9 @@ import com.hypherionmc.craterlib.api.event.server.CraterRegisterCommandEvent;
|
|||||||
import com.hypherionmc.craterlib.api.event.server.CraterServerLifecycleEvent;
|
import com.hypherionmc.craterlib.api.event.server.CraterServerLifecycleEvent;
|
||||||
import com.hypherionmc.craterlib.common.FabricCommonPlatform;
|
import com.hypherionmc.craterlib.common.FabricCommonPlatform;
|
||||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import com.hypherionmc.craterlib.network.CraterFabricNetworkHandler;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
@@ -12,6 +15,7 @@ public class CraterLibInitializer implements ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.SERVER));
|
||||||
CommandRegistrationCallback.EVENT.register(
|
CommandRegistrationCallback.EVENT.register(
|
||||||
(dispatcher, registryAccess, environment) -> CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(dispatcher)));
|
(dispatcher, registryAccess, environment) -> CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(dispatcher)));
|
||||||
|
|
||||||
|
@@ -2,6 +2,9 @@ package com.hypherionmc.craterlib.client;
|
|||||||
|
|
||||||
import com.hypherionmc.craterlib.api.event.client.CraterClientTickEvent;
|
import com.hypherionmc.craterlib.api.event.client.CraterClientTickEvent;
|
||||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import com.hypherionmc.craterlib.network.CraterFabricNetworkHandler;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
|
|
||||||
@@ -9,6 +12,7 @@ public class CraterLibClientInitializer implements ClientModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
|
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.CLIENT));
|
||||||
ClientTickEvents.START_CLIENT_TICK.register((listener) -> {
|
ClientTickEvents.START_CLIENT_TICK.register((listener) -> {
|
||||||
CraterClientTickEvent event = new CraterClientTickEvent(listener.level);
|
CraterClientTickEvent event = new CraterClientTickEvent(listener.level);
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
|
@@ -0,0 +1,81 @@
|
|||||||
|
package com.hypherionmc.craterlib.network;
|
||||||
|
|
||||||
|
import com.hypherionmc.craterlib.CraterConstants;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public class CraterFabricNetworkHandler extends PacketRegistry {
|
||||||
|
|
||||||
|
private final Map<Class<?>, Message<?>> CHANNELS = new HashMap();
|
||||||
|
|
||||||
|
public CraterFabricNetworkHandler(PacketSide side) {
|
||||||
|
super(side);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <T> void registerPacket(PacketHolder<T> holder) {
|
||||||
|
if (CHANNELS.get(holder.messageType()) == null) {
|
||||||
|
CHANNELS.put(holder.messageType(), new Message<>(holder.packetId(), holder.encoder()));
|
||||||
|
|
||||||
|
if (PacketSide.CLIENT.equals(this.side)) {
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(holder.packetId(), ((client, listener, buf, responseSender) -> {
|
||||||
|
buf.readByte();
|
||||||
|
T message = holder.decoder().apply(buf);
|
||||||
|
client.execute(() -> holder.handler().accept(new PacketContext<>(message, PacketSide.CLIENT)));
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
|
||||||
|
ServerPlayNetworking.registerGlobalReceiver(holder.packetId(), ((server, player, listener, buf, responseSender) -> {
|
||||||
|
buf.readByte();
|
||||||
|
T message = holder.decoder().apply(buf);
|
||||||
|
server.execute(() -> holder.handler().accept(new PacketContext<>(player, message, PacketSide.SERVER)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
CraterConstants.LOG.error("Trying to register duplicate packet for type {}", holder.messageType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void sendToServer(T packet) {
|
||||||
|
this.sendToServer(packet, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void sendToServer(T packet, boolean ignoreCheck) {
|
||||||
|
Message<T> message = (Message<T>) CHANNELS.get(packet.getClass());
|
||||||
|
|
||||||
|
if (ClientPlayNetworking.canSend(message.id()) || ignoreCheck) {
|
||||||
|
FriendlyByteBuf buf = PacketByteBufs.create();
|
||||||
|
buf.writeByte(0);
|
||||||
|
message.encoder().accept(packet, buf);
|
||||||
|
ClientPlayNetworking.send(message.id(), buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void sendToClient(T packet, ServerPlayer player) {
|
||||||
|
Message<T> message = (Message<T>) CHANNELS.get(packet.getClass());
|
||||||
|
if (ServerPlayNetworking.canSend(player, message.id()))
|
||||||
|
{
|
||||||
|
FriendlyByteBuf buf = PacketByteBufs.create();
|
||||||
|
buf.writeByte(0);
|
||||||
|
message.encoder().accept(packet, buf);
|
||||||
|
ServerPlayNetworking.send(player, message.id(), buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Message<T>(ResourceLocation id, BiConsumer<T, FriendlyByteBuf> encoder) { }
|
||||||
|
}
|
@@ -23,6 +23,7 @@ import java.util.function.Supplier;
|
|||||||
* @author HypherionSA
|
* @author HypherionSA
|
||||||
* @date 24/09/2022
|
* @date 24/09/2022
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class FabricNetworkHandler implements CraterNetworkHandler {
|
public class FabricNetworkHandler implements CraterNetworkHandler {
|
||||||
|
|
||||||
private static final Map<String, FabricNetworkHandler> NETWORK_HANDLERS = Maps.newConcurrentMap();
|
private static final Map<String, FabricNetworkHandler> NETWORK_HANDLERS = Maps.newConcurrentMap();
|
||||||
@@ -35,16 +36,22 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
|||||||
this.modid = modid;
|
this.modid = modid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized static CraterNetworkHandler of(String modId) {
|
||||||
|
return NETWORK_HANDLERS.computeIfAbsent(modId, FabricNetworkHandler::new);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends CraterPacket<T>> void registerPacket(Class<? extends T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
public <T extends CraterPacket<T>> void registerPacket(Class<T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
||||||
ResourceLocation channelName = this.nextId();
|
ResourceLocation channelName = this.nextId();
|
||||||
this.packets.put(clazz, new PacketData(clazz, channelName, packetDirection));
|
this.packets.put(clazz, new PacketData(clazz, channelName, packetDirection));
|
||||||
|
|
||||||
final Function<FriendlyByteBuf, CraterPacket<?>> decoder = buf -> Util.make(supplier.get(), message -> message.read(buf));
|
final Function<FriendlyByteBuf, CraterPacket<?>> decoder = buf -> Util.make(supplier.get(), message -> message.read(buf));
|
||||||
|
|
||||||
switch (packetDirection) {
|
switch (packetDirection) {
|
||||||
case TO_CLIENT -> FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerClientReceiver(channelName, decoder);
|
case TO_CLIENT ->
|
||||||
case TO_SERVER -> FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerServerReceiver(channelName, decoder);
|
FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerClientReceiver(channelName, decoder);
|
||||||
|
case TO_SERVER ->
|
||||||
|
FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerServerReceiver(channelName, decoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,13 +61,15 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
||||||
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_SERVER) throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_SERVER, PacketDirection.TO_CLIENT));
|
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_SERVER)
|
||||||
|
throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_SERVER, PacketDirection.TO_CLIENT));
|
||||||
return this.toPacket(ClientPlayNetworking::createC2SPacket, packet);
|
return this.toPacket(ClientPlayNetworking::createC2SPacket, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
||||||
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_CLIENT) throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_CLIENT, PacketDirection.TO_SERVER));
|
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_CLIENT)
|
||||||
|
throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_CLIENT, PacketDirection.TO_SERVER));
|
||||||
return this.toPacket(ServerPlayNetworking::createS2CPacket, packet);
|
return this.toPacket(ServerPlayNetworking::createS2CPacket, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,11 +80,8 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
|||||||
return packetFactory.apply(identifier, byteBuf);
|
return packetFactory.apply(identifier, byteBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static CraterNetworkHandler of(String modId) {
|
private record PacketData(Class<? extends CraterPacket<?>> clazz, ResourceLocation identifier,
|
||||||
return NETWORK_HANDLERS.computeIfAbsent(modId, FabricNetworkHandler::new);
|
PacketDirection direction) {
|
||||||
}
|
|
||||||
|
|
||||||
private record PacketData(Class<? extends CraterPacket<?>> clazz, ResourceLocation identifier, PacketDirection direction) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,12 +10,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public interface FabricNetworkHelper {
|
public interface FabricNetworkHelper {
|
||||||
|
|
||||||
/* FABRIC ONLY */
|
|
||||||
void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory);
|
|
||||||
void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
|
||||||
|
|
||||||
public static FabricNetworkHelper getForDist(EnvType dist) {
|
public static FabricNetworkHelper getForDist(EnvType dist) {
|
||||||
switch (dist) {
|
switch (dist) {
|
||||||
case CLIENT -> {
|
case CLIENT -> {
|
||||||
@@ -28,4 +25,9 @@ public interface FabricNetworkHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FABRIC ONLY */
|
||||||
|
void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory);
|
||||||
|
|
||||||
|
void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class FabricClientNetworkHelper extends FabricServerNetworkHelper {
|
public class FabricClientNetworkHelper extends FabricServerNetworkHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class FabricServerNetworkHelper implements FabricNetworkHelper {
|
public class FabricServerNetworkHelper implements FabricNetworkHelper {
|
||||||
@Override
|
@Override
|
||||||
public void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory) {
|
public void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory) {
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.21",
|
"fabricloader": ">=0.14.21",
|
||||||
"fabric-api": "*",
|
"fabric-api": "*",
|
||||||
"minecraft": ">=1.19.3",
|
"minecraft": ">=1.20.2",
|
||||||
"java": ">=17"
|
"java": ">=17"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -111,8 +111,8 @@ publisher {
|
|||||||
versionType = "release"
|
versionType = "release"
|
||||||
changelog = "https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-forge.md"
|
changelog = "https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-forge.md"
|
||||||
version = "${minecraft_version}-${project.version}"
|
version = "${minecraft_version}-${project.version}"
|
||||||
displayName = "[FORGE 1.19.3/4] CraterLib - ${project.version}"
|
displayName = "[FORGE 1.20.2] CraterLib - ${project.version}"
|
||||||
gameVersions = ["1.19.3", "1.19.4"]
|
gameVersions = ["1.20.2"]
|
||||||
loaders = ["forge"]
|
loaders = ["forge"]
|
||||||
artifact = remapJar
|
artifact = remapJar
|
||||||
}
|
}
|
@@ -3,6 +3,9 @@ package com.hypherionmc.craterlib;
|
|||||||
import com.hypherionmc.craterlib.api.event.client.LateInitEvent;
|
import com.hypherionmc.craterlib.api.event.client.LateInitEvent;
|
||||||
import com.hypherionmc.craterlib.common.ForgeServerEvents;
|
import com.hypherionmc.craterlib.common.ForgeServerEvents;
|
||||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import com.hypherionmc.craterlib.network.CraterForgeNetworkHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
@@ -10,6 +13,7 @@ import net.minecraftforge.fml.DistExecutor;
|
|||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
|
||||||
@Mod(CraterConstants.MOD_ID)
|
@Mod(CraterConstants.MOD_ID)
|
||||||
public class CraterLib {
|
public class CraterLib {
|
||||||
@@ -20,6 +24,7 @@ public class CraterLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void commonSetup(FMLCommonSetupEvent evt) {
|
public void commonSetup(FMLCommonSetupEvent evt) {
|
||||||
|
new CraterPacketNetwork(new CraterForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER));
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||||
LateInitEvent event = new LateInitEvent(Minecraft.getInstance(), Minecraft.getInstance().options);
|
LateInitEvent event = new LateInitEvent(Minecraft.getInstance(), Minecraft.getInstance().options);
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
package com.hypherionmc.craterlib.network;
|
||||||
|
|
||||||
|
import com.hypherionmc.craterlib.CraterConstants;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
|
||||||
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.network.Connection;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
|
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.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||||
|
*/
|
||||||
|
public class CraterForgeNetworkHandler extends PacketRegistry {
|
||||||
|
private final Map<Class<?>, SimpleChannel> CHANNELS = new HashMap<>();
|
||||||
|
|
||||||
|
public CraterForgeNetworkHandler(PacketSide side) {
|
||||||
|
super(side);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <T> void registerPacket(PacketHolder<T> holder) {
|
||||||
|
if (CHANNELS.get(holder.messageType()) == null) {
|
||||||
|
SimpleChannel channel = ChannelBuilder
|
||||||
|
.named(holder.packetId())
|
||||||
|
.clientAcceptedVersions((a, b) -> true)
|
||||||
|
.serverAcceptedVersions((a, b) -> true)
|
||||||
|
.networkProtocolVersion(1)
|
||||||
|
.simpleChannel();
|
||||||
|
|
||||||
|
channel.messageBuilder(holder.messageType())
|
||||||
|
.decoder(holder.decoder())
|
||||||
|
.encoder(holder.encoder())
|
||||||
|
.consumerNetworkThread(buildHandler(holder.handler()))
|
||||||
|
.add();
|
||||||
|
|
||||||
|
CHANNELS.put(holder.messageType(), channel);
|
||||||
|
} else {
|
||||||
|
CraterConstants.LOG.error("Trying to register duplicate packet for type {}", holder.messageType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void sendToServer(T packet) {
|
||||||
|
this.sendToServer(packet, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void sendToServer(T packet, boolean ignoreCheck) {
|
||||||
|
SimpleChannel channel = CHANNELS.get(packet.getClass());
|
||||||
|
Connection connection = Minecraft.getInstance().getConnection().getConnection();
|
||||||
|
if (channel.isRemotePresent(connection) || ignoreCheck) {
|
||||||
|
channel.send(packet, PacketDistributor.SERVER.noArg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void sendToClient(T packet, ServerPlayer player) {
|
||||||
|
SimpleChannel channel = CHANNELS.get(packet.getClass());
|
||||||
|
Connection connection = player.connection.getConnection();
|
||||||
|
if (channel.isRemotePresent(connection)) {
|
||||||
|
channel.send(packet, PacketDistributor.PLAYER.with(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private <T> BiConsumer<T, CustomPayloadEvent.Context> buildHandler(Consumer<PacketContext<T>> handler) {
|
||||||
|
return (message, ctx) -> {
|
||||||
|
ctx.enqueueWork(() -> {
|
||||||
|
PacketSide side = ctx.getDirection().getReceptionSide().isServer() ? PacketSide.SERVER : PacketSide.CLIENT;
|
||||||
|
ServerPlayer player = ctx.getSender();
|
||||||
|
handler.accept(new PacketContext<>(player, message, side));
|
||||||
|
});
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@@ -5,17 +5,20 @@ import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
|||||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||||
import com.hypherionmc.craterlib.core.network.PacketDirection;
|
import com.hypherionmc.craterlib.core.network.PacketDirection;
|
||||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.common.util.LogicalSidedProvider;
|
import net.minecraftforge.common.util.LogicalSidedProvider;
|
||||||
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
import net.minecraftforge.network.ChannelBuilder;
|
||||||
import net.minecraftforge.network.NetworkDirection;
|
import net.minecraftforge.network.NetworkDirection;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.SimpleChannel;
|
||||||
import net.minecraftforge.network.NetworkRegistry;
|
|
||||||
import net.minecraftforge.network.simple.SimpleChannel;
|
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
@@ -26,10 +29,10 @@ import java.util.function.Supplier;
|
|||||||
* @author HypherionSA
|
* @author HypherionSA
|
||||||
* Partly inspired by and based on <a href="https://github.com/Fuzss/puzzleslib/blob/1.19/Forge/src/main/java/fuzs/puzzleslib/network/ForgeNetworkHandler.java">...</a>
|
* Partly inspired by and based on <a href="https://github.com/Fuzss/puzzleslib/blob/1.19/Forge/src/main/java/fuzs/puzzleslib/network/ForgeNetworkHandler.java">...</a>
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class ForgeNetworkHandler implements CraterNetworkHandler {
|
public class ForgeNetworkHandler implements CraterNetworkHandler {
|
||||||
|
|
||||||
private static final Map<String, ForgeNetworkHandler> NETWORK_HANDLERS = Maps.newConcurrentMap();
|
private static final Map<String, ForgeNetworkHandler> NETWORK_HANDLERS = Maps.newConcurrentMap();
|
||||||
private static final String PROTOCOL = Integer.toString(1);
|
|
||||||
|
|
||||||
private final SimpleChannel channel;
|
private final SimpleChannel channel;
|
||||||
|
|
||||||
@@ -39,52 +42,87 @@ public class ForgeNetworkHandler implements CraterNetworkHandler {
|
|||||||
|
|
||||||
private final AtomicInteger packetID = new AtomicInteger();
|
private final AtomicInteger packetID = new AtomicInteger();
|
||||||
|
|
||||||
|
private HashMap<Class<?>, Integer> packetMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
private ForgeNetworkHandler(SimpleChannel channel, boolean clientRequired, boolean serverRequired) {
|
private ForgeNetworkHandler(SimpleChannel channel, boolean clientRequired, boolean serverRequired) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.clientRequired = clientRequired;
|
this.clientRequired = clientRequired;
|
||||||
this.serverRequired = serverRequired;
|
this.serverRequired = serverRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized static CraterNetworkHandler of(String modId, boolean clientRequired, boolean serverRequired) {
|
||||||
|
ForgeNetworkHandler handler = NETWORK_HANDLERS.computeIfAbsent(modId, modId1 -> new ForgeNetworkHandler(buildSimpleChannel(modId1, clientRequired, serverRequired), clientRequired, serverRequired));
|
||||||
|
if (handler.clientRequired != clientRequired)
|
||||||
|
throw new IllegalArgumentException("client channel settings mismatch, expected %s, but was %s".formatted(handler.clientRequired, clientRequired));
|
||||||
|
if (handler.serverRequired != serverRequired)
|
||||||
|
throw new IllegalArgumentException("server channel settings mismatch, expected %s, but was %s".formatted(handler.serverRequired, serverRequired));
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SimpleChannel buildSimpleChannel(String modId, boolean clientAcceptsVanillaOrMissing, boolean serverAcceptsVanillaOrMissing) {
|
||||||
|
ChannelBuilder builder = ChannelBuilder.named(new ResourceLocation(modId, "crater_network"));
|
||||||
|
|
||||||
|
if (clientAcceptsVanillaOrMissing) {
|
||||||
|
builder = builder.optionalClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverAcceptsVanillaOrMissing) {
|
||||||
|
builder = builder.optionalServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.simpleChannel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends CraterPacket<T>> void registerPacket(Class<? extends T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
public <T extends CraterPacket<T>> void registerPacket(Class<T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
||||||
BiConsumer<T, FriendlyByteBuf> encoder = CraterPacket::write;
|
BiConsumer<T, FriendlyByteBuf> encoder = CraterPacket::write;
|
||||||
Function<FriendlyByteBuf, T> decoder = buf -> {
|
Function<FriendlyByteBuf, T> decoder = buf -> {
|
||||||
T packet = supplier.get();
|
T packet = supplier.get();
|
||||||
packet.read(buf);
|
packet.read(buf);
|
||||||
return packet;
|
return packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
BiConsumer<T, Supplier<NetworkEvent.Context>> handler = (packet, sup) -> {
|
BiConsumer<T, CustomPayloadEvent.Context> handler = (packet, sup) -> {
|
||||||
NetworkEvent.Context context = sup.get();
|
|
||||||
LogicalSide expectedSide = getSideFromDirection(packetDirection);
|
LogicalSide expectedSide = getSideFromDirection(packetDirection);
|
||||||
LogicalSide currentSide = context.getDirection().getReceptionSide();
|
LogicalSide currentSide = sup.getDirection().getReceptionSide();
|
||||||
|
|
||||||
if (expectedSide != currentSide) {
|
if (expectedSide != currentSide) {
|
||||||
throw new IllegalStateException(String.format("Received message on wrong side, expected %s, was %s", expectedSide, currentSide));
|
throw new IllegalStateException(String.format("Received message on wrong side, expected %s, was %s", expectedSide, currentSide));
|
||||||
}
|
}
|
||||||
|
|
||||||
context.enqueueWork(() -> {
|
sup.enqueueWork(() -> {
|
||||||
Player player;
|
Player player;
|
||||||
if (packetDirection == PacketDirection.TO_CLIENT) {
|
if (packetDirection == PacketDirection.TO_CLIENT) {
|
||||||
player = ClientPlatform.INSTANCE.getClientPlayer();
|
player = ClientPlatform.INSTANCE.getClientPlayer();
|
||||||
} else {
|
} else {
|
||||||
player = context.getSender();
|
player = sup.getSender();
|
||||||
}
|
}
|
||||||
packet.handle(player, LogicalSidedProvider.WORKQUEUE.get(expectedSide));
|
packet.handle(player, LogicalSidedProvider.WORKQUEUE.get(expectedSide));
|
||||||
});
|
});
|
||||||
context.setPacketHandled(true);
|
sup.setPacketHandled(true);
|
||||||
};
|
};
|
||||||
this.channel.registerMessage(this.packetID.getAndIncrement(), (Class<T>) clazz, encoder, decoder, handler);
|
|
||||||
|
int id = packetID.getAndIncrement();
|
||||||
|
packetMap.put(clazz, id);
|
||||||
|
|
||||||
|
this.channel
|
||||||
|
.messageBuilder((Class<T>) clazz, id)
|
||||||
|
.encoder(encoder)
|
||||||
|
.decoder(decoder)
|
||||||
|
.consumerNetworkThread(handler)
|
||||||
|
.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
||||||
return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_SERVER);
|
return NetworkDirection.PLAY_TO_SERVER.buildPacket(toBuffer(packet), channel.getName()).getThis();
|
||||||
|
//return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
||||||
return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_CLIENT);
|
return NetworkDirection.PLAY_TO_CLIENT.buildPacket(toBuffer(packet), channel.getName()).getThis();
|
||||||
|
//return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,23 +130,16 @@ public class ForgeNetworkHandler implements CraterNetworkHandler {
|
|||||||
CraterNetworkHandler.super.sendToServer(packet);
|
CraterNetworkHandler.super.sendToServer(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static CraterNetworkHandler of(String modId, boolean clientRequired, boolean serverRequired) {
|
|
||||||
ForgeNetworkHandler handler = NETWORK_HANDLERS.computeIfAbsent(modId, modId1 -> new ForgeNetworkHandler(buildSimpleChannel(modId1, clientRequired, serverRequired), clientRequired, serverRequired));
|
|
||||||
if (handler.clientRequired != clientRequired) throw new IllegalArgumentException("client channel settings mismatch, expected %s, but was %s".formatted(handler.clientRequired, clientRequired));
|
|
||||||
if (handler.serverRequired != serverRequired) throw new IllegalArgumentException("server channel settings mismatch, expected %s, but was %s".formatted(handler.serverRequired, serverRequired));
|
|
||||||
return handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SimpleChannel buildSimpleChannel(String modId, boolean clientAcceptsVanillaOrMissing, boolean serverAcceptsVanillaOrMissing) {
|
|
||||||
return NetworkRegistry.ChannelBuilder
|
|
||||||
.named(new ResourceLocation(modId, "crater_network"))
|
|
||||||
.networkProtocolVersion(() -> PROTOCOL)
|
|
||||||
.clientAcceptedVersions(clientAcceptsVanillaOrMissing ? NetworkRegistry.acceptMissingOr(PROTOCOL) : PROTOCOL::equals)
|
|
||||||
.serverAcceptedVersions(serverAcceptsVanillaOrMissing ? NetworkRegistry.acceptMissingOr(PROTOCOL) : PROTOCOL::equals)
|
|
||||||
.simpleChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private LogicalSide getSideFromDirection(PacketDirection direction) {
|
private LogicalSide getSideFromDirection(PacketDirection direction) {
|
||||||
return direction == PacketDirection.TO_CLIENT ? LogicalSide.CLIENT : LogicalSide.SERVER;
|
return direction == PacketDirection.TO_CLIENT ? LogicalSide.CLIENT : LogicalSide.SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected FriendlyByteBuf toBuffer(CraterPacket<?> message) {
|
||||||
|
var msg = packetMap.get(message.getClass());
|
||||||
|
|
||||||
|
var ret = new FriendlyByteBuf(Unpooled.buffer());
|
||||||
|
ret.writeVarInt(msg);
|
||||||
|
message.write(ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
modLoader = "javafml"
|
modLoader = "javafml"
|
||||||
loaderVersion = "[44,)"
|
loaderVersion = "[48,)"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
issueTrackerURL = "https://github.com/firstdarkdev/craterLib/issues"
|
issueTrackerURL = "https://github.com/firstdarkdev/craterLib/issues"
|
||||||
|
|
||||||
@@ -19,13 +19,13 @@ displayTest = "MATCH_VERSION"
|
|||||||
[[dependencies.${mod_id}]]
|
[[dependencies.${mod_id}]]
|
||||||
modId = "forge"
|
modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[44,)"
|
versionRange = "[48,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.${mod_id}]]
|
[[dependencies.${mod_id}]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[1.19.3,1.20)"
|
versionRange = "[1.20.2,1.20.3)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
@@ -7,7 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
release=project.properties['release'] ?: false
|
release = project.properties['release'] ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
var base_version = "${version_major}.${version_minor}"
|
var base_version = "${version_major}.${version_minor}"
|
||||||
@@ -68,7 +68,7 @@ subprojects {
|
|||||||
'Implementation-Version' : project.jar.archiveVersion,
|
'Implementation-Version' : project.jar.archiveVersion,
|
||||||
'Implementation-Vendor' : mod_author,
|
'Implementation-Vendor' : mod_author,
|
||||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
'Timestamp' : System.currentTimeMillis(),
|
'Timestamp' : System.currentTimeMillis(),
|
||||||
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
|
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
|
||||||
'Build-On-Minecraft' : minecraft_version
|
'Build-On-Minecraft' : minecraft_version
|
||||||
])
|
])
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#Project
|
#Project
|
||||||
version_major=1
|
version_major=1
|
||||||
version_minor=1
|
version_minor=1
|
||||||
version_patch=1
|
version_patch=2
|
||||||
project_group=com.hypherionmc.craterlib
|
project_group=com.hypherionmc.craterlib
|
||||||
|
|
||||||
#Mod
|
#Mod
|
||||||
@@ -10,17 +10,20 @@ mod_id=craterlib
|
|||||||
mod_name=CraterLib
|
mod_name=CraterLib
|
||||||
|
|
||||||
# Shared
|
# Shared
|
||||||
minecraft_version=1.19.3
|
minecraft_version=1.20.2
|
||||||
|
|
||||||
# Fabric
|
# Fabric
|
||||||
fabric_loader=0.14.21
|
fabric_loader=0.14.22
|
||||||
fabric_api=0.76.1+1.19.3
|
fabric_api=0.89.0+1.20.2
|
||||||
|
|
||||||
# Forge
|
# Forge
|
||||||
forge_version=44.1.0
|
forge_version=48.0.6
|
||||||
|
|
||||||
|
# NeoForged
|
||||||
|
neoforge_version=64-beta
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
mod_menu_version=5.1.0-beta.4
|
mod_menu_version=8.0.0-beta.2
|
||||||
moon_config=1.0.9
|
moon_config=1.0.9
|
||||||
|
|
||||||
# Publishing
|
# Publishing
|
||||||
|
@@ -11,4 +11,4 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'CraterLib'
|
rootProject.name = 'CraterLib'
|
||||||
include("Common", "Fabric", "Forge")
|
include("Common", "Fabric", "Forge")
|
Reference in New Issue
Block a user