diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures')
45 files changed, 1482 insertions, 478 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java index 3bae4715..c52f8968 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.gson.JsonObject; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java index 5137c90f..97e32749 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -58,8 +77,9 @@ public class AuctionSortModeWarning { String warningText = "\u00a7aSort: " + selectedColour + selectedSort; int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText); - int centerX = ((AccessorGuiContainer)chest).getGuiLeft() + ((AccessorGuiContainer)chest).getXSize() / 2 + 9; - int centerY = ((AccessorGuiContainer)chest).getGuiTop() + 26; + int centerX = + ((AccessorGuiContainer) chest).getGuiLeft() + ((AccessorGuiContainer) chest).getXSize() / 2 + 9; + int centerY = ((AccessorGuiContainer) chest).getGuiTop() + 26; RenderUtils.drawFloatingRectDark(centerX - warningLength / 2 - 4, centerY - 6, warningLength + 8, 12, false diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java index 811c30d2..e51496e3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.gson.JsonObject; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java index 0abd5216..2aec0fbe 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.common.collect.Lists; @@ -20,7 +39,7 @@ public class CookieWarning { @SubscribeEvent public void onJoinWorld(EntityJoinWorldEvent e) { - if(e.entity == Minecraft.getMinecraft().thePlayer) { + if (e.entity == Minecraft.getMinecraft().thePlayer) { this.checkCookie(); } } @@ -33,24 +52,27 @@ public class CookieWarning { * Checks the tab list for a cookie timer, and sends a chat message if the timer is within the tolerance */ private void checkCookie() { - if(!hasNotified && NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif) { + if (!hasNotified && NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif) { String[] lines = {}; try { - lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()).getFooter().getUnformattedText().split("\n"); - } catch(NullPointerException e) { + lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()) + .getFooter() + .getUnformattedText() + .split("\n"); + } catch (NullPointerException e) { return; // if the footer is null or somehow doesn't exist, stop } boolean hasCookie = true; String timeLine = null; // the line that contains the cookie timer - for(int i = 0; i < lines.length; i++) { - if(lines[i].startsWith("Cookie Buff")) { - timeLine = lines[i+1]; // the line after the "Cookie Buff" line + for (int i = 0; i < lines.length; i++) { + if (lines[i].startsWith("Cookie Buff")) { + timeLine = lines[i + 1]; // the line after the "Cookie Buff" line } - if(lines[i].startsWith("Not active! Obtain booster cookies from the")) { + if (lines[i].startsWith("Not active! Obtain booster cookies from the")) { hasCookie = false; } } - if(!hasCookie) { + if (!hasCookie) { NotificationHandler.displayNotification(Lists.newArrayList( "\u00a7cBooster Cookie Ran Out!", "\u00a77Your Booster Cookie expired!", @@ -60,21 +82,21 @@ public class CookieWarning { hasNotified = true; return; } - if(timeLine != null) { + if (timeLine != null) { String[] digits = timeLine.split(" "); int minutes = 0; try { - for(String digit : digits) { - if(digit.endsWith("y")) { + for (String digit : digits) { + if (digit.endsWith("y")) { digit = digit.substring(0, digit.length() - 1); minutes += Integer.parseInt(digit) * 525600; - } else if(digit.endsWith("d")) { + } else if (digit.endsWith("d")) { digit = digit.substring(0, digit.length() - 1); minutes += Integer.parseInt(digit) * 1440; - } else if(digit.endsWith("h")) { + } else if (digit.endsWith("h")) { digit = digit.substring(0, digit.length() - 1); minutes += Integer.parseInt(digit) * 60; - } else if(digit.endsWith("m")) { + } else if (digit.endsWith("m")) { digit = digit.substring(0, digit.length() - 1); minutes += Integer.parseInt(digit); } // ignore seconds @@ -85,7 +107,7 @@ public class CookieWarning { EnumChatFormatting.RED + "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details.")); } - if(minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins) { + if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins) { NotificationHandler.displayNotification(Lists.newArrayList( "\u00a7cBooster Cookie Running Low!", "\u00a77Your Booster Cookie will expire in " + timeLine, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java index f43ebda2..167b6a2f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -52,56 +71,56 @@ public class CrystalMetalDetectorSolver { private static final String EMERALD_STRING = "emerald"; private static final String GOLD_STRING = "gold"; private static final HashMap<String, Vec3i> keeperOffsets = new HashMap<String, Vec3i>() {{ - put(DIAMOND_STRING, new Vec3i(33,0,3)); - put(LAPIS_STRING, new Vec3i(-33,0,-3)); - put(EMERALD_STRING, new Vec3i(-3,0,33)); - put(GOLD_STRING, new Vec3i(3,0,-33)); + put(DIAMOND_STRING, new Vec3i(33, 0, 3)); + put(LAPIS_STRING, new Vec3i(-33, 0, -3)); + put(EMERALD_STRING, new Vec3i(-3, 0, 33)); + put(GOLD_STRING, new Vec3i(3, 0, -33)); }}; // Chest offsets from center private static final HashSet<Long> knownChestOffsets = new HashSet<>(Arrays.asList( - -10171958951910L, // x=-38, y=-22, z=26 - 10718829084646L, // x=38, y=-22, z=-26 - -10721714765806L, // x=-40, y=-22, z=18 - -10996458455018L, // x=-41, y=-20, z=22 - -1100920913904L, // x=-5, y=-21, z=16 - 11268584898530L, // x=40, y=-22, z=-30 - -11271269253148L, // x=-42, y=-20, z=-28 - -11546281377832L, // x=-43, y=-22, z=-40 - 11818542038999L, // x=42, y=-19, z=-41 - 12093285728240L, // x=43, y=-21, z=-16 - -1409286164L, // x=-1, y=-22, z=-20 - 1922736062492L, // x=6, y=-21, z=28 - 2197613969419L, // x=7, y=-21, z=11 - 2197613969430L, // x=7, y=-21, z=22 - -3024999153708L, // x=-12, y=-21, z=-44 - 3571936395295L, // x=12, y=-22, z=31 - 3572003504106L, // x=12, y=-22, z=-22 - 3572003504135L, // x=12, y=-21, z=7 - 3572070612949L, // x=12, y=-21, z=-43 - -3574822076373L, // x=-14, y=-21, z=43 - -3574822076394L, // x=-14, y=-21, z=22 - -4399455797228L, // x=-17, y=-21, z=20 - -5224156626944L, // x=-20, y=-22, z=0 - 548346527764L, // x=1, y=-21, z=20 - 5496081743901L, // x=19, y=-22, z=29 - 5770959650816L, // x=20, y=-22, z=0 - 5771093868518L, // x=20, y=-21, z=-26 - -6048790347736L, // x=-23, y=-22, z=40 - 6320849682418L, // x=22, y=-21, z=-14 - -6323668254708L, // x=-24, y=-22, z=12 - 6595593371674L, // x=23, y=-22, z=26 - 6595660480473L, // x=23, y=-22, z=-39 - 6870471278619L, // x=24, y=-22, z=27 - 7145349185553L, // x=25, y=-22, z=17 - 8244995030996L, // x=29, y=-21, z=-44 - -8247679385612L, // x=-31, y=-21, z=-12 - -8247679385640L, // x=-31, y=-21, z=-40 - 8519872937959L, // x=30, y=-21, z=-25 - -8522557292584L, // x=-32, y=-21, z=-40 - -9622068920278L, // x=-36, y=-20, z=42 - -9896946827278L, // x=-37, y=-21, z=-14 - -9896946827286L // x=-37, y=-21, z=-22 + -10171958951910L, // x=-38, y=-22, z=26 + 10718829084646L, // x=38, y=-22, z=-26 + -10721714765806L, // x=-40, y=-22, z=18 + -10996458455018L, // x=-41, y=-20, z=22 + -1100920913904L, // x=-5, y=-21, z=16 + 11268584898530L, // x=40, y=-22, z=-30 + -11271269253148L, // x=-42, y=-20, z=-28 + -11546281377832L, // x=-43, y=-22, z=-40 + 11818542038999L, // x=42, y=-19, z=-41 + 12093285728240L, // x=43, y=-21, z=-16 + -1409286164L, // x=-1, y=-22, z=-20 + 1922736062492L, // x=6, y=-21, z=28 + 2197613969419L, // x=7, y=-21, z=11 + 2197613969430L, // x=7, y=-21, z=22 + -3024999153708L, // x=-12, y=-21, z=-44 + 3571936395295L, // x=12, y=-22, z=31 + 3572003504106L, // x=12, y=-22, z=-22 + 3572003504135L, // x=12, y=-21, z=7 + 3572070612949L, // x=12, y=-21, z=-43 + -3574822076373L, // x=-14, y=-21, z=43 + -3574822076394L, // x=-14, y=-21, z=22 + -4399455797228L, // x=-17, y=-21, z=20 + -5224156626944L, // x=-20, y=-22, z=0 + 548346527764L, // x=1, y=-21, z=20 + 5496081743901L, // x=19, y=-22, z=29 + 5770959650816L, // x=20, y=-22, z=0 + 5771093868518L, // x=20, y=-21, z=-26 + -6048790347736L, // x=-23, y=-22, z=40 + 6320849682418L, // x=22, y=-21, z=-14 + -6323668254708L, // x=-24, y=-22, z=12 + 6595593371674L, // x=23, y=-22, z=26 + 6595660480473L, // x=23, y=-22, z=-39 + 6870471278619L, // x=24, y=-22, z=27 + 7145349185553L, // x=25, y=-22, z=17 + 8244995030996L, // x=29, y=-21, z=-44 + -8247679385612L, // x=-31, y=-21, z=-12 + -8247679385640L, // x=-31, y=-21, z=-40 + 8519872937959L, // x=30, y=-21, z=-25 + -8522557292584L, // x=-32, y=-21, z=-40 + -9622068920278L, // x=-36, y=-20, z=42 + -9896946827278L, // x=-37, y=-21, z=-14 + -9896946827286L // x=-37, y=-21, z=-22 )); static Predicate<BlockPos> treasureAllowedPredicate = CrystalMetalDetectorSolver::treasureAllowed; @@ -153,9 +172,11 @@ public class CrystalMetalDetectorSolver { mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Found solution.")); if (NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.contains(NEUDebugFlag.METAL) && (previousState == SolutionState.INVALID || previousState == SolutionState.FAILED)) { - NEUDebugLogger.log(NEUDebugFlag.METAL, + NEUDebugLogger.log( + NEUDebugFlag.METAL, EnumChatFormatting.AQUA + "Solution coordinates: " + - EnumChatFormatting.WHITE + possibleBlocks.iterator().next().toString()); + EnumChatFormatting.WHITE + possibleBlocks.iterator().next().toString() + ); } break; case INVALID: @@ -184,9 +205,9 @@ public class CrystalMetalDetectorSolver { } static void findPossibleSolutions(double distToTreasure, Vec3Comparable playerPos, boolean centerNewlyDiscovered) { - if (prevDistToTreasure == distToTreasure && prevPlayerPos.equals(playerPos) && - !evaluatedPlayerPositions.containsKey(playerPos)) { - evaluatedPlayerPositions.put(playerPos, distToTreasure); + if (prevDistToTreasure == distToTreasure && prevPlayerPos.equals(playerPos) && + !evaluatedPlayerPositions.containsKey(playerPos)) { + evaluatedPlayerPositions.put(playerPos, distToTreasure); if (possibleBlocks.size() == 0) { for (int zOffset = (int) Math.floor(-distToTreasure); zOffset <= Math.ceil(distToTreasure); zOffset++) { for (int y = 65; y <= 75; y++) { @@ -259,7 +280,7 @@ public class CrystalMetalDetectorSolver { if (minesCenter != Vec3i.NULL_VECTOR) { BlockPos relativeOffset = blockPos.subtract(minesCenter); sb.append(", Relative: "); - sb.append(relativeOffset.toString() ); + sb.append(relativeOffset.toString()); sb.append(" (" + relativeOffset.toLong() + ")"); } sb.append("\n"); @@ -296,7 +317,7 @@ public class CrystalMetalDetectorSolver { if (chestFound) { prevPlayerPos = null; prevDistToTreasure = 0; - if (possibleBlocks.size() == 1) { + if (possibleBlocks.size() == 1) { openedChestPositions.add(possibleBlocks.iterator().next().getImmutable()); } } @@ -360,11 +381,11 @@ public class CrystalMetalDetectorSolver { EntityArmorStand keeperEntity = keeperEntities.get(0); String keeperName = keeperEntity.getCustomNameTag(); - NEUDebugLogger.log(NEUDebugFlag.METAL,"Locating center using Keeper: " + + NEUDebugLogger.log(NEUDebugFlag.METAL, "Locating center using Keeper: " + EnumChatFormatting.WHITE + keeperEntity); String keeperType = keeperName.substring(keeperName.indexOf(KEEPER_OF_STRING) + KEEPER_OF_STRING.length()); - minesCenter = keeperEntity.getPosition().add(keeperOffsets.get(keeperType.toLowerCase())); - NEUDebugLogger.log(NEUDebugFlag.METAL,"Mines center: " + + minesCenter = keeperEntity.getPosition().add(keeperOffsets.get(keeperType.toLowerCase())); + NEUDebugLogger.log(NEUDebugFlag.METAL, "Mines center: " + EnumChatFormatting.WHITE + minesCenter.toString()); mc.thePlayer.addChatMessage(new ChatComponentText( EnumChatFormatting.YELLOW + "[NEU] Faster treasure hunting is now enabled based on Keeper location.")); @@ -538,8 +559,7 @@ public class CrystalMetalDetectorSolver { return; } - if (!NotEnoughUpdates.INSTANCE.config.mining.metalDetectorEnabled) - { + if (!NotEnoughUpdates.INSTANCE.config.mining.metalDetectorEnabled) { mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Metal Detector Solver is not enabled.")); return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java index 2b095c42..c0653742 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; 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 1bc26d50..19cf9c09 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -74,6 +93,7 @@ public class CrystalWishingCompassSolver { } private static final CrystalWishingCompassSolver INSTANCE = new CrystalWishingCompassSolver(); + public static CrystalWishingCompassSolver getInstance() { return INSTANCE; } @@ -118,9 +138,11 @@ public class CrystalWishingCompassSolver { public LongSupplier currentTimeMillis = System::currentTimeMillis; public BooleanSupplier kingsScentPresent = this::isKingsScentPresent; public BooleanSupplier keyInInventory = this::isKeyInInventory; + public interface CrystalEnumSetSupplier { EnumSet<Crystal> getAsCrystalEnumSet(); } + public CrystalEnumSetSupplier foundCrystals = this::getFoundCrystals; private SolverState solverState; @@ -159,7 +181,7 @@ public class CrystalWishingCompassSolver { } private void resetForNewTarget() { - NEUDebugLogger.log(NEUDebugFlag.WISHING,"Resetting for new target"); + NEUDebugLogger.log(NEUDebugFlag.WISHING, "Resetting for new target"); solverState = SolverState.NOT_STARTED; firstCompass = null; secondCompass = null; @@ -188,7 +210,7 @@ public class CrystalWishingCompassSolver { event.entityPlayer != mc.thePlayer || (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR && event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) - ) { + ) { return; } @@ -248,57 +270,57 @@ public class CrystalWishingCompassSolver { public HandleCompassResult handleCompassUse(BlockPos playerPos) { long lastCompassUsedMillis = 0; switch (solverState) { - case PROCESSING_SECOND_USE: - if (secondCompass != null) { - lastCompassUsedMillis = secondCompass.whenUsedMillis; - } - case PROCESSING_FIRST_USE: - if (lastCompassUsedMillis == 0 && firstCompass != null) { - lastCompassUsedMillis = firstCompass.whenUsedMillis; - } - if (lastCompassUsedMillis != 0 && - (currentTimeMillis.getAsLong() > lastCompassUsedMillis + ALL_PARTICLES_MAX_MILLIS)) { - return HandleCompassResult.NO_PARTICLES_FOR_PREVIOUS_COMPASS; - } - - return HandleCompassResult.STILL_PROCESSING_PRIOR_USE; - case SOLVED: - case FAILED_EXCEPTION: - case FAILED_TIMEOUT_NO_REPEATING: - case FAILED_TIMEOUT_NO_PARTICLES: - case FAILED_INTERSECTION_CALCULATION: - case FAILED_INVALID_SOLUTION: + case PROCESSING_SECOND_USE: + if (secondCompass != null) { + lastCompassUsedMillis = secondCompass.whenUsedMillis; + } + case PROCESSING_FIRST_USE: + if (lastCompassUsedMillis == 0 && firstCompass != null) { + lastCompassUsedMillis = firstCompass.whenUsedMillis; + } + if (lastCompassUsedMillis != 0 && + (currentTimeMillis.getAsLong() > lastCompassUsedMillis + ALL_PARTICLES_MAX_MILLIS)) { + return HandleCompassResult.NO_PARTICLES_FOR_PREVIOUS_COMPASS; + } + + return HandleCompassResult.STILL_PROCESSING_PRIOR_USE; + case SOLVED: + case FAILED_EXCEPTION: + case FAILED_TIMEOUT_NO_REPEATING: + case FAILED_TIMEOUT_NO_PARTICLES: + case FAILED_INTERSECTION_CALCULATION: + case FAILED_INVALID_SOLUTION: + resetForNewTarget(); + // falls through, NOT_STARTED is the state when resetForNewTarget returns + case NOT_STARTED: + if (NUCLEUS_BB.isVecInside(new Vec3Comparable(playerPos.getX(), playerPos.getY(), playerPos.getZ()))) { + return HandleCompassResult.PLAYER_IN_NUCLEUS; + } + + firstCompass = new Compass(playerPos, currentTimeMillis.getAsLong()); + seenParticles.clear(); + solverState = SolverState.PROCESSING_FIRST_USE; + possibleTargets = calculatePossibleTargets(playerPos); + return HandleCompassResult.SUCCESS; + case NEED_SECOND_COMPASS: + if (firstCompass.whereUsed.distanceSq(playerPos) < MINIMUM_DISTANCE_SQ_BETWEEN_COMPASSES) { + return HandleCompassResult.LOCATION_TOO_CLOSE; + } + + HollowsZone firstCompassZone = getZoneForCoords(firstCompass.whereUsed); + HollowsZone playerZone = getZoneForCoords(playerPos); + if (!possibleTargets.equals(calculatePossibleTargets(playerPos)) || + firstCompassZone != playerZone) { resetForNewTarget(); - // falls through, NOT_STARTED is the state when resetForNewTarget returns - case NOT_STARTED: - if (NUCLEUS_BB.isVecInside(new Vec3Comparable(playerPos.getX(), playerPos.getY(), playerPos.getZ()))) { - return HandleCompassResult.PLAYER_IN_NUCLEUS; - } - - firstCompass = new Compass(playerPos, currentTimeMillis.getAsLong()); - seenParticles.clear(); - solverState = SolverState.PROCESSING_FIRST_USE; - possibleTargets = calculatePossibleTargets(playerPos); - return HandleCompassResult.SUCCESS; - case NEED_SECOND_COMPASS: - if (firstCompass.whereUsed.distanceSq(playerPos) < MINIMUM_DISTANCE_SQ_BETWEEN_COMPASSES) { - return HandleCompassResult.LOCATION_TOO_CLOSE; - } - - HollowsZone firstCompassZone = getZoneForCoords(firstCompass.whereUsed); - HollowsZone playerZone = getZoneForCoords(playerPos); - if (!possibleTargets.equals(calculatePossibleTargets(playerPos)) || - firstCompassZone != playerZone) { - resetForNewTarget(); - return HandleCompassResult.POSSIBLE_TARGETS_CHANGED; - } - - secondCompass = new Compass(playerPos, currentTimeMillis.getAsLong()); - solverState = SolverState.PROCESSING_SECOND_USE; - return HandleCompassResult.SUCCESS; - } + return HandleCompassResult.POSSIBLE_TARGETS_CHANGED; + } + + secondCompass = new Compass(playerPos, currentTimeMillis.getAsLong()); + solverState = SolverState.PROCESSING_SECOND_USE; + return HandleCompassResult.SUCCESS; + } - throw new IllegalStateException("Unexpected compass state" ); + throw new IllegalStateException("Unexpected compass state"); } /* @@ -338,7 +360,7 @@ public class CrystalWishingCompassSolver { // Capture particle troubleshooting info for two minutes starting when the first compass is used. // This list is reset each time the first compass is used from a NOT_STARTED state. if (firstCompass != null && !solverState.equals(SolverState.SOLVED) && - System.currentTimeMillis() < firstCompass.whenUsedMillis + 2*60*1000) { + System.currentTimeMillis() < firstCompass.whenUsedMillis + 2 * 60 * 1000) { seenParticles.add(new ParticleData(new Vec3Comparable(x, y, z), System.currentTimeMillis())); } @@ -376,9 +398,9 @@ public class CrystalWishingCompassSolver { logDiagnosticData(false); break; case NEED_SECOND_COMPASS: - mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + - "[NEU] Need another position to determine wishing compass target.")); - break; + mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + + "[NEU] Need another position to determine wishing compass target.")); + break; } } } catch (Exception e) { @@ -389,7 +411,6 @@ public class CrystalWishingCompassSolver { } /** - * * @param x Particle x coordinate * @param y Particle y coordinate * @param z Particle z coordinate @@ -454,7 +475,8 @@ public class CrystalWishingCompassSolver { getZoneForCoords(firstCompass.whereUsed), foundCrystals.getAsCrystalEnumSet(), possibleTargets, - solution); + solution + ); // Adjust the Jungle Temple solution coordinates if (solutionPossibleTargets.size() == 1 && @@ -466,9 +488,8 @@ public class CrystalWishingCompassSolver { solverState = SolverState.SOLVED; } - private boolean isKeyInInventory() - { - for (ItemStack item : mc.thePlayer.inventory.mainInventory){ + private boolean isKeyInInventory() { + for (ItemStack item : mc.thePlayer.inventory.mainInventory) { if (item != null && item.getDisplayName().contains("Jungle Key")) { return true; } @@ -476,12 +497,11 @@ public class CrystalWishingCompassSolver { return false; } - private boolean isKingsScentPresent() - { + private boolean isKingsScentPresent() { return SBInfo.getInstance().footer.getUnformattedText().contains("King's Scent I"); } - private EnumSet<Crystal> getFoundCrystals() { + private EnumSet<Crystal> getFoundCrystals() { EnumSet<Crystal> foundCrystals = EnumSet.noneOf(Crystal.class); NEUConfig.HiddenProfileSpecific perProfileConfig = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); if (perProfileConfig == null) return foundCrystals; @@ -523,10 +543,11 @@ public class CrystalWishingCompassSolver { // | Holdout | Deposits | // |----------|------------| static public EnumSet<CompassTarget> getSolutionTargets( - HollowsZone compassUsedZone, - EnumSet<Crystal> foundCrystals, - EnumSet<CompassTarget> possibleTargets, - Vec3Comparable solution) { + HollowsZone compassUsedZone, + EnumSet<Crystal> foundCrystals, + EnumSet<CompassTarget> possibleTargets, + Vec3Comparable solution + ) { EnumSet<CompassTarget> solutionPossibleTargets; solutionPossibleTargets = possibleTargets.clone(); @@ -541,28 +562,28 @@ public class CrystalWishingCompassSolver { // Y=41/74 is the absolute min/max based on structure size if // the center of the topaz crystal has to be in magma fields. if (solutionPossibleTargets.contains(CompassTarget.BAL) && - solution.yCoord > 75) { + solution.yCoord > 75) { solutionPossibleTargets.remove(CompassTarget.BAL); } // Y coordinates are 93-157 from 15 samples. // Y=83/167 is the absolute min/max based on structure size if (solutionPossibleTargets.contains(CompassTarget.GOBLIN_KING) && - solution.yCoord < 82 || solution.yCoord > 168) { + solution.yCoord < 82 || solution.yCoord > 168) { solutionPossibleTargets.remove(CompassTarget.GOBLIN_KING); } // Y coordinates are 129-139 from 10 samples // Y=126/139 is the absolute min/max based on structure size if (solutionPossibleTargets.contains(CompassTarget.GOBLIN_QUEEN) && - (solution.yCoord < 125 || solution.yCoord > 140)) { + (solution.yCoord < 125 || solution.yCoord > 140)) { solutionPossibleTargets.remove(CompassTarget.GOBLIN_QUEEN); } // Y coordinates are 72-80 from 10 samples // Y=73/80 is the absolute min/max based on structure size if (solutionPossibleTargets.contains(CompassTarget.JUNGLE_TEMPLE) && - (solution.yCoord < 72 || solution.yCoord > 81)) { + (solution.yCoord < 72 || solution.yCoord > 81)) { solutionPossibleTargets.remove(CompassTarget.JUNGLE_TEMPLE); } @@ -576,7 +597,7 @@ public class CrystalWishingCompassSolver { // Y coordinates are 122-129 from 8 samples // Y=122/129 is the absolute min/max based on structure size if (solutionPossibleTargets.contains(CompassTarget.PRECURSOR_CITY) && - (solution.yCoord < 121 || solution.yCoord > 130)) { + (solution.yCoord < 121 || solution.yCoord > 130)) { solutionPossibleTargets.remove(CompassTarget.PRECURSOR_CITY); } @@ -584,26 +605,26 @@ public class CrystalWishingCompassSolver { // Y=98/100 is the absolute min/max based on structure size, // but 102 has been seen - possibly with earlier code that rounded up if (solutionPossibleTargets.contains(CompassTarget.MINES_OF_DIVAN) && - (solution.yCoord < 97 || solution.yCoord > 102)) { + (solution.yCoord < 97 || solution.yCoord > 102)) { solutionPossibleTargets.remove(CompassTarget.MINES_OF_DIVAN); } // Now filter by structure offset if (solutionPossibleTargets.contains(CompassTarget.GOBLIN_KING) && (solution.xCoord > GOBLIN_HOLDOUT_BB.maxX + GOBLIN_KING_BB.maxX || - solution.zCoord < GOBLIN_HOLDOUT_BB.minZ - GOBLIN_KING_BB.maxZ)) { + solution.zCoord < GOBLIN_HOLDOUT_BB.minZ - GOBLIN_KING_BB.maxZ)) { solutionPossibleTargets.remove(CompassTarget.GOBLIN_KING); } if (solutionPossibleTargets.contains(CompassTarget.GOBLIN_QUEEN) && (solution.xCoord > GOBLIN_HOLDOUT_BB.maxX + GOBLIN_QUEEN_BB.maxX || - solution.zCoord < GOBLIN_HOLDOUT_BB.minZ - GOBLIN_QUEEN_BB.maxZ)) { + solution.zCoord < GOBLIN_HOLDOUT_BB.minZ - GOBLIN_QUEEN_BB.maxZ)) { solutionPossibleTargets.remove(CompassTarget.GOBLIN_QUEEN); } if (solutionPossibleTargets.contains(CompassTarget.JUNGLE_TEMPLE) && (solution.xCoord > JUNGLE_BB.maxX + JUNGLE_TEMPLE_BB.maxX || - solution.zCoord > JUNGLE_BB.maxZ + JUNGLE_TEMPLE_BB.maxZ)) { + solution.zCoord > JUNGLE_BB.maxZ + JUNGLE_TEMPLE_BB.maxZ)) { solutionPossibleTargets.remove(CompassTarget.JUNGLE_TEMPLE); } @@ -677,38 +698,54 @@ public class CrystalWishingCompassSolver { private String getFriendlyNameForCompassTarget(CompassTarget compassTarget) { switch (compassTarget) { - case BAL: return EnumChatFormatting.RED + "Bal"; - case ODAWA: return EnumChatFormatting.GREEN + "Odawa"; - case JUNGLE_TEMPLE: return EnumChatFormatting.AQUA + "the " + - EnumChatFormatting.GREEN + "Jungle Temple"; - case GOBLIN_KING: return EnumChatFormatting.GOLD + "King Yolkar"; - case GOBLIN_QUEEN: return EnumChatFormatting.AQUA + "the " + - EnumChatFormatting.YELLOW + "Goblin Queen"; - case PRECURSOR_CITY: return EnumChatFormatting.AQUA + "the " + - EnumChatFormatting.WHITE + "Precursor City"; - case MINES_OF_DIVAN: return EnumChatFormatting.AQUA + "the " + - EnumChatFormatting.BLUE + "Mines of Divan"; - default: return EnumChatFormatting.WHITE + "an undetermined location"; + case BAL: + return EnumChatFormatting.RED + "Bal"; + case ODAWA: + return EnumChatFormatting.GREEN + "Odawa"; + case JUNGLE_TEMPLE: + return EnumChatFormatting.AQUA + "the " + + EnumChatFormatting.GREEN + "Jungle Temple"; + case GOBLIN_KING: + return EnumChatFormatting.GOLD + "King Yolkar"; + case GOBLIN_QUEEN: + return EnumChatFormatting.AQUA + "the " + + EnumChatFormatting.YELLOW + "Goblin Queen"; + case PRECURSOR_CITY: + return EnumChatFormatting.AQUA + "the " + + EnumChatFormatting.WHITE + "Precursor City"; + case MINES_OF_DIVAN: + return EnumChatFormatting.AQUA + "the " + + EnumChatFormatting.BLUE + "Mines of Divan"; + default: + return EnumChatFormatting.WHITE + "an undetermined location"; } } private String getNameForCompassTarget(CompassTarget compassTarget) { boolean useSkytilsNames = (NotEnoughUpdates.INSTANCE.config.mining.wishingCompassWaypointNames == 1); switch (compassTarget) { - case BAL: return useSkytilsNames ? "internal_bal" : "Bal"; - case ODAWA: return "Odawa"; - case JUNGLE_TEMPLE: return useSkytilsNames ? "internal_temple" : "Temple"; - case GOBLIN_KING: return useSkytilsNames ? "internal_king" : "King"; - case GOBLIN_QUEEN: return useSkytilsNames ? "internal_den" : "Queen"; - case PRECURSOR_CITY: return useSkytilsNames ? "internal_city" : "City"; - case MINES_OF_DIVAN: return useSkytilsNames ? "internal_mines" : "Mines"; - default: return "WishingTarget"; + case BAL: + return useSkytilsNames ? "internal_bal" : "Bal"; + case ODAWA: + return "Odawa"; + case JUNGLE_TEMPLE: + return useSkytilsNames ? "internal_temple" : "Temple"; + case GOBLIN_KING: + return useSkytilsNames ? "internal_king" : "King"; + case GOBLIN_QUEEN: + return useSkytilsNames ? "internal_den" : "Queen"; + case PRECURSOR_CITY: + return useSkytilsNames ? "internal_city" : "City"; + case MINES_OF_DIVAN: + return useSkytilsNames ? "internal_mines" : "Mines"; + default: + return "WishingTarget"; } } private String getSolutionCoordsText() { return solution == null ? "" : - String.format("%.0f %.0f %.0f", solution.xCoord, solution.yCoord, solution.zCoord); + String.format("%.0f %.0f %.0f", solution.xCoord, solution.yCoord, solution.zCoord); } private String getWishingCompassDestinationsMessage() { @@ -759,21 +796,23 @@ public class CrystalWishingCompassSolver { "WishingTarget"; String skytilsCommand = String.format("/sthw add %s %s", getSolutionCoordsText(), targetNameForSkytils); if (NotEnoughUpdates.INSTANCE.config.mining.wishingCompassAutocreateKnownWaypoints && - solutionPossibleTargets.size() == 1) { + solutionPossibleTargets.size() == 1) { mc.thePlayer.addChatMessage(new ChatComponentText(destinationMessage)); int commandResult = ClientCommandHandler.instance.executeCommand(mc.thePlayer, skytilsCommand); - if (commandResult == 1) - { + if (commandResult == 1) { return; } - mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Failed to automatically run /sthw")); + mc.thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "[NEU] Failed to automatically run /sthw")); } destinationMessage += EnumChatFormatting.YELLOW + " [Add Skytils Waypoint]"; ChatComponentText chatMessage = new ChatComponentText(destinationMessage); - chatMessage.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, - skytilsCommand, - EnumChatFormatting.YELLOW + "Set waypoint for wishing target")); + chatMessage.setChatStyle(Utils.createClickStyle( + ClickEvent.Action.RUN_COMMAND, + skytilsCommand, + EnumChatFormatting.YELLOW + "Set waypoint for wishing target" + )); mc.thePlayer.addChatMessage(chatMessage); } @@ -878,8 +917,7 @@ public class CrystalWishingCompassSolver { return; } - if (!NotEnoughUpdates.INSTANCE.config.mining.wishingCompassSolver) - { + if (!NotEnoughUpdates.INSTANCE.config.mining.wishingCompassSolver) { mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Wishing Compass Solver is not enabled.")); return; @@ -951,8 +989,8 @@ public class CrystalWishingCompassSolver { public void processParticle(double x, double y, double z, long particleTimeMillis) { if (compassState == CompassState.FAILED_TIMEOUT_NO_REPEATING || - compassState == CompassState.FAILED_TIMEOUT_NO_PARTICLES || - compassState == CompassState.COMPLETED) { + compassState == CompassState.FAILED_TIMEOUT_NO_PARTICLES || + compassState == CompassState.COMPLETED) { throw new UnsupportedOperationException("processParticle should not be called in a failed or completed state"); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java index e621cf78..ca9a92cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -11,7 +30,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -24,7 +47,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.*; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.util.Vec3i; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -36,8 +65,14 @@ import org.lwjgl.util.vector.Vector3f; import java.awt.*; import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; import java.util.List; -import java.util.*; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java index 1157e73a..95ec0f7a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.common.collect.Maps; @@ -14,8 +33,17 @@ import net.minecraft.client.model.ModelSkeletonHead; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.block.model.*; -import net.minecraft.client.renderer.texture.*; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BlockPart; +import net.minecraft.client.renderer.block.model.BlockPartFace; +import net.minecraft.client.renderer.block.model.FaceBakery; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ModelBlock; +import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.IIconCreator; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; @@ -31,7 +59,11 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public class CustomSkulls implements IResourceManagerReloadListener { private static final CustomSkulls INSTANCE = new CustomSkulls(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java index 9c93b9c5..127edcde 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java index f7f9003c..c1c7dca1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java index 83a68915..aaaa1e24 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -19,7 +38,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Keyboard; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; public class EnchantingSolvers { private static SolverType currentSolver = SolverType.NONE; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java index 39ac1b22..a3717f32 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.common.reflect.TypeToken; @@ -131,13 +150,14 @@ public class FairySouls { int g2 = (color2 >> 8) & 0xff; int b2 = color2 & 0xff; - int r3 = r1 + (int)Math.round(factor * (r2-r1)); - int g3 = g1 + (int)Math.round(factor * (g2-g1)); - int b3 = b1 + (int)Math.round(factor * (b2-b1)); + int r3 = r1 + (int) Math.round(factor * (r2 - r1)); + int g3 = g1 + (int) Math.round(factor * (g2 - g1)); + int b3 = b1 + (int) Math.round(factor * (b2 - b1)); return (r3 & 0xff) << 16 | (g3 & 0xff) << 8 | - (b3 & 0xff); } + (b3 & 0xff); + } private double normalize(double value, double min, double max) { return ((value - min) / (max - min)); @@ -151,7 +171,7 @@ public class FairySouls { int closeColor = 0x772991; // 0xa839ce int farColor = 0xCEB4D1; - double farSoulDistSq = lastPlayerPos.distanceSq(closestMissingSouls.get(closestMissingSouls.size()-1)); + double farSoulDistSq = lastPlayerPos.distanceSq(closestMissingSouls.get(closestMissingSouls.size() - 1)); for (BlockPos currentSoul : closestMissingSouls) { double currentDistSq = lastPlayerPos.distanceSq(currentSoul); double factor = normalize(currentDistSq, 0.0, farSoulDistSq); @@ -405,7 +425,8 @@ public class FairySouls { case "on": case "enable": if (!FairySouls.instance.trackSouls) { - print(EnumChatFormatting.RED + "Fairy soul tracking is off, enable it using /neu before using this command"); + print( + EnumChatFormatting.RED + "Fairy soul tracking is off, enable it using /neu before using this command"); return; } print(EnumChatFormatting.DARK_PURPLE + "Enabled fairy soul waypoints"); 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 65092752..26e25a11 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java index 96522d34..f2b13abc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java index 655364ef..e1b9d567 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.gson.Gson; @@ -18,7 +37,13 @@ import org.lwjgl.opengl.GL14; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.function.Consumer; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java index 88c7261c..79dd18f1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -5,7 +24,11 @@ import io.github.moulberry.notenoughupdates.util.NEUResourceManager; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java index b56737e7..12e0301b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java index 05d75c26..ad0dd66d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.gson.Gson; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java index 3419b8c4..9cc872b7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.gson.JsonElement; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java index 927111b3..6302343e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.util.ReverseWorldRenderer; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 056cf0a4..4cf076d8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.common.collect.Lists; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java index 9292c0d3..3955c363 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java @@ -1,3 +1,22 @@ +/* + * 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; import com.google.gson.Gson; @@ -30,7 +49,13 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector2f; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.function.Consumer; @@ -546,8 +571,8 @@ public class SlotLocking { ); } } else if (pairingSlot != null && lockKeyHeld && slot.getSlotIndex() < 8) { - int x1 = ((AccessorGuiContainer)container).getGuiLeft() + pairingSlot.xDisplayPosition; - int y1 = ((AccessorGuiContainer)container).getGuiTop() + pairingSlot.yDisplayPosition; + int x1 = ((AccessorGuiContainer) container).getGuiLeft() + pairingSlot.xDisplayPosition; + int y1 = ((AccessorGuiContainer) container).getGuiTop() + pairingSlot.yDisplayPosition; if (mouseX <= x1 || mouseX >= x1 + 16 || mouseY <= y1 || mouseY >= y1 + 16) { @@ -635,8 +660,8 @@ public class SlotLocking { int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - int x1 = ((AccessorGuiContainer)container).getGuiLeft() + pairingSlot.xDisplayPosition; - int y1 = ((AccessorGuiContainer)container).getGuiTop() + pairingSlot.yDisplayPosition; + int x1 = ((AccessorGuiContainer) container).getGuiLeft() + pairingSlot.xDisplayPosition; + int y1 = ((AccessorGuiContainer) container).getGuiTop() + pairingSlot.yDisplayPosition; if (mouseX <= x1 || mouseX >= x1 + 16 || mouseY <= y1 || mouseY >= y1 + 16) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java index 94aee789..680637f2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java @@ -1,6 +1,35 @@ +/* + * 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; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -13,14 +42,32 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.*; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagByteArray; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagDouble; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; +import net.minecraft.nbt.NBTTagIntArray; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagLong; +import net.minecraft.nbt.NBTTagShort; +import net.minecraft.nbt.NBTTagString; import net.minecraft.network.play.client.C0EPacketClickWindow; import net.minecraft.network.play.server.S2DPacketOpenWindow; import net.minecraft.network.play.server.S2EPacketCloseWindow; import net.minecraft.network.play.server.S2FPacketSetSlot; import net.minecraft.network.play.server.S30PacketWindowItems; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.HashMap; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java index 064f41ca..a2951e56 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.util.Utils; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java index 27cf42ac..9c2549b8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java @@ -1,3 +1,22 @@ +/* + * 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; import io.github.moulberry.notenoughupdates.util.Utils; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java index 36858276..7d23d922 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java @@ -1,3 +1,22 @@ +/* + * 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.customblockzones; import net.minecraft.util.BlockPos; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java index 9a6f9cac..48a01187 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java @@ -1,3 +1,22 @@ +/* + * 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.customblockzones; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java index dec011d3..2a3e9ec4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java @@ -1,8 +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.miscfeatures.customblockzones; import com.google.gson.Gson; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.PositionedSoundRecord; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java index faf7eabe..1c6acc1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java @@ -1,3 +1,22 @@ +/* + * 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.customblockzones; import com.google.gson.JsonArray; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java index 8b00bc85..75ff566f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java @@ -1,3 +1,22 @@ +/* + * 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.customblockzones; import net.minecraft.util.BlockPos; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java index c6f5e9c0..5a87af11 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java @@ -1,3 +1,22 @@ +/* + * 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.customblockzones; import net.minecraftforge.fml.common.eventhandler.Event; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java index f4e8f1fc..e88e2c25 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java @@ -1,3 +1,22 @@ +/* + * 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.customblockzones; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java index 5884512f..963fa793 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; @@ -9,22 +28,22 @@ import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.monster.EntityZombie; public class AgeModifier extends EntityViewerModifier { - @Override - public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { - boolean baby = info.has("baby") && info.get("baby").getAsBoolean(); - if (base instanceof EntityAgeable) { - ((AccessorEntityAgeable) base).setGrowingAgeDirect(baby ? -1 : 1); - return base; - } - if (base instanceof EntityZombie) { - ((EntityZombie) base).setChild(baby); - return base; - } - if (base instanceof EntityArmorStand) { - ((AccessorEntityArmorStand) base).setSmallDirect(baby); - return base; - } - System.out.println("Cannot apply age to a non ageable entity: " + base); - return null; - } + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + boolean baby = info.has("baby") && info.get("baby").getAsBoolean(); + if (base instanceof EntityAgeable) { + ((AccessorEntityAgeable) base).setGrowingAgeDirect(baby ? -1 : 1); + return base; + } + if (base instanceof EntityZombie) { + ((EntityZombie) base).setChild(baby); + return base; + } + if (base instanceof EntityArmorStand) { + ((AccessorEntityArmorStand) base).setSmallDirect(baby); + return base; + } + System.out.println("Cannot apply age to a non ageable entity: " + base); + return null; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java index 17dce66d..5f452132 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; @@ -6,12 +25,12 @@ import net.minecraft.entity.monster.EntityCreeper; public class ChargedModifier extends EntityViewerModifier { - @Override - public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { - if (base instanceof EntityCreeper) { - base.getDataWatcher().updateObject(17, (byte) 1); - return base; - } - return null; - } + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (base instanceof EntityCreeper) { + base.getDataWatcher().updateObject(17, (byte) 1); + return base; + } + return null; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java index 78d035ac..367d62d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.Gson; @@ -14,166 +33,213 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.monster.*; -import net.minecraft.entity.passive.*; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.monster.EntityCaveSpider; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntityEndermite; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.EntityGuardian; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.passive.EntityRabbit; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.passive.EntityWolf; import net.minecraft.util.ResourceLocation; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.StreamSupport; public class EntityViewer extends GuiScreen { - public static Map<String, Supplier<? extends EntityLivingBase>> validEntities = new HashMap<String, Supplier<? extends EntityLivingBase>>() {{ - put("Zombie", () -> new EntityZombie(null)); - put("Chicken", () -> new EntityChicken(null)); - put("Slime", () -> new EntitySlime(null)); - put("Wolf", () -> new EntityWolf(null)); - put("Skeleton", () -> new EntitySkeleton(null)); - put("Creeper", () -> new EntityCreeper(null)); - put("Ocelot", () -> new EntityOcelot(null)); - put("Blaze", () -> new EntityBlaze(null)); - put("Rabbit", () -> new EntityRabbit(null)); - put("Sheep", () -> new EntitySheep(null)); - put("Horse", () -> new EntityHorse(null)); - put("Eisengolem", () -> new EntityIronGolem(null)); - put("Silverfish", () -> new EntitySilverfish(null)); - put("Witch", () -> new EntityWitch(null)); - put("Endermite", () -> new EntityEndermite(null)); - put("Snowman", () -> new EntitySnowman(null)); - put("Villager", () -> new EntityVillager(null)); - put("Guardian", () -> new EntityGuardian(null)); - put("ArmorStand", () -> new EntityArmorStand(null)); - put("Squid", () -> new EntitySquid(null)); - put("Bat", () -> new EntityBat(null)); - put("Spider", () -> new EntitySpider(null)); - put("CaveSpider", () -> new EntityCaveSpider(null)); - put("Pigman", () -> new EntityPigZombie(null)); - put("Ghast", () -> new EntityGhast(null)); - put("MagmaCube", () -> new EntityMagmaCube(null)); - put("Wither", () -> new EntityWither(null)); - put("Enderman", () -> new EntityEnderman(null)); - put("Mooshroom", ()-> new EntityMooshroom(null)); - put("WitherSkeleton", () -> { - EntitySkeleton skeleton = new EntitySkeleton(null); - skeleton.setSkeletonType(1); - return skeleton; - }); - put("Cow", () -> new EntityCow(null)); - put("Dragon", ()-> new EntityDragon(null)); - put("Player", () -> new GUIClientPlayer()); - put("Pig", () -> new EntityPig(null)); - }}; - - public static Map<String, EntityViewerModifier> validModifiers = new HashMap<String, EntityViewerModifier>() {{ - put("playerdata", new SkinModifier()); - put("equipment", new EquipmentModifier()); - put("riding", new RidingModifier()); - put("charged", new ChargedModifier()); - put("witherdata", new WitherModifier()); - put("invisible", new InvisibleModifier()); - put("age", new AgeModifier()); - put("horse", new HorseModifier()); - put("name", new NameModifier()); - }}; - - public int guiLeft = 0; - public int guiTop = 0; - public int xSize = 176; - public int ySize = 166; - - private final String label; - private final EntityLivingBase entity; - private static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates", "textures/gui/entity_viewer.png"); - - public EntityViewer(String label, EntityLivingBase entity) { - this.label = label; - this.entity = entity; - } - - public static EntityLivingBase constructEntity(ResourceLocation resourceLocation) { - Gson gson = NotEnoughUpdates.INSTANCE.manager.gson; - try (Reader is = new InputStreamReader( - Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation).getInputStream(), StandardCharsets.UTF_8)) { - return constructEntity(gson.fromJson(is, JsonObject.class)); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - public static EntityLivingBase constructEntity(JsonObject info) { - List<JsonObject> modifiers = info.has("modifiers") ? - StreamSupport.stream(info.get("modifiers").getAsJsonArray().spliterator(), false) - .map(JsonElement::getAsJsonObject).collect(Collectors.toList()) - : Collections.emptyList(); - return EntityViewer.constructEntity(info.get("entity").getAsString(), modifiers); - } - - public static EntityLivingBase constructEntity(String string, String[] modifiers) { - Gson gson = NotEnoughUpdates.INSTANCE.manager.gson; - return constructEntity(string, Arrays.stream(modifiers).map(it -> gson.fromJson(it, JsonObject.class)).collect(Collectors.toList())); - } - - public static EntityLivingBase constructEntity(String string, List<JsonObject> modifiers) { - Supplier<? extends EntityLivingBase> aClass = validEntities.get(string); - if (aClass == null) { - System.err.println("Could not find entity of type: " + string); - return null; - } - try { - EntityLivingBase entity = aClass.get(); - for (JsonObject modifier : modifiers) { - String type = modifier.get("type").getAsString(); - EntityViewerModifier entityViewerModifier = validModifiers.get(type); - entity = entityViewerModifier.applyModifier(entity, modifier); - if (entity == null) break; - } - return entity; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - drawDefaultBackground(); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - - this.guiLeft = (width - this.xSize) / 2; - this.guiTop = (height - this.ySize) / 2; - - - Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize); - - - Utils.drawStringScaledMaxWidth(label, fontRenderer, guiLeft + 10, guiTop + 10, false, 100, 0xFF00FF); - renderEntity(entity, guiLeft + 90, guiTop + 75, mouseX, mouseY); - } - - public static void renderEntity(EntityLivingBase entity, int posX, int posY, int mouseX, int mouseY) { - GlStateManager.color(1F, 1F, 1F, 1F); - - int scale = 30; - float bottomOffset = 0F; - EntityLivingBase stack = entity; - while (true) { - - stack.ticksExisted = Minecraft.getMinecraft().thePlayer.ticksExisted; - GuiInventory.drawEntityOnScreen(posX, (int) (posY - bottomOffset * scale), scale, posX - mouseX, (int) (posY - stack.getEyeHeight() * scale - mouseY), stack); - bottomOffset += stack.getMountedYOffset(); - if (!(stack.riddenByEntity instanceof EntityLivingBase)) { - break; - } - stack = (EntityLivingBase) stack.riddenByEntity; - } - - } + public static Map<String, Supplier<? extends EntityLivingBase>> validEntities = + new HashMap<String, Supplier<? extends EntityLivingBase>>() {{ + put("Zombie", () -> new EntityZombie(null)); + put("Chicken", () -> new EntityChicken(null)); + put("Slime", () -> new EntitySlime(null)); + put("Wolf", () -> new EntityWolf(null)); + put("Skeleton", () -> new EntitySkeleton(null)); + put("Creeper", () -> new EntityCreeper(null)); + put("Ocelot", () -> new EntityOcelot(null)); + put("Blaze", () -> new EntityBlaze(null)); + put("Rabbit", () -> new EntityRabbit(null)); + put("Sheep", () -> new EntitySheep(null)); + put("Horse", () -> new EntityHorse(null)); + put("Eisengolem", () -> new EntityIronGolem(null)); + put("Silverfish", () -> new EntitySilverfish(null)); + put("Witch", () -> new EntityWitch(null)); + put("Endermite", () -> new EntityEndermite(null)); + put("Snowman", () -> new EntitySnowman(null)); + put("Villager", () -> new EntityVillager(null)); + put("Guardian", () -> new EntityGuardian(null)); + put("ArmorStand", () -> new EntityArmorStand(null)); + put("Squid", () -> new EntitySquid(null)); + put("Bat", () -> new EntityBat(null)); + put("Spider", () -> new EntitySpider(null)); + put("CaveSpider", () -> new EntityCaveSpider(null)); + put("Pigman", () -> new EntityPigZombie(null)); + put("Ghast", () -> new EntityGhast(null)); + put("MagmaCube", () -> new EntityMagmaCube(null)); + put("Wither", () -> new EntityWither(null)); + put("Enderman", () -> new EntityEnderman(null)); + put("Mooshroom", () -> new EntityMooshroom(null)); + put("WitherSkeleton", () -> { + EntitySkeleton skeleton = new EntitySkeleton(null); + skeleton.setSkeletonType(1); + return skeleton; + }); + put("Cow", () -> new EntityCow(null)); + put("Dragon", () -> new EntityDragon(null)); + put("Player", () -> new GUIClientPlayer()); + put("Pig", () -> new EntityPig(null)); + }}; + + public static Map<String, EntityViewerModifier> validModifiers = new HashMap<String, EntityViewerModifier>() {{ + put("playerdata", new SkinModifier()); + put("equipment", new EquipmentModifier()); + put("riding", new RidingModifier()); + put("charged", new ChargedModifier()); + put("witherdata", new WitherModifier()); + put("invisible", new InvisibleModifier()); + put("age", new AgeModifier()); + put("horse", new HorseModifier()); + put("name", new NameModifier()); + }}; + + public int guiLeft = 0; + public int guiTop = 0; + public int xSize = 176; + public int ySize = 166; + + private final String label; + private final EntityLivingBase entity; + private static final ResourceLocation BACKGROUND = new ResourceLocation( + "notenoughupdates", + "textures/gui/entity_viewer.png" + ); + + public EntityViewer(String label, EntityLivingBase entity) { + this.label = label; + this.entity = entity; + } + + public static EntityLivingBase constructEntity(ResourceLocation resourceLocation) { + Gson gson = NotEnoughUpdates.INSTANCE.manager.gson; + try ( + Reader is = new InputStreamReader( + Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation).getInputStream(), + StandardCharsets.UTF_8 + ) + ) { + return constructEntity(gson.fromJson(is, JsonObject.class)); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + public static EntityLivingBase constructEntity(JsonObject info) { + List<JsonObject> modifiers = info.has("modifiers") ? + StreamSupport.stream(info.get("modifiers").getAsJsonArray().spliterator(), false) + .map(JsonElement::getAsJsonObject).collect(Collectors.toList()) + : Collections.emptyList(); + return EntityViewer.constructEntity(info.get("entity").getAsString(), modifiers); + } + + public static EntityLivingBase constructEntity(String string, String[] modifiers) { + Gson gson = NotEnoughUpdates.INSTANCE.manager.gson; + return constructEntity( + string, + Arrays.stream(modifiers).map(it -> gson.fromJson(it, JsonObject.class)).collect(Collectors.toList()) + ); + } + + public static EntityLivingBase constructEntity(String string, List<JsonObject> modifiers) { + Supplier<? extends EntityLivingBase> aClass = validEntities.get(string); + if (aClass == null) { + System.err.println("Could not find entity of type: " + string); + return null; + } + try { + EntityLivingBase entity = aClass.get(); + for (JsonObject modifier : modifiers) { + String type = modifier.get("type").getAsString(); + EntityViewerModifier entityViewerModifier = validModifiers.get(type); + entity = entityViewerModifier.applyModifier(entity, modifier); + if (entity == null) break; + } + return entity; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + this.guiLeft = (width - this.xSize) / 2; + this.guiTop = (height - this.ySize) / 2; + + Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize); + + Utils.drawStringScaledMaxWidth(label, fontRenderer, guiLeft + 10, guiTop + 10, false, 100, 0xFF00FF); + renderEntity(entity, guiLeft + 90, guiTop + 75, mouseX, mouseY); + } + + public static void renderEntity(EntityLivingBase entity, int posX, int posY, int mouseX, int mouseY) { + GlStateManager.color(1F, 1F, 1F, 1F); + + int scale = 30; + float bottomOffset = 0F; + EntityLivingBase stack = entity; + while (true) { + + stack.ticksExisted = Minecraft.getMinecraft().thePlayer.ticksExisted; + GuiInventory.drawEntityOnScreen( + posX, + (int) (posY - bottomOffset * scale), + scale, + posX - mouseX, + (int) (posY - stack.getEyeHeight() * scale - mouseY), + stack + ); + bottomOffset += stack.getMountedYOffset(); + if (!(stack.riddenByEntity instanceof EntityLivingBase)) { + break; + } + stack = (EntityLivingBase) stack.riddenByEntity; + } + + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java index bab6c354..aa6d22c9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java @@ -1,8 +1,27 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; import net.minecraft.entity.EntityLivingBase; public abstract class EntityViewerModifier { - public abstract EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info); + public abstract EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java index 3011e479..685e161a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java index db20a684..8cdf2ef0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.mojang.authlib.GameProfile; @@ -9,29 +28,29 @@ import net.minecraft.util.ResourceLocation; import java.util.UUID; public class GUIClientPlayer extends AbstractClientPlayer { - public GUIClientPlayer() { - super(null, new GameProfile(UUID.randomUUID(), "GuiPlayer")); - } - - ResourceLocation overrideSkin = DefaultPlayerSkin.getDefaultSkinLegacy(); - ResourceLocation overrideCape = null; - boolean overrideIsSlim = false; - NetworkPlayerInfo playerInfo = new NetworkPlayerInfo(this.getGameProfile()) { - @Override - public String getSkinType() { - return overrideIsSlim ? "slim" : "default"; - } - - @Override - public ResourceLocation getLocationSkin() { - return overrideSkin; - } - - @Override - public ResourceLocation getLocationCape() { - return overrideCape; - } - }; + public GUIClientPlayer() { + super(null, new GameProfile(UUID.randomUUID(), "GuiPlayer")); + } + + ResourceLocation overrideSkin = DefaultPlayerSkin.getDefaultSkinLegacy(); + ResourceLocation overrideCape = null; + boolean overrideIsSlim = false; + NetworkPlayerInfo playerInfo = new NetworkPlayerInfo(this.getGameProfile()) { + @Override + public String getSkinType() { + return overrideIsSlim ? "slim" : "default"; + } + + @Override + public ResourceLocation getLocationSkin() { + return overrideSkin; + } + + @Override + public ResourceLocation getLocationCape() { + return overrideCape; + } + }; @Override public String getName() { @@ -45,7 +64,7 @@ public class GUIClientPlayer extends AbstractClientPlayer { } @Override - protected NetworkPlayerInfo getPlayerInfo() { - return playerInfo; - } + protected NetworkPlayerInfo getPlayerInfo() { + return playerInfo; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java index 7fd2dadd..b29152bf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonElement; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java index c2138b3f..74535ce9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java @@ -1,12 +1,31 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; import net.minecraft.entity.EntityLivingBase; public class InvisibleModifier extends EntityViewerModifier { - @Override - public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { - base.setInvisible(!info.has("invisible") || info.get("invisible").getAsBoolean()); - return base; - } + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + base.setInvisible(!info.has("invisible") || info.get("invisible").getAsBoolean()); + return base; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/NameModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/NameModifier.java index 9978882d..c0fd23bd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/NameModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/NameModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java index 9879542a..72dd8b73 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java @@ -1,14 +1,33 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; import net.minecraft.entity.EntityLivingBase; public class RidingModifier extends EntityViewerModifier { - @Override - public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { - EntityLivingBase newEntity = EntityViewer.constructEntity(info); - if (newEntity == null) return null; - newEntity.mountEntity(base); - return base; - } + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + EntityLivingBase newEntity = EntityViewer.constructEntity(info); + if (newEntity == null) return null; + newEntity.mountEntity(base); + return base; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java index 55e8a432..076e8417 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonElement; @@ -9,38 +28,38 @@ import net.minecraft.util.ResourceLocation; import java.util.Map; public class SkinModifier extends EntityViewerModifier { - @Override - public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { - if (base instanceof GUIClientPlayer) { - GUIClientPlayer player = (GUIClientPlayer) base; - if (info.has("cape")) { - player.overrideCape = new ResourceLocation(info.get("cape").getAsString()); - } - if (info.has("skin")) { - player.overrideSkin = new ResourceLocation(info.get("skin").getAsString()); - } - if (info.has("slim")) { - player.overrideIsSlim = info.get("slim").getAsBoolean(); - } - if (info.has("parts")) { - JsonElement parts = info.get("parts"); - byte partBitField = player.getDataWatcher().getWatchableObjectByte(10); - if (parts.isJsonPrimitive() && parts.getAsJsonPrimitive().isBoolean()) { - partBitField = parts.getAsBoolean() ? (byte) -1 : 0; - } else { - JsonObject obj = parts.getAsJsonObject(); - for (Map.Entry<String, JsonElement> part : obj.entrySet()) { - EnumPlayerModelParts modelPart = EnumPlayerModelParts.valueOf(part.getKey()); - if (part.getValue().getAsBoolean()) { - partBitField |= modelPart.getPartMask(); - } else { - partBitField &= ~modelPart.getPartMask(); - } - } - } - player.getDataWatcher().updateObject(10, partBitField); - } - } - return base; - } + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (base instanceof GUIClientPlayer) { + GUIClientPlayer player = (GUIClientPlayer) base; + if (info.has("cape")) { + player.overrideCape = new ResourceLocation(info.get("cape").getAsString()); + } + if (info.has("skin")) { + player.overrideSkin = new ResourceLocation(info.get("skin").getAsString()); + } + if (info.has("slim")) { + player.overrideIsSlim = info.get("slim").getAsBoolean(); + } + if (info.has("parts")) { + JsonElement parts = info.get("parts"); + byte partBitField = player.getDataWatcher().getWatchableObjectByte(10); + if (parts.isJsonPrimitive() && parts.getAsJsonPrimitive().isBoolean()) { + partBitField = parts.getAsBoolean() ? (byte) -1 : 0; + } else { + JsonObject obj = parts.getAsJsonObject(); + for (Map.Entry<String, JsonElement> part : obj.entrySet()) { + EnumPlayerModelParts modelPart = EnumPlayerModelParts.valueOf(part.getKey()); + if (part.getValue().getAsBoolean()) { + partBitField |= modelPart.getPartMask(); + } else { + partBitField &= ~modelPart.getPartMask(); + } + } + } + player.getDataWatcher().updateObject(10, partBitField); + } + } + return base; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java index c5580f17..3b73c26f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java @@ -1,3 +1,22 @@ +/* + * 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.entityviewer; import com.google.gson.JsonObject; @@ -5,25 +24,25 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityWither; public class WitherModifier extends EntityViewerModifier { - @Override - public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { - if (!(base instanceof EntityWither)) - return null; - EntityWither wither = (EntityWither) base; - if (info.has("tiny")) { - if (info.get("tiny").getAsBoolean()) { - wither.setInvulTime(800); - } else { - wither.setInvulTime(0); - } - } - if (info.has("armored")) { - if (info.get("armored").getAsBoolean()) { - wither.setHealth(1); - } else { - wither.setHealth(wither.getMaxHealth()); - } - } - return base; - } + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (!(base instanceof EntityWither)) + return null; + EntityWither wither = (EntityWither) base; + if (info.has("tiny")) { + if (info.get("tiny").getAsBoolean()) { + wither.setInvulTime(800); + } else { + wither.setInvulTime(0); + } + } + if (info.has("armored")) { + if (info.get("armored").getAsBoolean()) { + wither.setHealth(1); + } else { + wither.setHealth(wither.getMaxHealth()); + } + } + return base; + } } |