From d1401dba757660d611535db69cddb45d4f4de22f Mon Sep 17 00:00:00 2001 From: Biscuit Date: Fri, 23 Aug 2019 13:21:43 -0400 Subject: [PATCH] Fixed the magma wave/blaze wave checker. Subtract potato books from anvil uses. Reduce magma boss checking time from 15 to 12 minutes. Fixed many compatibility issues hopefully. Fixed lighting issues in backpack preview. --- build.gradle | 11 +-- .../skyblockaddons/SkyblockAddons.java | 2 +- .../listeners/PlayerListener.java | 70 +++++++++++-------- .../mixins/MixinGuiContainer.java | 4 ++ .../skyblockaddons/utils/CoordsPair.java | 9 ++- .../skyblockaddons/utils/Scheduler.java | 10 +-- .../biscuit/skyblockaddons/utils/Utils.java | 3 +- 7 files changed, 64 insertions(+), 45 deletions(-) diff --git a/build.gradle b/build.gradle index 06e0e7f705..4fdc7f31d5 100644 --- a/build.gradle +++ b/build.gradle @@ -26,9 +26,9 @@ plugins { id "net.minecraftforge.gradle.forge" version "2.0.2" } */ -version = "1.2.0" //remember don't update this until its released +version = "1.2.1" //remember don't update this until its released group= "codes.biscuit.skyblockaddons" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "[1.8.9] SkyblockAddons" +archivesBaseName = "SkyblockAddons" sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -95,13 +95,14 @@ jar { from configurations.provided.asFileTree.files.collect { zipTree(it) } - + manifest.attributes( -// 'FMLAT': 'skyblockaddons_at.cfg', + 'FMLAT': 'skyblockaddons_at.cfg', 'MixinConfigs': 'mixins.skyblockaddons.json', 'TweakOrder': '0', - 'TweakClass': 'codes.biscuit.skyblockaddons.tweaker.SkyblockAddonsTweaker' + 'TweakClass': 'codes.biscuit.skyblockaddons.tweaker.SkyblockAddonsTweaker' //codes.biscuit.skyblockaddons.tweaker.SkyblockAddonsTweaker ) + } configurations { diff --git a/src/main/java/codes/biscuit/skyblockaddons/SkyblockAddons.java b/src/main/java/codes/biscuit/skyblockaddons/SkyblockAddons.java index d8a5eec194..041b33d284 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/SkyblockAddons.java +++ b/src/main/java/codes/biscuit/skyblockaddons/SkyblockAddons.java @@ -25,7 +25,7 @@ public class SkyblockAddons { static final String MOD_ID = "skyblockaddons"; static final String MOD_NAME = "SkyblockAddons"; - public static final String VERSION = "1.2.0"; + public static final String VERSION = "1.2.1"; private static SkyblockAddons instance; // for Mixins cause they don't have a constructor private ConfigValues configValues; diff --git a/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java b/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java index 61d5fd76e5..024bed9b10 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java +++ b/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java @@ -13,15 +13,17 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.Vec3; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.ChunkEvent; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -78,24 +80,21 @@ public void onWorldJoin(EntityJoinWorldEvent e) { } } - @SubscribeEvent() - public void onWorldUnload(WorldEvent.Unload e) { - recentlyLoadedChunks.clear(); - } - /** * Keep track of recently loaded chunks for the magma boss timer. */ @SubscribeEvent() public void onChunkLoad(ChunkEvent.Load e) { - CoordsPair coords = new CoordsPair(e.getChunk().xPosition, e.getChunk().zPosition); - recentlyLoadedChunks.add(coords); - new Timer().schedule(new TimerTask() { - @Override - public void run() { - recentlyLoadedChunks.remove(coords); - } - }, 1000); + if (main.getUtils().isOnSkyblock()) { + CoordsPair coords = new CoordsPair(e.getChunk().xPosition, e.getChunk().zPosition); + recentlyLoadedChunks.add(coords); + new Timer().schedule(new TimerTask() { + @Override + public void run() { + recentlyLoadedChunks.remove(coords); + } + }, 30000); + } } /** * Interprets the action bar to extract mana, health, and defence. Enables/disables mana/health prediction, @@ -213,8 +212,7 @@ public void onInteract(PlayerInteractEvent e) { } if (main.getConfigValues().isEnabled(Feature.AVOID_PLACING_ENCHANTED_ITEMS)) { if ((e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || e.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) && -// ((heldItem.getItem() instanceof ItemBlock && !heldItem.getItem().equals(Item.getItemFromBlock(Blocks.bookshelf))) // Bookshelves should be an exception - (heldItem.getItem().equals(Items.lava_bucket) || heldItem.getItem().equals(Items.water_bucket))) { + (heldItem.getItem().equals(Items.lava_bucket) || heldItem.getItem().equals(Items.string))) { e.setCanceled(true); } } @@ -404,7 +402,7 @@ public void run() { if ((magmaAccuracy == EnumUtils.MagmaTimerAccuracy.EXACTLY || magmaAccuracy == EnumUtils.MagmaTimerAccuracy.ABOUT) && magmaTime == 0) { magmaAccuracy = EnumUtils.MagmaTimerAccuracy.SPAWNED_PREDICTION; - main.getScheduler().schedule(Scheduler.CommandType.RESET_MAGMA_PREDICTION, 400); + main.getScheduler().schedule(Scheduler.CommandType.RESET_MAGMA_PREDICTION, 20); } magmaTime--; magmaTick = 1; @@ -416,22 +414,20 @@ public void run() { private long lastBlazeWavePost = -1; @SubscribeEvent() - public void onTickMagmaBossChecker(EntityJoinWorldEvent e) { + public void onTickMagmaBossChecker(EntityEvent.EnteringChunk e) { // EntityJoinWorldEvent // Between these two coordinates is the whole "arena" area where all the magmas and stuff are. - int[] xPoints = {-244, -379}; - int[] yPoints = {-566, -635}; + AxisAlignedBB spawnArea = new AxisAlignedBB(-244, 0, -566, -379, 255, -635); if (main.getUtils().getLocation() == EnumUtils.Location.BLAZING_FORTRESS) { Entity entity = e.entity; - if (entity.posX < xPoints[0] && entity.posX > xPoints[1] && - entity.posZ < yPoints[0] && entity.posZ > yPoints[1]) { // timers will trigger if 15 magmas/8 blazes spawn in the box within a 4 second time period + if (spawnArea.isVecInside(new Vec3(entity.posX, entity.posY, entity.posZ))) { // timers will trigger if 15 magmas/8 blazes spawn in the box within a 4 second time period long currentTime = System.currentTimeMillis(); if (e.entity instanceof EntityMagmaCube) { - if (!recentlyLoadedChunks.contains(new CoordsPair(entity.chunkCoordX, entity.chunkCoordZ)) && entity.ticksExisted == 0) { + if (!recentlyLoadedChunks.contains(new CoordsPair(e.newChunkX, e.newChunkZ)) && entity.ticksExisted == 0) { recentMagmaCubes++; - main.getScheduler().schedule(Scheduler.CommandType.SUBTRACT_MAGMA_COUNT, 80); - if (recentMagmaCubes > 15) { + main.getScheduler().schedule(Scheduler.CommandType.SUBTRACT_MAGMA_COUNT, 4); + if (recentMagmaCubes >= 17) { setMagmaTime(600, true); magmaAccuracy = EnumUtils.MagmaTimerAccuracy.EXACTLY; if (currentTime- lastMagmaWavePost > 300000) { @@ -441,10 +437,10 @@ public void onTickMagmaBossChecker(EntityJoinWorldEvent e) { } } } else if (e.entity instanceof EntityBlaze) { - if (!recentlyLoadedChunks.contains(new CoordsPair(entity.chunkCoordX, entity.chunkCoordZ)) && entity.ticksExisted == 0) { + if (!recentlyLoadedChunks.contains(new CoordsPair(e.newChunkX, e.newChunkZ)) && entity.ticksExisted == 0) { recentBlazes++; - main.getScheduler().schedule(Scheduler.CommandType.SUBTRACT_BLAZE_COUNT, 80); - if (recentBlazes > 8) { + main.getScheduler().schedule(Scheduler.CommandType.SUBTRACT_BLAZE_COUNT, 4); + if (recentBlazes >= 10) { setMagmaTime(1200, true); magmaAccuracy = EnumUtils.MagmaTimerAccuracy.EXACTLY; if (currentTime- lastBlazeWavePost > 300000) { @@ -477,8 +473,14 @@ public void onItemTooltip(ItemTooltipEvent e) { insertAt--; // 1 line for damage } } - e.toolTip.add(insertAt, - "Anvil Uses: " + EnumChatFormatting.RED+ nbt.getCompoundTag("ExtraAttributes").getInteger("anvil_uses")); + int anvilUses = nbt.getCompoundTag("ExtraAttributes").getInteger("anvil_uses"); + if (nbt.getCompoundTag("ExtraAttributes").hasKey("hot_potato_count")) { + int hotPotatoCount = nbt.getCompoundTag("ExtraAttributes").getInteger("hot_potato_count"); + anvilUses -= hotPotatoCount; + } + if (anvilUses > 0) { + e.toolTip.add(insertAt, "Anvil Uses: " + EnumChatFormatting.RED.toString() + anvilUses); + } } } } @@ -492,7 +494,13 @@ public void onItemTooltip(ItemTooltipEvent e) { main.getUtils().sendMessage(EnumChatFormatting.GREEN + "Copied this item's NBT to clipboard!"); } } catch (UnsupportedFlavorException | IOException ex) { - ex.printStackTrace(); + try { + clipboard.setContents(new StringSelection(nbt), null); + main.getUtils().sendMessage(EnumChatFormatting.GREEN + "Copied this item's NBT to clipboard!"); + } catch (IllegalStateException ex1) { + main.getUtils().sendMessage(EnumChatFormatting.RED + "Error copying item NBT to clipboard!"); + ex.printStackTrace(); + } } } } diff --git a/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinGuiContainer.java b/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinGuiContainer.java index b7754b2dd7..7a6145047f 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinGuiContainer.java +++ b/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinGuiContainer.java @@ -123,12 +123,14 @@ private void drawBackpacks(int mouseX, int mouseY, float partialTicks, CallbackI if (SkyblockAddons.getInstance().getConfigValues().getBackpackStyle() == EnumUtils.BackpackStyle.GUI) { this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); int rows = length/9; + GlStateManager.disableLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(0,0,300); drawTexturedModalRect(x, y, 0, 0, 176, rows * 18 + 17); drawTexturedModalRect(x, y + rows * 18 + 17, 0, 215, 176, 7); fontRendererObj.drawString(backpack.getItemName(), x+8, y+6, 4210752); GlStateManager.popMatrix(); + GlStateManager.enableLighting(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -148,10 +150,12 @@ private void drawBackpacks(int mouseX, int mouseY, float partialTicks, CallbackI } } } else { + GlStateManager.disableLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(0,0, 300); Gui.drawRect(x, y, x + (16 * 9) + 3, y + (16 * (length / 9)) + 3, ConfigColor.DARK_GRAY.getColor(250)); GlStateManager.popMatrix(); + GlStateManager.enableLighting(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/codes/biscuit/skyblockaddons/utils/CoordsPair.java b/src/main/java/codes/biscuit/skyblockaddons/utils/CoordsPair.java index 3e346dac7c..885119677b 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/utils/CoordsPair.java +++ b/src/main/java/codes/biscuit/skyblockaddons/utils/CoordsPair.java @@ -38,11 +38,16 @@ public boolean equals(Object obj) { return false; } CoordsPair chunkCoords = (CoordsPair)obj; - return new EqualsBuilder().append(x, chunkCoords.x).append(y, chunkCoords.y).isEquals(); + return new EqualsBuilder().append(getX(), chunkCoords.getX()).append(getY(), chunkCoords.getY()).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder(83, 11).append(x).append(y).toHashCode(); + return new HashCodeBuilder(83, 11).append(getX()).append(getY()).toHashCode(); + } + + @Override + public String toString() { + return getX()+"|"+getY(); } } diff --git a/src/main/java/codes/biscuit/skyblockaddons/utils/Scheduler.java b/src/main/java/codes/biscuit/skyblockaddons/utils/Scheduler.java index 28518d43b2..027246763d 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/utils/Scheduler.java +++ b/src/main/java/codes/biscuit/skyblockaddons/utils/Scheduler.java @@ -26,10 +26,10 @@ public Scheduler(SkyblockAddons main) { * by client ticks reliably. * * @param commandType What you want to schedule - * @param delayTicks The delay in ticks (20 ticks = 1second) + * @param delaySeconds The delay in ticks (20 ticks = 1second) */ - public void schedule(CommandType commandType, int delayTicks) { - long ticks = totalTicks+delayTicks; + public void schedule(CommandType commandType, int delaySeconds) { + long ticks = totalTicks+(delaySeconds*20); Set commands = queue.get(ticks); if (commands != null) { for (Command command : commands) { @@ -63,8 +63,8 @@ public void ticker(TickEvent.ClientTickEvent e) { } queue.remove(totalTicks); } - if (totalTicks % 18000 == 0) { // check magma boss every 15 minutes - if (main.getPlayerListener().getMagmaAccuracy() == EnumUtils.MagmaTimerAccuracy.ABOUT) { + if (totalTicks % 12000 == 0) { // check magma boss every 15 minutes + if (main.getPlayerListener().getMagmaAccuracy() != EnumUtils.MagmaTimerAccuracy.EXACTLY) { main.getUtils().fetchEstimateFromServer(); } } diff --git a/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java b/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java index 4882e96bcc..f55bd12b67 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java +++ b/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java @@ -136,6 +136,7 @@ public void checkGameLocationDate() { if (loopLocation == EnumUtils.Location.BLAZING_FORTRESS && location != EnumUtils.Location.BLAZING_FORTRESS) { sendPostRequest(EnumUtils.MagmaEvent.PING); // going into blazing fortress + main.getUtils().fetchEstimateFromServer(); } location = loopLocation; foundLocation = true; @@ -342,7 +343,7 @@ public void fetchEstimateFromServer() { long estimate = responseJson.get("estimate").getAsLong(); long currentTime = System.currentTimeMillis(); int magmaSpawnTime = (int)((estimate-currentTime)/1000); - FMLLog.info("[SkyblockAddons] System time is " + currentTime +", server time estimate is" + + FMLLog.info("[SkyblockAddons] System time is " + currentTime +", server time estimate is " + estimate+". Updating magma boss spawn to be in "+magmaSpawnTime+" seconds."); main.getPlayerListener().setMagmaTime(magmaSpawnTime, true);