From 9c639562598150228f4f78abcbc38c9bc89368b0 Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Fri, 9 Feb 2024 15:00:20 +0800 Subject: [PATCH] jukebox missing discs and duration tick rate fix ## Changes - resolves #118 - slimefun tickrate is now utilized to adjust initial duration in seconds. --- pom.xml | 4 ++-- .../machines/ElectricJukebox.java | 18 +++++++++++------- .../implementation/DiscDurationsEnum.java | 14 +++++++++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 0f0e1514..802829c6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ ne.fnfal113 FNAmplifications - Unoffical-4.1.7 + Unoffical-4.1.8 jar FNAmplifications - Adds different kind of items in-game from machines, utilities to pvp related items! Take part on exploring FN's offering! + Adds different kind of in-game items from machines, utilities to pvp related items! Take part on exploring FN's offering! 1.8 diff --git a/src/main/java/ne/fnfal113/fnamplifications/machines/ElectricJukebox.java b/src/main/java/ne/fnfal113/fnamplifications/machines/ElectricJukebox.java index 2b4a1635..aa76a7c4 100644 --- a/src/main/java/ne/fnfal113/fnamplifications/machines/ElectricJukebox.java +++ b/src/main/java/ne/fnfal113/fnamplifications/machines/ElectricJukebox.java @@ -20,7 +20,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; -import ne.fnfal113.fnamplifications.FNAmplifications; import ne.fnfal113.fnamplifications.machines.abstracts.AbstractJukeBox; import ne.fnfal113.fnamplifications.machines.implementation.DiscDurationsEnum; import ne.fnfal113.fnamplifications.utils.Utils; @@ -303,17 +302,22 @@ public void onTick(@Nonnull Block b) { menu.replaceExistingItem(48, OPERATING); if(jukebox.getPlaying() != Material.AIR) { - menu.replaceExistingItem(49, new CustomItemStack(Material.PINK_STAINED_GLASS_PANE, - "&d&lPlaying: " + jukebox.getPlaying().toString().replace("_", " "), - "&eDuration : " + - durationMap.get(b.getLocation()) + "/" + - (DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDurationInSec() * 2))); + menu.replaceExistingItem( + 49, + new CustomItemStack( + Material.PINK_STAINED_GLASS_PANE, + "&d&lPlaying: " + jukebox.getPlaying().toString().replace("_", " "), + "&eDuration : " + + durationMap.get(b.getLocation()) + "/" + + (DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDuration()) + ) + ); } } // when disc duration has elapsed, check next slot if there is a disc else stop the jukebox or go back to default slot when upper bound is reached if(durationMap.containsKey(b.getLocation())) { - if (durationMap.get(b.getLocation()) >= (DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDurationInSec() * 2)) { + if (durationMap.get(b.getLocation()) >= DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDuration()) { goToNextSlot(menu, null); currentTime = 0; diff --git a/src/main/java/ne/fnfal113/fnamplifications/machines/implementation/DiscDurationsEnum.java b/src/main/java/ne/fnfal113/fnamplifications/machines/implementation/DiscDurationsEnum.java index 300a2143..51907342 100644 --- a/src/main/java/ne/fnfal113/fnamplifications/machines/implementation/DiscDurationsEnum.java +++ b/src/main/java/ne/fnfal113/fnamplifications/machines/implementation/DiscDurationsEnum.java @@ -1,5 +1,7 @@ package ne.fnfal113.fnamplifications.machines.implementation; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + public enum DiscDurationsEnum { MUSIC_DISC_13(180), @@ -16,16 +18,18 @@ public enum DiscDurationsEnum { MUSIC_DISC_WAIT(235), MUSIC_DISC_OTHERSIDE(180), MUSIC_DISC_PIGSTEP(148), + MUSIC_DISC_5(178), + MUSIC_DISC_RELIC(216), ; - private final int durationInSec; + private final int duration; - DiscDurationsEnum(int durationInSec) { - this.durationInSec = durationInSec; + DiscDurationsEnum(int durationInSeconds) { + this.duration = durationInSeconds * (int) 20.0 / Slimefun.getTickerTask().getTickRate(); } - public int getDurationInSec(){ - return durationInSec; + public int getDuration() { + return duration; } } \ No newline at end of file