Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jukebox missing discs and duration tick rate fix #119

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>ne.fnfal113</groupId>
<artifactId>FNAmplifications</artifactId>
<version>Unoffical-4.1.7</version>
<version>Unoffical-4.1.8</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>

<description>Adds different kind of items in-game from machines, utilities to pvp related items! Take part on exploring FN's offering!</description>
<description>Adds different kind of in-game items from machines, utilities to pvp related items! Take part on exploring FN's offering!</description>

<properties>
<java.version>1.8</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ne.fnfal113.fnamplifications.machines.implementation;

import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

public enum DiscDurationsEnum {

MUSIC_DISC_13(180),
Expand All @@ -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;
}

}
Loading