Skip to content

Commit

Permalink
updated mod to 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
lilgallon committed Dec 7, 2021
1 parent a5e011c commit 1994a07
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 1.4.2 for Minecraft 1.18.x

- Updated mod to 1.18

## Version 1.4.2 for Minecraft 1.17.x

- Improved German translation (thanks @Greg-21)
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = 'MC1.17.x-1.4.2'
version = 'MC1.18.x-1.4.2'
group = 'dev.nero.horsestatsmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'horsestatsmod'

java.toolchain.languageVersion = JavaLanguageVersion.of(16)
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

minecraft {
mappings channel: 'official', version: '1.17.1'
mappings channel: 'official', version: '1.18'

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

Expand All @@ -42,5 +42,5 @@ minecraft {
sourceSets.main.resources { srcDir 'src/generated/resources' }

dependencies {
minecraft 'net.minecraftforge:forge:1.17.1-37.0.51'
minecraft 'net.minecraftforge:forge:1.18-38.0.15'
}
28 changes: 14 additions & 14 deletions src/main/java/dev/nero/horsestatsmod/HorseStatsMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.animal.horse.Llama;
import net.minecraftforge.client.event.GuiContainerEvent;
import net.minecraftforge.client.event.ContainerScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fmlclient.gui.GuiUtils;
import net.minecraftforge.fmllegacy.network.FMLNetworkConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

import static net.minecraftforge.network.NetworkConstants.IGNORESERVERONLY;

@Mod(HorseStatsMod.MODID)
public class HorseStatsMod
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public HorseStatsMod() {
// the server as incompatible
ModLoadingContext.get().registerExtensionPoint(
IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (remote, isServer)-> true)
() -> new IExtensionPoint.DisplayTest(() -> IGNORESERVERONLY, (remote, isServer)-> true)
);

MinecraftForge.EVENT_BUS.addListener(this::onEntityInteractEvent);
Expand Down Expand Up @@ -147,12 +147,12 @@ private void onEntityInteractEvent(final PlayerInteractEvent.EntityInteractSpeci
}
}

private void onDrawForegroundEvent(final GuiContainerEvent.DrawForeground event) {
if (event.getGuiContainer() instanceof HorseInventoryScreen) {
private void onDrawForegroundEvent(final ContainerScreenEvent.DrawForeground event) {
if (event.getContainerScreen() instanceof HorseInventoryScreen) {
// 1. GET THE STATISTICS OF THAT RIDDEN HORSE

// The horse attribute is private in HorseInventoryScreen (see accesstransformer.cfg)
AbstractHorse horse = ((HorseInventoryScreen) event.getGuiContainer()).horse;
AbstractHorse horse = ((HorseInventoryScreen) event.getContainerScreen()).horse;
getHorseStats(horse);

// 2. DISPLAY THE I18n.get("horsestatsmod.stats")
Expand All @@ -162,19 +162,19 @@ private void onDrawForegroundEvent(final GuiContainerEvent.DrawForeground event)
// no clue lol
int mouseX = (
(int) Minecraft.getInstance().mouseHandler.xpos()
- 2 * event.getGuiContainer().getGuiLeft()
- 2 * event.getContainerScreen().getGuiLeft()
);
int mouseY = (
(int) Minecraft.getInstance().mouseHandler.ypos()
- 2 * event.getGuiContainer().getGuiTop()
- 2 * event.getContainerScreen().getGuiTop()
);

if (TheModConfig.displayStats()) {
// Show the stats on the GUI
displayStatsAndHoveringTexts(horse, mouseX, mouseY);
} else {
// Show the stats only if the mouse is on the horse's name
displayStatsInHoveringText(((HorseInventoryScreen) event.getGuiContainer()), mouseX, mouseY);
displayStatsInHoveringText(((HorseInventoryScreen) event.getContainerScreen()), mouseX, mouseY);
}
}
}
Expand Down Expand Up @@ -370,14 +370,14 @@ private void drawHoveringText(int x, int y, String title, String min, String max
}

private void drawHoveringText(int x, int y, List<Component> textLines) {

GuiUtils.drawHoveringText(
Minecraft.getInstance().screen.renderTooltip(
new PoseStack(),
textLines,
java.util.Optional.empty(),
// why /2? bc it works that way, I did not inspect the mc code in depth to understand
x/2, y/2,
Minecraft.getInstance().getWindow().getWidth(),
Minecraft.getInstance().getWindow().getHeight(),150,
// Minecraft.getInstance().getWindow().getWidth(),
// Minecraft.getInstance().getWindow().getHeight(),150,
Minecraft.getInstance().font
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
modLoader="javafml" #mandatory
loaderVersion="[37,)" #mandatory
loaderVersion="[38,)" #mandatory
license="GNU GPL-3.0"
issueTrackerURL="https://github.com/lilgallon/HorseStatsMod/issues" #optional

[[mods]] #mandatory
modId="horsestatsmod" #mandatory
version="1.4.2" #mandatory
displayName="Horse Stats Mod" #mandatory
updateJSONURL="https://raw.githubusercontent.com/lilgallon/HorseStatsMod/MC_1.17.x/update.json" #optional
updateJSONURL="https://raw.githubusercontent.com/lilgallon/HorseStatsMod/MC_1.18.x/update.json" #optional
displayURL="https://github.com/lilgallon/HorseStatsMod" #optional
logoFile="horsestatsmod.png" #optional (jar root)
# credits="" #optional
Expand All @@ -23,7 +23,7 @@ modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[37,)" #mandatory
versionRange="[38,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
Expand Down
4 changes: 3 additions & 1 deletion update.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"1.16.5-latest": "1.4.2",
"1.16.5-recommended": "1.4.2",
"1.17.1-latest": "1.4.2",
"1.17.1-recommended": "1.4.2"
"1.17.1-recommended": "1.4.2",
"1.18-latest": "1.4.2",
"1.18-recommended": "1.4.2"
}
}

0 comments on commit 1994a07

Please sign in to comment.