Skip to content

Commit

Permalink
Merge the brand new changes for the brand new island :D
Browse files Browse the repository at this point in the history
Merge New Island Changes!
  • Loading branch information
AsoDesu authored Jun 14, 2023
2 parents 8369814 + e2244fb commit 5c52897
Show file tree
Hide file tree
Showing 133 changed files with 220 additions and 12 deletions.
5 changes: 5 additions & 0 deletions assets/resources/assets/island/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"island:sky_battle"
]
},
"island.music.parkour_warrior": {
"sounds": [
"island:parkour_warrior"
]
},
"island.music.classic_hitw": {
"sounds": [
"island:spacewall"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void create() {
activity.assets().setLargeImage("mcci");
activity.assets().setLargeText("play.mccisland.net");

if (started == null) started = Instant.ofEpochMilli(System.currentTimeMillis());
if (started == null) started = Instant.now();
if (IslandOptions.getOptions().showTimeElapsed)
activity.timestamps().setStart(started);

Expand Down Expand Up @@ -97,7 +97,11 @@ public static void updatePlace() {
if (ROUND_STATE != null) roundScoreboardUpdate(ROUND_STATE, false);
if (MccIslandState.getGame() == GAME.HITW || MccIslandState.getGame() == GAME.SKY_BATTLE)
if (REMAIN_STATE != null) remainScoreboardUpdate(REMAIN_STATE, false);

if (MccIslandState.getGame() == GAME.PARKOUR_WARRIOR)
if (COURSE_STATE != null) courseScoreboardUpdate(COURSE_STATE, false);
if (MccIslandState.getGame() == GAME.HUB) {
activity.setState("");
}

updateActivity();
}
Expand Down Expand Up @@ -129,6 +133,20 @@ public static void roundScoreboardUpdate(String value, Boolean set) {
updateActivity();
}

static String COURSE_STATE;
public static void courseScoreboardUpdate(String value, Boolean set) {
if (activity == null) return;
if (!IslandOptions.getOptions().showGameInfo || !IslandOptions.getOptions().showGame) return;

if (set) COURSE_STATE = value;
if (MccIslandState.getGame() != GAME.PARKOUR_WARRIOR) return;

try { activity.setState(COURSE_STATE); }
catch (Exception e) { e.printStackTrace(); }

updateActivity();
}

public static void updateActivity() {
if (activity == null) return;
if (!IslandOptions.getOptions().discordPresence) return;
Expand All @@ -154,7 +172,7 @@ public static void updateFromConfig(IslandOptions options) {

if (!options.showTimeElapsed) activity.timestamps().setStart(Instant.MAX);
else {
if (started == null) started = Instant.ofEpochMilli(System.currentTimeMillis());
if (started == null) started = Instant.now();
activity.timestamps().setStart(started);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.time.Instant;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -72,7 +73,11 @@ public void handleAddObjective(ClientboundSetObjectivePacket clientboundSetObjec
Component displayName = clientboundSetObjectivePacket.getDisplayName(); // Get the title of the scoreboard
String title = displayName.getString(); // Get the string version of the title of the scoreboard

if (!isGameDisplayName(displayName)) { // Check if the name doesn't have the aqua color, if so, we're in hub!

// Check if the name of the game is not the aqua color, then we check if we are not in parkour warrior
// Parkour Warrior (at least solo mode) is exception and has white name in the scoreboard title
// if both checks are false, we are in hub!
if (!isGameDisplayName(displayName) && !title.contains("PARKOUR WARRIOR")) {
MccIslandState.setGame(GAME.HUB);
} else { // We're in a game!!!
// These checks are pretty self-explanatory
Expand All @@ -84,6 +89,8 @@ public void handleAddObjective(ClientboundSetObjectivePacket clientboundSetObjec
MccIslandState.setGame(GAME.SKY_BATTLE);
} else if (title.contains("BATTLE BOX")) {
MccIslandState.setGame(GAME.BATTLE_BOX);
} else if (title.contains("PARKOUR WARRIOR")) {
MccIslandState.setGame(GAME.PARKOUR_WARRIOR);
} else {
MccIslandState.setGame(GAME.HUB); // Somehow we're in a game, but not soooo hub it is!!
}
Expand Down Expand Up @@ -121,7 +128,8 @@ public void handleSetExperience(ClientboundSetActionBarTextPacket clientboundSet
// Patterns for the Map & Modifier options on scoreboard
final Map<String, Pattern> scoreboardPatterns = Map.of(
"MAP", Pattern.compile("MAP: (?<map>\\w+(?:,? \\w+)*)"),
"MODIFIER", Pattern.compile("MODIFIER: (?<modifier>\\w+(?:,? \\w+)*)")
"MODIFIER", Pattern.compile("MODIFIER: (?<modifier>\\w+(?:,? \\w+)*)"),
"COURSE", Pattern.compile("COURSE: (?<course>.*)")
);
@Inject(method = "handleSetPlayerTeamPacket", at = @At("TAIL")) // Scoreboard lines!
public void handleSetPlayerTeamPacket(ClientboundSetPlayerTeamPacket clientboundSetPlayerTeamPacket, CallbackInfo ci) {
Expand All @@ -132,7 +140,7 @@ public void handleSetPlayerTeamPacket(ClientboundSetPlayerTeamPacket clientbound
ClientboundSetPlayerTeamPacket.Parameters parameters = optional.get(); // Get the team parameters
try { // We do a little exceptioning
Component prefixComponent = parameters.getPlayerPrefix(); // Get the prefix of this team
String playerPrefix = prefixComponent.getString().toUpperCase(); // Turn it uppercase
String playerPrefix = prefixComponent.getString(); // Turn it uppercase

for (Map.Entry<String, Pattern> entry : scoreboardPatterns.entrySet()) { // Loop over our scoreboard reg-exes
Matcher matcher = entry.getValue().matcher(playerPrefix); // Match the prefix against the regex
Expand All @@ -142,6 +150,7 @@ public void handleSetPlayerTeamPacket(ClientboundSetPlayerTeamPacket clientbound
switch (entry.getKey()) {
case "MAP" -> MccIslandState.setMap(value); // Set our MAP
case "MODIFIER" -> MccIslandState.setModifier(value); // Set our MODIFIER
case "COURSE" -> DiscordPresenceUpdator.courseScoreboardUpdate(value, true);
}

ChatUtils.debug("ScoreboardUpdate - Current %s: \"%s\"", entry.getKey(), value);
Expand All @@ -162,6 +171,12 @@ public void handleCustomSoundEvent(ClientboundSoundPacket clientboundCustomSound
if (MccIslandState.getGame() != GAME.HUB) {
// Use the sound files above to determine what just happened in the game
if (MccIslandState.getGame() != GAME.BATTLE_BOX) {

// Stop the music if you restart the course or switch game mode in Parkour Warrior
if(soundLoc.getPath().contains("games.parkour_warrior.mode_swap") || soundLoc.getPath().contains("games.parkour_warrior.restart_course")) {
MusicUtil.stopMusic(false);
}

if (Objects.equals(soundLoc.getPath(), "games.global.countdown.go")) {
MusicUtil.startMusic(clientboundCustomSoundPacket); // The game started. Start the music!!
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class IslandOptions implements ConfigData {
@ConfigEntry.Category("music")
boolean sbMusic = true;
@ConfigEntry.Category("music")
boolean pkwMusic = true;
@ConfigEntry.Category("music")
boolean tgttosDoubleTime = true;

@ConfigEntry.Category("cosmetics")
Expand Down Expand Up @@ -78,6 +80,10 @@ public boolean isBbMusic() {
public boolean isSbMusic() {
return sbMusic;
}
public boolean isPkwMusic() {
return pkwMusic;
}

public boolean isTgttosDoubleTime() {
return tgttosDoubleTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static net.asodev.islandutils.util.ChatUtils.translate;

public class ResourcePackUpdater {
private static final String url = "http://static.islandutils.asodev.net/pack.json";
private static final String url = "http://static.islandutils.asodev.net/pack_2.json";
private static final Component title = Component.literal(translate("Island Utils"));
private static final Component desc = Component.literal(translate("&6Music Resources"));
HttpClient client;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/asodev/islandutils/state/GAME.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum GAME {
TGTTOS("TGTTOS", new ResourceLocation("island", "island.music.tgttos")),
HITW("Hole in the Wall", new ResourceLocation("island", "island.music.hitw")),
BATTLE_BOX("Battle Box", new ResourceLocation("island", "island.music.battle_box")),
PARKOUR_WARRIOR("Parkour Warrior", new ResourceLocation("island", "island.music.parkour_warrior")),
SKY_BATTLE("Sky Battle", new ResourceLocation("island", "island.music.sky_battle"));

final private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static void setGame(GAME game) {
ClientPacketListener connection = Minecraft.getInstance().getConnection();
if (connection != null) connection.send(packet);
}
ChatUtils.debug("MccIslandState - Changed game to: " + game);
MccIslandState.game = game;
}

Expand All @@ -59,7 +60,7 @@ public static FACTION getFaction() {
return faction;
}
public static void setFaction(FACTION faction) {
ChatUtils.debug("Detected Faction: " + faction);
//ChatUtils.debug("Detected Faction: " + faction);
DiscordPresenceUpdator.setLevel(DiscordPresenceUpdator.lastLevel);
MccIslandState.faction = faction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static boolean isLockedItem(ItemStack item) {
if (!item.is(Items.POPPED_CHORUS_FRUIT)) return false;
CompoundTag tag = item.getTag();
if (tag == null) return false;
return tag.getInt("HideFlags") == 0;
return tag.getInt("HideFlags") == -1;
}
// Color items do not have lore
public static boolean isColoredItem(ItemStack item) {
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/net/asodev/islandutils/util/MCCSoundInstance.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.asodev.islandutils.util;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.sounds.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
Expand All @@ -10,6 +11,9 @@ public class MCCSoundInstance extends AbstractTickableSoundInstance {

public static ResourceLocation location;

public float ticksRemaining;
public boolean hasLooped;

public float totalVolume;
public float totalFadeTicks = 20f;
public float fadeTicks = 0f;
Expand All @@ -28,6 +32,7 @@ protected MCCSoundInstance(SoundEvent event, SoundSource soundSource, float f,fl
this.delay = i;
this.attenuation = attenuation;
this.relative = bl2;
this.ticksRemaining = ticksBeforeLoop(location);
}

public void fade(float ticks) {
Expand All @@ -41,6 +46,17 @@ public void stopFwd() {

@Override
public void tick() {
if (ticksRemaining != -1 && !hasLooped) {
if (ticksRemaining <= 0) {
Minecraft.getInstance().getSoundManager().queueTickingSound(this.copy());
hasLooped = true;
this.stop();
ChatUtils.debug("Looping sound...");
return;
}
ticksRemaining--;
}

if (!isFading) return;
if (fadeTicks <= 0) this.stop();

Expand All @@ -54,4 +70,28 @@ public String toString() {
"location=" + location +
'}';
}

public MCCSoundInstance copy() {
return new MCCSoundInstance(
SoundEvent.createVariableRangeEvent(this.getLocation()),
this.source,
this.totalVolume,
this.pitch,
this.random,
this.looping,
this.delay,
this.attenuation,
this.x,
this.y,
this.z,
this.relative
);
}

static int ticksBeforeLoop(ResourceLocation sound) {
if (sound.getPath().equals("island.music.parkour_warrior")) {
return 2400;
}
return -1;
}
}
1 change: 1 addition & 0 deletions src/main/java/net/asodev/islandutils/util/MusicUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static void startMusic(ClientboundSoundPacket clientboundCustomSoundPacke
case TGTTOS -> { if (!options.isTgttosMusic()) return; }
case BATTLE_BOX -> { if (!options.isBbMusic()) return; }
case SKY_BATTLE -> { if (!options.isSbMusic()) return; }
case PARKOUR_WARRIOR -> { if (!options.isPkwMusic()) return; }
}

ResourceLocation location = MccIslandState.getGame().getMusicLocation();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/island/font/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"providers": [
{
"type": "bitmap",
"file": "minecraft:gui/gui_icons/social.png",
"file": "mcc:island_interface/social/icon.png",
"chars": ["\ue001"],
"ascent": 7,
"height": 8
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/af_za.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/ar_sa.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/ast_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/az_az.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/ba_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/bar.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/be_by.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/bg_bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/br_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/brb.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/bs_ba.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/ca_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/cs_cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/island/lang/cy_gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.islandutils.option.hitwMusic": "HITW Music",
"text.autoconfig.islandutils.option.bbMusic": "Battle Box Music",
"text.autoconfig.islandutils.option.sbMusic": "Sky Battle Music",
"text.autoconfig.islandutils.option.pkwMusic": "Parkour Warrior Music",
"text.autoconfig.islandutils.option.tgttosDoubleTime": "TGTTOS Double Time Music",

"text.autoconfig.islandutils.category.cosmetics": "Cosmetic Previews",
Expand Down
Loading

0 comments on commit 5c52897

Please sign in to comment.