diff --git a/build.gradle b/build.gradle index 986f74b..68b7344 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = "1.14.4-1.7" +version = "1.15.2-1.7" group= "net.unladenswallow.minecraft.autofish" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "mod_autofish_forge" @@ -71,7 +71,7 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.14.4-28.1.0' + minecraft 'net.minecraftforge:forge:1.15.2-31.1.0' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..0d4a951 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 949819d..a95009c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/AutoFish.java b/src/main/java/net/unladenswallow/minecraft/autofish/AutoFish.java index 4458274..da6cd72 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/AutoFish.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/AutoFish.java @@ -18,6 +18,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.dimension.DimensionType; @@ -124,7 +125,7 @@ public void onBobberSplashDetected(float x, float y, float z) { FishingBobberEntity hook = this.player.fishingBobber; // double yDifference = Math.abs(hook.posY - y); // Ignore Y component when calculating distance from hook - double xzDistanceFromHook = hook.getDistanceSq(x, hook.posY, z); + double xzDistanceFromHook = hook.getDistanceSq(x, hook.getPositionVec().y, z); if (xzDistanceFromHook <= CLOSE_BOBBER_SPLASH_THRESHOLD) { // AutoFishLogger.info("[%d] Close bobber splash at %f / %f", getGameTime(), xzDistanceFromHook, yDifference); this.closeBobberSplashDetectedAt = getGameTime(); @@ -186,7 +187,8 @@ private boolean isUseOfNonRodInMainHand(Hand hand) { public void onWaterWakeDetected(double x, double y, double z) { if (this.minecraftClient != null && this.minecraftClient.player != null && playerHookInWater(this.minecraftClient.player)) { FishingBobberEntity hook = this.minecraftClient.player.fishingBobber; - double distanceFromHook = new BlockPos(x, y, z).distanceSq(new Vec3i(hook.posX, hook.posY, hook.posZ)); + Vec3d hookPosition = hook.getPositionVec(); + double distanceFromHook = new BlockPos(x, y, z).distanceSq(new Vec3i(hookPosition.x, hookPosition.y, hookPosition.z)); if (distanceFromHook <= CLOSE_WATER_WAKE_THRESHOLD) { if (this.closeWaterWakeDetectedAt <= 0) { // AutoFishLogger.info("[%d] Close water wake at %f", getGameTime(), distanceFromHook); @@ -426,7 +428,8 @@ private boolean playerHookInWater(PlayerEntity player) { // water block, so also check a fraction of a block distance lower to see if that is water. // (EntityFishHook.isInWater() seems to be completely broken in 1.13) BlockState hookBlockState = player.fishingBobber.getEntityWorld().getBlockState(new BlockPos(player.fishingBobber)); - BlockState justBelowHookBlockState = player.fishingBobber.getEntityWorld().getBlockState(new BlockPos(player.fishingBobber.posX, player.fishingBobber.posY - 0.25, player.fishingBobber.posZ)); + Vec3d hookPosition = player.fishingBobber.getPositionVec(); + BlockState justBelowHookBlockState = player.fishingBobber.getEntityWorld().getBlockState(new BlockPos(hookPosition.x, hookPosition.y - 0.25, hookPosition.z)); boolean hookIsInWater = hookBlockState.getMaterial() == Material.WATER || justBelowHookBlockState.getMaterial() == Material.WATER; return hookIsInWater; } diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/ModAutoFish.java b/src/main/java/net/unladenswallow/minecraft/autofish/ModAutoFish.java index 80ac20a..3c95a8f 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/ModAutoFish.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/ModAutoFish.java @@ -7,7 +7,6 @@ import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.unladenswallow.minecraft.autofish.config.AutoFishModConfig; import net.unladenswallow.minecraft.autofish.events.EventListener; @@ -32,10 +31,10 @@ public ModAutoFish() { FMLJavaModLoadingContext.get().getModEventBus().register(AutoFishModConfig.class); MinecraftForge.EVENT_BUS.register(this); AutoFishModConfig.register(ModLoadingContext.get()); -// ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (mc, screen) -> { -// Logger.info("CONFIGGUIFACTORY thing is called"); -// return new ConfigGui(); -// }); + ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (mc, screen) -> { + Logger.info("CONFIGGUIFACTORY thing is called"); + return new ConfigGui(); + }); } @SubscribeEvent diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/events/EventListener.java b/src/main/java/net/unladenswallow/minecraft/autofish/events/EventListener.java index c0c9202..dd0d78d 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/events/EventListener.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/events/EventListener.java @@ -3,6 +3,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.util.SoundEvents; +import net.minecraft.util.math.Vec3d; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.event.TickEvent.ClientTickEvent; import net.minecraftforge.event.TickEvent.Phase; @@ -102,7 +103,8 @@ public void onEntitySpawned(EntityJoinWorldEvent event) { if (AutoFishModConfig.autofishEnabled() && event.getWorld().isRemote) { Entity entity = event.getEntity(); if (entity instanceof ExperienceOrbEntity) { - _autoFish.onXpOrbAdded(entity.posX, entity.posY, entity.posZ); + Vec3d entityPosition = entity.getPositionVec(); + _autoFish.onXpOrbAdded(entityPosition.x, entityPosition.y, entityPosition.z); } } } diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/events/KeyInputHandler.java b/src/main/java/net/unladenswallow/minecraft/autofish/events/KeyInputHandler.java index 02f7f4d..b0fe431 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/events/KeyInputHandler.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/events/KeyInputHandler.java @@ -1,7 +1,5 @@ package net.unladenswallow.minecraft.autofish.events; -import java.util.function.Supplier; - import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.util.InputMappings; diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGui.java b/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGui.java index 8871af3..8680a3f 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGui.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGui.java @@ -8,7 +8,7 @@ import net.minecraft.client.gui.widget.Widget; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.fml.ForgeI18n; -import net.minecraftforge.fml.client.config.GuiButtonExt; +import net.minecraftforge.fml.client.gui.widget.ExtendedButton; import net.unladenswallow.minecraft.autofish.config.AutoFishModConfig; import net.unladenswallow.minecraft.autofish.config.ConfigOption; import net.unladenswallow.minecraft.autofish.util.Logger; @@ -74,7 +74,7 @@ protected void init() { addButton(new ConfigGuiButton(this.font, buttonX, rowY, BUTTON_WIDTH, BUTTON_HEIGHT, option)); buttonIndex++; } - addButton(new GuiButtonExt((this.width - BUTTON_WIDTH) / 2, this.height - 20 - BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, ForgeI18n.parseMessage("gui.autofish.config.done"), + addButton(new ExtendedButton((this.width - BUTTON_WIDTH) / 2, this.height - 20 - BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, ForgeI18n.parseMessage("gui.autofish.config.done"), b -> {this.closeGui();})); } @@ -126,7 +126,7 @@ public void renderButton(int p_renderButton_1_, int p_renderButton_2_, float p_r @Override public void renderToolTip(int mouseX, int mouseY) { - net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText( + net.minecraftforge.fml.client.gui.GuiUtils.drawHoveringText( Arrays.asList(this.tooltip), mouseX, mouseY, diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGuiButton.java b/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGuiButton.java index 6d2dacd..bf13c5d 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGuiButton.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/gui/ConfigGuiButton.java @@ -2,13 +2,13 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraftforge.fml.ForgeI18n; -import net.minecraftforge.fml.client.config.GuiButtonExt; +import net.minecraftforge.fml.client.gui.widget.ExtendedButton; import net.unladenswallow.minecraft.autofish.config.AutoFishModConfig; import net.unladenswallow.minecraft.autofish.config.ConfigOption; import net.unladenswallow.minecraft.autofish.config.ConfigOption.ValueType; import net.unladenswallow.minecraft.autofish.util.Logger; -class ConfigGuiButton extends GuiButtonExt { +class ConfigGuiButton extends ExtendedButton { private ConfigOption configOption; diff --git a/src/main/java/net/unladenswallow/minecraft/autofish/gui/GuiFactory.java b/src/main/java/net/unladenswallow/minecraft/autofish/gui/GuiFactory.java index 5077d3f..6daca0b 100644 --- a/src/main/java/net/unladenswallow/minecraft/autofish/gui/GuiFactory.java +++ b/src/main/java/net/unladenswallow/minecraft/autofish/gui/GuiFactory.java @@ -1,30 +1,23 @@ -package net.unladenswallow.minecraft.autofish.gui; - -import java.util.Set; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraftforge.fml.client.IModGuiFactory; - -public class GuiFactory implements IModGuiFactory { - - @Override - public void initialize(Minecraft minecraftInstance) { - } - - @Override - public Set runtimeGuiCategories() { - return null; - } - - @Override - public boolean hasConfigGui() { - return true; - } - - @Override - public Screen createConfigGui(Screen parentScreen) { - return new ConfigGui(); - } - -} +/* + * package net.unladenswallow.minecraft.autofish.gui; + * + * import java.util.Set; + * + * import net.minecraft.client.Minecraft; import + * net.minecraft.client.gui.screen.Screen; import + * net.minecraftforge.fml.client.IModGuiFactory; + * + * public class GuiFactory implements IModGuiFactory { + * + * @Override public void initialize(Minecraft minecraftInstance) { } + * + * @Override public Set runtimeGuiCategories() { + * return null; } + * + * @Override public boolean hasConfigGui() { return true; } + * + * @Override public Screen createConfigGui(Screen parentScreen) { return new + * ConfigGui(); } + * + * } + */ \ No newline at end of file