Skip to content

Commit

Permalink
Update to 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ustc-zzzz committed Mar 18, 2023
1 parent f4c7585 commit 484d528
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bin/
# mc

eclipse/
run/
run_client/
run_server/
logs/
remappedSrc/
Expand Down
20 changes: 6 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
}

apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'net.minecraftforge.gradle'

apply from: 'gradle/teacon-forge.gradle'

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

// definitions at gradle/teacon-forge.gradle
teacon {
modId = 'sign_up'
modVersion = '0.3.2'
modVersion = '0.4.0'
modLicense = 'BSD-3-Clause'
modGitHubRepo = 'teaconmc/SignMeUp'
modAuthors = ['3TUSK', 'yuesha-yc (YueSha)', 'Hookan', 'ustc-zzzz']
modDescription = 'Sign up, sign in, in-game guide map and more.'

platform = 'forge-1.18.2-40.1.19'
platform = 'forge-1.19.4-45.0.9'
// parchment = '2022.01.23'

// uncomment these lines if you need
Expand Down
2 changes: 1 addition & 1 deletion gradle/teacon-forge.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ gradle.afterProject { Project current ->
lines += "version=\"\${file.jarVersion}\""
lines += "displayName=\"${escaped(modName)}\""
lines += "authors=\"TeaConMC${modAuthors.collect { ', ' + escaped(it) }.join()}\""
lines += "displayName=\"${escaped(publishDescription)}\""
lines += "description=\"${escaped(publishDescription)}\""
lines += ""

// forge dependency
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pluginManagement.repositories {
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
}

rootProject.name = 'SignMeUp'
14 changes: 7 additions & 7 deletions src/main/java/org/teacon/signin/SignMeUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.commands.arguments.ResourceLocationArgument;
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -23,7 +23,6 @@
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;

import org.teacon.signin.client.SignMeUpClient;
import org.teacon.signin.command.CommandImpl;
import org.teacon.signin.data.DynamicLocationStorage;
Expand Down Expand Up @@ -98,10 +97,10 @@ public static void command(RegisterCommandsEvent event) {
.then(Commands.literal("trigger")
.then(Commands.argument("id", ResourceLocationArgument.id())
.suggests((src, builder) -> {
if(FMLEnvironment.dist.isClient()) {
SignMeUpClient.MANAGER.getAllTriggers().stream().forEach(location -> builder.suggest(location.toString()));
if (FMLEnvironment.dist.isClient()) {
SignMeUpClient.MANAGER.getAllTriggers().forEach(location -> builder.suggest(location.toString()));
} else {
SignMeUp.MANAGER.getAllTriggers().stream().forEach(location -> builder.suggest(location.toString()));
SignMeUp.MANAGER.getAllTriggers().forEach(location -> builder.suggest(location.toString()));
}
return builder.buildFuture();
}).executes(CommandImpl::trigger))));
Expand All @@ -122,12 +121,13 @@ public static boolean trigger(ServerPlayer player, Vec3i pos, ResourceLocation t
? player.createCommandSourceStack().withPosition(pos3d).withPermission(2)
: player.createCommandSourceStack().withPosition(pos3d).withSuppressedOutput().withMaximumPermission(2);
for (String command : trigger.executes) {
server.getCommands().performCommand(source, command);
server.getCommands().performPrefixedCommand(source, command);
}
}
return true;
} else {
player.displayClientMessage(new TextComponent("You seemed to click the void just now..."), true);
// TODO: make it translatable
player.displayClientMessage(Component.literal("You seemed to click the void just now..."), true);
return false;
}
}
Expand Down
29 changes: 16 additions & 13 deletions src/main/java/org/teacon/signin/client/GuideMapScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -165,11 +163,16 @@ protected void init() {
final int wpY = Math.round((float) outputY[i] / this.map.radius * 64) + 64;
if (wpX >= 1 && wpX <= 127 && wpY >= 1 && wpY <= 127) {
// Setup Waypoints as ImageButtons
this.addRenderableWidget(new ImageButton(mapCanvasX + wpX - 2, mapCanvasY + wpY - 2, 4, 4, 58, 2, 0, MAP_ICONS,
128, 128, (btn) -> this.selectedWaypoint = wpId, (btn, transform, mouseX, mouseY) -> {
double distance = Math.sqrt(wp.getActualLocation().distToCenterSqr(this.playerLocation));
this.queuedTips.offer(Pair.of(wp.getTitle(), this.toDistanceText(distance)));
}, wp.getTitle()));
final Button.OnPress onPress = (btn) -> {
this.selectedWaypoint = wpId;
if (btn.isHoveredOrFocused()) {
double distance = Math.sqrt(wp.getActualLocation().distToCenterSqr(this.playerLocation));
this.queuedTips.offer(Pair.of(wp.getTitle(), this.toDistanceText(distance)));
}
};
this.addRenderableWidget(new ImageButton(
mapCanvasX + wpX - 2, mapCanvasY + wpY - 2, 4, 4,
58, 2, 0, MAP_ICONS, 128, 128, onPress, wp.getTitle()));
// Setup trigger buttons from Waypoints
List<ResourceLocation> wpTriggerIds = wp.getTriggerIds();
for (int j = 0, k = 0; k < wpTriggerIds.size() && j < 7; ++k) {
Expand Down Expand Up @@ -216,8 +219,8 @@ public void tick() {
}
}

private TranslatableComponent toDistanceText(double distance) {
return new TranslatableComponent("sign_up.waypoint.distance", "%.1f".formatted(distance));
private Component toDistanceText(double distance) {
return Component.translatable("sign_up.waypoint.distance", "%.1f".formatted(distance));
}

@Override
Expand Down Expand Up @@ -262,7 +265,7 @@ private void renderTextCollection(PoseStack transforms, int mouseX, int mouseY,
List<Component> tooltipTexts = new ArrayList<>(this.queuedTips.size() * 2 + 1);
for (Pair<Component, Component> pair = this.queuedTips.poll(); pair != null; pair = this.queuedTips.poll()) {
if (!tooltipTexts.isEmpty()) {
tooltipTexts.add(TextComponent.EMPTY);
tooltipTexts.add(Component.empty());
}
tooltipTexts.add(pair.getFirst());
tooltipTexts.add(pair.getSecond());
Expand Down Expand Up @@ -438,11 +441,11 @@ private TriggerButton(int x, int y, int width, int height, int uOffset, int vOff
}

@Override
public void renderButton(PoseStack transforms, int mouseX, int mouseY, float partialTicks) {
super.renderButton(transforms, mouseX, mouseY, partialTicks);
public void renderWidget(PoseStack transforms, int mouseX, int mouseY, float partialTicks) {
super.renderWidget(transforms, mouseX, mouseY, partialTicks);
//final Font font = Minecraft.getInstance().font;
final int stringWidth = font.width(this.trigger.getTitle());
final int x0 = this.x + this.width / 2 - stringWidth / 2, y0 = this.y + (this.height - 8) / 2;
final int x0 = this.getX() + this.width / 2 - stringWidth / 2, y0 = this.getY() + (this.height - 8) / 2;
font.draw(transforms, this.trigger.getTitle(), x0, y0, this.trigger.disabled ? 0xFFFFFF : 0x404040);
if (this.isHovered) {
GuideMapScreen.this.renderTooltip(transforms, this.trigger.getDesc(), mouseX, mouseY);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/teacon/signin/client/Hotkey.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.teacon.signin.client;

import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
Expand All @@ -16,7 +16,7 @@
public final class Hotkey {

@SubscribeEvent
public static void keyTyped(InputEvent.KeyInputEvent event) {
public static void keyTyped(InputEvent.Key event) {
if (SignMeUpClient.keyOpenMap != null && SignMeUpClient.keyOpenMap.isDown()) {
Minecraft mc = Minecraft.getInstance();
if (mc.player != null) {
Expand All @@ -25,7 +25,7 @@ public static void keyTyped(InputEvent.KeyInputEvent event) {
if (entry != null) {
mc.setScreen(new GuideMapScreen(entry.getKey(), entry.getValue(), position));
} else {
mc.player.displayClientMessage(new TranslatableComponent("sign_up.status.no_map_available"), true);
mc.player.displayClientMessage(Component.translatable("sign_up.status.no_map_available"), true);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/teacon/signin/client/SignMeUpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ClientRegistry;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import org.lwjgl.glfw.GLFW;


Expand All @@ -20,8 +19,8 @@ public final class SignMeUpClient {
static KeyMapping keyOpenMap;

@SubscribeEvent
public static void setup(FMLClientSetupEvent event) {
ClientRegistry.registerKeyBinding(keyOpenMap = new KeyMapping("sign_up.keybinding.open_map",
public static void setup(RegisterKeyMappingsEvent event) {
event.register(keyOpenMap = new KeyMapping("sign_up.keybinding.open_map",
KeyConflictContext.IN_GAME, KeyModifier.NONE,
InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_M, "sign_up.keybinding"));
}
Expand Down
Loading

0 comments on commit 484d528

Please sign in to comment.