diff options
14 files changed, 426 insertions, 54 deletions
diff --git a/Update Notes/2.1.1.md b/Update Notes/2.1.1.md index 988913cc..681f8773 100644 --- a/Update Notes/2.1.1.md +++ b/Update Notes/2.1.1.md @@ -18,6 +18,7 @@ - Add exponent and percentage to calculator - u9g - Add total trophy fish count to /pv - Vixid - Allow hiding messages below a set skyblock level - nopo + - Add Glowing Mushroom Highlighter - nea89 - Add crimson isle quests to todo overlay - Vixid - Add replace chat social options to both party and guild chat - Vixid - Add class average to dungeons page in /pv - Vixid diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index b514e419..c1190b2b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -65,6 +65,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.Custom import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures; import io.github.moulberry.notenoughupdates.miscfeatures.updater.AutoUpdater; +import io.github.moulberry.notenoughupdates.miscfeatures.world.GlowingMushroomHighlighter; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; import io.github.moulberry.notenoughupdates.miscgui.SignCalculator; @@ -324,6 +325,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(AuctionBINWarning.getInstance()); MinecraftForge.EVENT_BUS.register(MinionHelperManager.getInstance()); MinecraftForge.EVENT_BUS.register(navigation); + MinecraftForge.EVENT_BUS.register(new GlowingMushroomHighlighter()); MinecraftForge.EVENT_BUS.register(new WorldListener(this)); MinecraftForge.EVENT_BUS.register(TitleUtil.getInstance()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java index d7bd097a..50eff87a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java @@ -305,7 +305,21 @@ public class RenderUtils { } } - private static void renderBoundingBox(double x, double y, double z, int rgb, float alphaMult, float partialTicks) { + public static void renderBoundingBox( + BlockPos worldPos, + int rgb, + float partialTicks + ) { + Vector3f interpolatedPlayerPosition = getInterpolatedPlayerPosition(partialTicks); + renderBoundingBoxInViewSpace( + worldPos.getX() - interpolatedPlayerPosition.x, + worldPos.getY() - interpolatedPlayerPosition.y, + worldPos.getZ() - interpolatedPlayerPosition.z, + rgb + ); + } + + private static void renderBoundingBoxInViewSpace(double x, double y, double z, int rgb) { AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1); GlStateManager.disableDepth(); @@ -343,33 +357,42 @@ public class RenderUtils { RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, distSq > 10 * 10); } - public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) { - double viewerX; - double viewerY; - double viewerZ; + public static Vector3f getInterpolatedPlayerPosition(float partialTicks) { Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition(); if (aoteInterpPos != null) { - viewerX = aoteInterpPos.x; - viewerY = aoteInterpPos.y; - viewerZ = aoteInterpPos.z; + return new Vector3f(aoteInterpPos); } else { Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); - viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks; - viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks; - viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks; + Vector3f lastPos = new Vector3f( + (float) viewer.lastTickPosX, + (float) viewer.lastTickPosY, + (float) viewer.lastTickPosZ + ); + Vector3f currentPos = new Vector3f( + (float) viewer.posX, + (float) viewer.posY, + (float) viewer.posZ + ); + Vector3f movement = Vector3f.sub(currentPos, lastPos, currentPos); + movement.scale(partialTicks); + return Vector3f.add(lastPos, movement, lastPos); } + } - double x = block.getX() - viewerX; - double y = block.getY() - viewerY; - double z = block.getZ() - viewerZ; + public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) { + + Vector3f interpolatedPlayerPosition = getInterpolatedPlayerPosition(partialTicks); + double x = block.getX() - interpolatedPlayerPosition.x; + double y = block.getY() - interpolatedPlayerPosition.y; + double z = block.getZ() - interpolatedPlayerPosition.z; double distSq = x * x + y * y + z * z; if (distSq > 10 * 10) { RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true); } else { - RenderUtils.renderBoundingBox(x, y, z, rgb, 1.0f, partialTicks); + RenderUtils.renderBoundingBoxInViewSpace(x, y, z, rgb); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java index 178431d0..ed8da0d5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java @@ -27,4 +27,8 @@ public class NEUEvent extends Event { MinecraftForge.EVENT_BUS.post(this); return isCancelable() && isCanceled(); } + + public void cancel() { + setCanceled(true); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/SpawnParticleEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/events/SpawnParticleEvent.java new file mode 100644 index 00000000..818ad0fa --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/events/SpawnParticleEvent.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.events; + +import net.minecraft.util.EnumParticleTypes; +import net.minecraftforge.fml.common.eventhandler.Cancelable; + +@Cancelable +public class SpawnParticleEvent extends NEUEvent { + + // I LOVE code duplication! + // I LOVE repeating field names five times to declare a data class! + // I LOVE that yummy high fructose corn syrup! + // I LOVE the United Nations! + + EnumParticleTypes particleTypes; + boolean isLongDistance; + double xCoord; + double yCoord; + double zCoord; + double xOffset; + double yOffset; + double zOffset; + int[] params; + + public SpawnParticleEvent( + EnumParticleTypes particleTypes, + boolean isLongDistance, + double xCoord, double yCoord, double zCoord, + double xOffset, double yOffset, double zOffset, + int[] params + ) { + this.particleTypes = particleTypes; + this.isLongDistance = isLongDistance; + this.xCoord = xCoord; + this.yCoord = yCoord; + this.zCoord = zCoord; + this.xOffset = xOffset; + this.yOffset = yOffset; + this.zOffset = zOffset; + this.params = params; + } + + public EnumParticleTypes getParticleTypes() { + return particleTypes; + } + + public boolean isLongDistance() { + return isLongDistance; + } + + public double getXCoord() { + return xCoord; + } + + public double getYCoord() { + return yCoord; + } + + public double getZCoord() { + return zCoord; + } + + public double getXOffset() { + return xOffset; + } + + public double getYOffset() { + return yOffset; + } + + public double getZOffset() { + return zOffset; + } + + public int[] getParams() { + return params; + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java index f378fdca..50975af9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java @@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.Line; import io.github.moulberry.notenoughupdates.core.util.Vec3Comparable; +import io.github.moulberry.notenoughupdates.events.SpawnParticleEvent; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; import io.github.moulberry.notenoughupdates.util.NEUDebugLogger; @@ -346,15 +347,15 @@ public class CrystalWishingCompassSolver { * per-area structure missing, or because Hypixel. * Always within 1 block of X=513 Y=106 Z=551. */ - public void onSpawnParticle( - EnumParticleTypes particleType, - double x, - double y, - double z - ) { + @SubscribeEvent + public void onSpawnParticle(SpawnParticleEvent event) { + EnumParticleTypes particleType = event.getParticleTypes(); + double x = event.getXCoord(); + double y = event.getYCoord(); + double z = event.getZCoord(); if (!NotEnoughUpdates.INSTANCE.config.mining.wishingCompassSolver || particleType != EnumParticleTypes.VILLAGER_HAPPY || - !SBInfo.getInstance().getLocation().equals("crystal_hollows")) { + !"crystal_hollows".equals(SBInfo.getInstance().getLocation())) { return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index fff8d269..e3afc73d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.ChromaColour; +import io.github.moulberry.notenoughupdates.events.SpawnParticleEvent; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.block.state.IBlockState; @@ -380,24 +381,24 @@ public class FishingHelper { return 1 / (d + (1 / (ZERO_PITCH - MAX_PITCH))) * (1 - d / MAX_DISTANCE) + MAX_PITCH; } - public boolean onSpawnParticle( - EnumParticleTypes particleType, - double x, - double y, - double z, - double xOffset, - double yOffset, - double zOffset - ) { + @SubscribeEvent + public void onSpawnParticle(SpawnParticleEvent event) { + EnumParticleTypes particleType = event.getParticleTypes(); + double x = event.getXCoord(); + double y = event.getYCoord(); + double z = event.getZCoord(); + double xOffset = event.getXOffset(); + double yOffset = event.getYOffset(); + double zOffset = event.getZOffset(); if (!NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll && !NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles && !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { - return false; + return; } if (hookEntities.isEmpty()) { - return false; + return; } if ((particleType == EnumParticleTypes.WATER_WAKE || particleType == EnumParticleTypes.SMOKE_NORMAL || particleType == EnumParticleTypes.FLAME) && Math.abs( @@ -610,22 +611,24 @@ public class FishingHelper { particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleType; particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleColour; } else if (NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) { - return true; + event.cancel(); + return; } else { particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleType; particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleColour; } if (!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) { - return false; + return; } int argb = SpecialColour.specialToChromaRGB(particleCustomColour); if (particleTypeI == 0) { - return false; + return; } else if (particleTypeI == 1) { - return true; + event.cancel(); + return; } if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().getRenderViewEntity() != null && @@ -633,11 +636,13 @@ public class FishingHelper { int i = Minecraft.getMinecraft().gameSettings.particleSetting; if (i == 1 && Minecraft.getMinecraft().theWorld.rand.nextInt(3) == 0) { - return true; + event.cancel(); + return; } if (i >= 2) { - return true; + event.cancel(); + return; } double xDist = Minecraft.getMinecraft().getRenderViewEntity().posX - x; @@ -678,7 +683,8 @@ public class FishingHelper { } if (customColour && (((argb >> 24) & 0xFF) < 10)) { - return true; + event.cancel(); + return; } EntityFX fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle( @@ -706,10 +712,9 @@ public class FishingHelper { } } - return true; + event.cancel(); + return; } } - - return false; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java new file mode 100644 index 00000000..0e71c7a9 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures.world; + +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.HashSet; +import java.util.Set; + +public abstract class GenericBlockHighlighter { + protected abstract boolean isEnabled(); + + protected abstract boolean isValidHighlightSpot(BlockPos key); + + protected abstract int getColor(BlockPos blockPos); + + public final Set<BlockPos> highlightedBlocks = new HashSet<>(); + + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + if (!isEnabled()) return; + World w = Minecraft.getMinecraft().theWorld; + if (w == null) return; + for (BlockPos blockPos : highlightedBlocks) { + RenderUtils.renderBoundingBox(blockPos, getColor(blockPos), event.partialTicks); + } + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent ev) { + if (ev.phase != TickEvent.Phase.END) return; + highlightedBlocks.removeIf(it -> !isValidHighlightSpot(it) || !canPlayerSeeBlock(it.getX(), it.getY(), it.getZ())); + } + + protected boolean canPlayerSeeBlock(double xCoord, double yCoord, double zCoord) { + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + if (p == null) return false; + World w = p.worldObj; + MovingObjectPosition hitResult = w.rayTraceBlocks( + new Vec3(p.posX, p.posY + p.eyeHeight, p.posZ), + new Vec3(xCoord, yCoord, zCoord), + false, + true, + true + ); + BlockPos bp = new BlockPos(xCoord, yCoord, zCoord); + return hitResult == null + || hitResult.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK + || bp.equals(hitResult.getBlockPos()); + } + + @SubscribeEvent + public void onWorldChange(WorldEvent.Load event) { + highlightedBlocks.clear(); + } + + public void registerInterest(BlockPos pos) { + if (isValidHighlightSpot(pos) && canPlayerSeeBlock(pos.getX(), pos.getY(), pos.getZ())) { + highlightedBlocks.add(pos); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java new file mode 100644 index 00000000..9857f84b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures.world; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.events.SpawnParticleEvent; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import static io.github.moulberry.notenoughupdates.util.MathUtil.isDecimalPartApproximately; + +public class GlowingMushroomHighlighter extends GenericBlockHighlighter { + + @SubscribeEvent + public void onParticleSpawn(SpawnParticleEvent event) { + if (!isEnabled()) return; + if (event.getParticleTypes() == EnumParticleTypes.SPELL_MOB) { + BlockPos blockPos = new BlockPos(event.getXCoord(), event.getYCoord(), event.getZCoord()); + if (highlightedBlocks.contains(blockPos)) return; + if ( + isDecimalPartApproximately(event.getXCoord(), 0.5) + && isDecimalPartApproximately(event.getYCoord(), 0.1) + && isDecimalPartApproximately(event.getZCoord(), 0.5) + ) { + registerInterest(blockPos); + } + } + } + + + @Override + protected boolean isEnabled() { + return "farming_1".equals(SBInfo.getInstance().getLocation()) + && NotEnoughUpdates.INSTANCE.config.world.highlightGlowingMushrooms; + } + + @Override + protected boolean isValidHighlightSpot(BlockPos key) { + World w = Minecraft.getMinecraft().theWorld; + if (w == null) return false; + Block b = w.getBlockState(key).getBlock(); + return b == Blocks.brown_mushroom || b == Blocks.red_mushroom; + } + + @Override + protected int getColor(BlockPos blockPos) { + return SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.world.glowingMushroomColor); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java index 0b33609d..44d7eef6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java @@ -19,10 +19,9 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.miscfeatures.CrystalWishingCompassSolver; +import io.github.moulberry.notenoughupdates.events.SpawnParticleEvent; import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; -import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; import io.github.moulberry.notenoughupdates.miscfeatures.NewApiKeyHelper; @@ -79,22 +78,18 @@ public class MixinNetHandlerPlayClient { double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] params ) { - CrystalWishingCompassSolver.getInstance().onSpawnParticle( - particleTypes, - xCoord, - yCoord, - zCoord - ); - boolean override = FishingHelper.getInstance().onSpawnParticle( + SpawnParticleEvent event = new SpawnParticleEvent( particleTypes, + isLongDistance, xCoord, yCoord, zCoord, xOffset, yOffset, - zOffset + zOffset, + params ); - if (!override) { + if (!event.post()) { world.spawnParticle(particleTypes, isLongDistance, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, params); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index e1e18940..75ae33a1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -33,6 +33,7 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; +import io.github.moulberry.notenoughupdates.options.seperateSections.WorldConfig; import io.github.moulberry.notenoughupdates.options.seperateSections.AHGraph; import io.github.moulberry.notenoughupdates.options.seperateSections.AHTweaks; import io.github.moulberry.notenoughupdates.options.seperateSections.AccessoryBag; @@ -372,6 +373,13 @@ public class NEUConfig extends Config { @Expose @Category( + name = "World Renderer", + desc = "In World Renderers" + ) + public WorldConfig world = new WorldConfig(); + + @Expose + @Category( name = "AH Tweaks", desc = "Tweaks for Hypixel's (Not NEU's) Auction House" ) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java new file mode 100644 index 00000000..1484cb87 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.options.seperateSections; + +import com.google.gson.annotations.Expose; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; + +public class WorldConfig { + @Expose + @ConfigOption( + name = "Highlight Glowing Mushrooms", + desc = "Highlight glowing mushrooms in the mushroom gorge" + ) + @ConfigEditorBoolean + public boolean highlightGlowingMushrooms = false; + + @Expose + @ConfigOption( + name = "Glowing Mushroom Colour", + desc = "In which colour should glowing mushrooms be highlighted" + ) + @ConfigEditorColour + public String glowingMushroomColor = "0:255:142:88:36"; +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java new file mode 100644 index 00000000..f358f37f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.util; + +public class MathUtil { + public static boolean isDecimalPartApproximately(double fullValue, double expectedDecimalPart) { + return Math.abs(Math.abs(fullValue % 1) - expectedDecimalPart) < 0.01; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index e28e52d6..b8e8312d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -271,11 +271,15 @@ public class SBInfo { } } + /** + * @return the current mode, as returned by /locraw, usually equivalent to a skyblock public island type. + */ public String getLocation() { return mode; } public void setLocation(String location) { + location = location == null ? location :location.intern(); if (!Objects.equals(this.mode, location)) { MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(location, this.mode)); } |