Skip to content

Commit

Permalink
Fixed the magma wave/blaze wave checker. Subtract potato books from a…
Browse files Browse the repository at this point in the history
…nvil uses. Reduce magma boss checking time from 15 to 12 minutes. Fixed many compatibility issues hopefully. Fixed lighting issues in backpack preview.
  • Loading branch information
biscuut committed Aug 23, 2019
1 parent 4a57f7a commit d1401db
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 45 deletions.
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
}
Expand All @@ -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();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
10 changes: 5 additions & 5 deletions src/main/java/codes/biscuit/skyblockaddons/utils/Scheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Command> commands = queue.get(ticks);
if (commands != null) {
for (Command command : commands) {
Expand Down Expand Up @@ -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();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d1401db

Please sign in to comment.