Skip to content

Commit

Permalink
Fix burrow tracker mobs not saving
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Apr 26, 2021
1 parent 5b27131 commit c60915a
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
5 changes: 3 additions & 2 deletions src/main/kotlin/skytils/skytilsmod/Skytils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package skytils.skytilsmod

import club.sk1er.vigilance.gui.SettingsGui
import com.google.common.collect.Lists
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiButton
Expand Down Expand Up @@ -95,7 +96,7 @@ class Skytils {
const val VERSION = "1.0-pre1"

@JvmField
val gson = GsonBuilder().setPrettyPrinting().create()
val gson: Gson = GsonBuilder().setPrettyPrinting().create()

@JvmField
val mc: Minecraft = Minecraft.getMinecraft()
Expand Down Expand Up @@ -308,7 +309,7 @@ class Skytils {
y2 = y + 20
}
}
event.buttonList.add(GuiButton(6969420, x, Math.max(0, y), 100, 20, "Skytils"))
event.buttonList.add(GuiButton(6969420, x, 0.coerceAtLeast(y), 100, 20, "Skytils"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class GriffinBurrows {
@SubscribeEvent
fun onTick(event: ClientTickEvent) {
val player = mc.thePlayer
if (event.phase != TickEvent.Phase.START || SBInfo.instance.mode != "hub") return
if (event.phase != TickEvent.Phase.START || SBInfo.instance.mode != SBInfo.SkyblockIslands.HUB.mode) return
if (!burrowRefreshTimer.isStarted) burrowRefreshTimer.start()
if (burrowRefreshTimer.time >= 90_000 || shouldRefreshBurrows) {
burrowRefreshTimer.reset()
Expand Down Expand Up @@ -232,7 +232,7 @@ class GriffinBurrows {

class GriffinGuiElement : GuiElement("Griffin Timer", FloatPair(100, 10)) {
override fun render() {
if (SBInfo.instance.mode != "hub") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.HUB.mode) return
val player = mc.thePlayer
if (toggled && Utils.inSkyblock && player != null) {
for (i in 0..7) {
Expand Down Expand Up @@ -283,7 +283,7 @@ class GriffinBurrows {
fun onReceivePacket(event: ReceiveEvent) {
if (!Utils.inSkyblock) return
if (Skytils.config.showGriffinBurrows && Skytils.config.particleBurrows && event.packet is S2APacketParticles) {
if (SBInfo.instance.mode != "hub") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.HUB.mode) return
val packet = event.packet
val type = packet.particleType
val longDistance = packet.isLongDistance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TechnoMayor {
@SubscribeEvent
fun onWorldRender(event: RenderWorldLastEvent) {
if (!Utils.inSkyblock) return
if (SBInfo.instance.mode != "hub" && SBInfo.instance.mode != "farming_1") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.HUB.mode && SBInfo.instance.mode != SBInfo.SkyblockIslands.FARMINGISLANDS.mode) return
if (!Skytils.config.shinyOrbWaypoints) return
val viewer = Minecraft.getMinecraft().renderViewEntity
val viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TreasureHunter {

@SubscribeEvent
fun onRenderWorld(event: RenderWorldLastEvent) {
if (!Utils.inSkyblock || treasureLocation == null || SBInfo.instance.mode != "farming_1") return
if (!Utils.inSkyblock || treasureLocation == null || SBInfo.instance.mode != SBInfo.SkyblockIslands.FARMINGISLANDS.mode) return
val viewer = Minecraft.getMinecraft().renderViewEntity
val viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks
val viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DarkModeMist {
fun onGetBlockModel(event: RenderBlockInWorldEvent) {
if (!Utils.inSkyblock || !Skytils.config.darkModeMist) return
val state = event.state
if (SBInfo.instance.mode == "mining_3" && event.state != null && event.pos != null) {
if (SBInfo.instance.mode == SBInfo.SkyblockIslands.DWARVENMINES.mode && event.state != null && event.pos != null) {
if ((event.pos as BlockPos).y <= 76) {
if ((state as IBlockState).block === Blocks.stained_glass && (state as IBlockState).getValue(BlockStainedGlass.COLOR) == EnumDyeColor.WHITE) {
event.state = state.withProperty(BlockStainedGlass.COLOR, EnumDyeColor.GRAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class MiningFeatures {
""
) && !unformatted.contains("") && !unformatted.contains("")
) return
if (SBInfo.instance.mode == "mining_3") {
if (SBInfo.instance.mode == SBInfo.SkyblockIslands.DWARVENMINES.mode) {
puzzlerSolution = BlockPos(181, 195, 135)
val msg = unformatted.substring(15).trim { it <= ' ' }
val matcher = Pattern.compile("([▶▲◀▼]+)").matcher(unformatted)
Expand Down Expand Up @@ -259,7 +259,7 @@ class MiningFeatures {
@SubscribeEvent
fun onTick(event: ClientTickEvent) {
if (!Utils.inSkyblock || event.phase != TickEvent.Phase.START) return
if (Skytils.config.skymallReminder && SBInfo.instance.mode == "mining_3" && SBInfo.instance.time == "12:00 am" && GuiManager.title != "§cSKYMALL RESET"
if (Skytils.config.skymallReminder && SBInfo.instance.mode == SBInfo.SkyblockIslands.DWARVENMINES.mode && SBInfo.instance.time == "12:00 am" && GuiManager.title != "§cSKYMALL RESET"
) {
createTitle("§cSKYMALL RESET", 20)
}
Expand All @@ -275,7 +275,7 @@ class MiningFeatures {

@SubscribeEvent(priority = EventPriority.HIGH)
fun onGetBlockModel(event: RenderBlockInWorldEvent) {
if (!Utils.inSkyblock || SBInfo.instance.mode != "mining_3" || event.state == null) return
if (!Utils.inSkyblock || SBInfo.instance.mode != SBInfo.SkyblockIslands.DWARVENMINES.mode || event.state == null) return
val state = event.state!!
if (Skytils.config.recolorCarpets && state.block === Blocks.carpet && state.getValue(BlockCarpet.COLOR) == EnumDyeColor.GRAY) {
event.state = state.withProperty(BlockCarpet.COLOR, EnumDyeColor.RED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class MiscFeatures {
override fun render() {
val player = mc.thePlayer
if (toggled && Utils.inSkyblock && player != null && mc.theWorld != null) {
if (SBInfo.instance.mode != "combat_3") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.THEEND.mode) return
var invalid = false
var placedEyes = 0
for (pos in SUMMONING_EYE_FRAMES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ItemWorthStrategy : ItemProtectStrategy() {
return value >= threshold
}
ProtectType.HOTBARDROPKEY -> {
if (SBInfo.instance.mode != "dungeon") {
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.DUNGEON.mode) {
return value >= threshold
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class StarredItemStrategy : ItemProtectStrategy() {
}
}
ProtectType.HOTBARDROPKEY -> {
if (SBInfo.instance.mode != "dungeon" && extraAttr.hasKey("dungeon_item_level")) {
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.DUNGEON.mode && extraAttr.hasKey("dungeon_item_level")) {
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RelicWaypoints : PersistentSave(File(Skytils.modDir, "found_spiders_den_re
@SubscribeEvent
fun onSendPacket(event: SendEvent) {
if (!Utils.inSkyblock) return
if (SBInfo.instance.mode != "combat_1") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.SPIDERDEN.mode) return
if (event.packet is C08PacketPlayerBlockPlacement) {
val packet = event.packet as C08PacketPlayerBlockPlacement?
if (relicLocations.contains(packet!!.position)) {
Expand All @@ -86,7 +86,7 @@ class RelicWaypoints : PersistentSave(File(Skytils.modDir, "found_spiders_den_re
@SubscribeEvent
fun onWorldRender(event: RenderWorldLastEvent) {
if (!Utils.inSkyblock) return
if (SBInfo.instance.mode != "combat_1") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.SPIDERDEN.mode) return
val viewer = Minecraft.getMinecraft().renderViewEntity
val viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks
val viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SpidersDenFeatures {
val player = mc.thePlayer
val world: World? = mc.theWorld
if (toggled && Utils.inSkyblock && player != null && world != null) {
if (SBInfo.instance.mode != "combat_1") return
if (SBInfo.instance.mode != SBInfo.SkyblockIslands.SPIDERDEN.mode) return
val arachneNames =
world.getEntities(EntityArmorStand::class.java, Predicate getEntities@{ entity: EntityArmorStand? ->
val name = entity!!.displayName.formattedText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class MythologicalTracker : PersistentSave(File(File(Skytils.modDir, "trackers")

val mobObj = JsonObject()
for (mob in BurrowMob.values()) {
itemObj.addProperty(mob.modId, mob.dugTimes)
mobObj.addProperty(mob.modId, mob.dugTimes)
}
obj.add("mobs", mobObj)
gson.toJson(obj, writer)
Expand Down
17 changes: 16 additions & 1 deletion src/main/kotlin/skytils/skytilsmod/utils/SBInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import java.util.*
import java.util.regex.Pattern

/**
* Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
* Adapted from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
* https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE
*
* @author Moulberry
Expand Down Expand Up @@ -163,4 +163,19 @@ class SBInfo {
private val timePattern = Pattern.compile(".+(am|pm)")
private val JSON_BRACKET_PATTERN = Pattern.compile("\\{.+}")
}

enum class SkyblockIslands(val mode: String) {
BLAZINGFORTRESS("combat_2"),
DEEPERCAVERNS("mining_2"),
DUNGEON("dungeon"),
DUNGEONHUB("dungeon_hub"),
DWARVENMINES("mining_3"),
FARMINGISLANDS("farming_1"),
GOLDMINE("mining_1"),
HUB("hub"),
THEEND("combat_3"),
THEPARK("foraging_1"),
PRIVATEISLAND("dynamic"),
SPIDERDEN("combat_1")
}
}

0 comments on commit c60915a

Please sign in to comment.