Skip to content
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
24 changes: 12 additions & 12 deletions src/main/java/io/github/fripe070/pirkko/Pirkko.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.fripe070.pirkko;

import eu.pb4.polymer.core.api.other.PolymerSoundEvent;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import eu.pb4.polymer.rsm.api.RegistrySyncUtils;
import io.github.fripe070.pirkko.block.PirkkoBlock;
import io.github.fripe070.pirkko.effect.PirkkoPowerEffect;
Expand All @@ -20,8 +21,6 @@
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.minecraft.util.Rarity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -32,12 +31,8 @@ public class Pirkko implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("pirkko");

public static final PirkkoBlock PIRKKO_BLOCK = registerPirkkoBlock("pirkko");
public static final Item DEFAULT_PIRKKO_ITEM = registerPirkkoItem("pirkko", PIRKKO_BLOCK);

public static final SoundEvent PIRKKO_SOUND = registerSoundEvent("pirkko/pirkko", SoundEvents.ENTITY_COD_FLOP);
public static final SoundEvent PIRKKO_GHOST_SOUND = registerSoundEvent("pirkko/ghost", SoundEvents.ENTITY_COD_FLOP);
public static final SoundEvent PIRKKO_PHOZ_SOUND = registerSoundEvent("pirkko/phoz", SoundEvents.ENTITY_COD_FLOP);
public static final SoundEvent PIRKKO_KONGLIG_SOUND = registerSoundEvent("pirkko/konglig", SoundEvents.ENTITY_COD_FLOP);
public static final PirkkoItem PIRKKO_ITEM = registerPirkkoItem("pirkko", PIRKKO_BLOCK);
public static final SoundEvent DEFAULT_PIRKKO_SOUND = registerSoundEvent("pirkko/pirkko", SoundEvents.ENTITY_COD_FLOP);
public static final StatusEffect PIRKKO_POWER = new PirkkoPowerEffect();

@Override
Expand All @@ -46,7 +41,13 @@ public void onInitialize() {
PolymerResourcePackUtils.markAsRequired();

Registry.register(Registries.STATUS_EFFECT, Identifier.of(MOD_ID, "pirkko_power"), PIRKKO_POWER);
PirkkoKind.InitializePirkkoKindData();

for (PirkkoKind kind : PirkkoKind.values()) {
if (!kind.usesCustomSound()) continue;
var sound = kind.getSound();
Registry.register(Registries.SOUND_EVENT, sound.id(), sound);
PolymerSoundEvent.registerOverlay(sound);
}
}

private static PirkkoBlock registerPirkkoBlock(String name) {
Expand All @@ -60,15 +61,14 @@ private static PirkkoBlock registerPirkkoBlock(String name) {
return block;
}

private static Item registerPirkkoItem(String name, PirkkoBlock block) {
private static PirkkoItem registerPirkkoItem(String name, PirkkoBlock block) {
var registryKey = Identifier.of(MOD_ID, name);
var item = new PirkkoItem(block, new Item.Settings()
.maxCount(65)
.fireproof()
.rarity(Rarity.EPIC)
.equippableUnswappable(EquipmentSlot.HEAD)
.registryKey(RegistryKey.of(RegistryKeys.ITEM, registryKey))
// .useBlockPrefixedTranslationKey()
.useBlockPrefixedTranslationKey()
);
Registry.register(Registries.ITEM, Identifier.of(MOD_ID, name), item);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(entries -> {
Expand Down
145 changes: 79 additions & 66 deletions src/main/java/io/github/fripe070/pirkko/PirkkoKind.java
Original file line number Diff line number Diff line change
@@ -1,89 +1,102 @@
package io.github.fripe070.pirkko;

import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;
import net.minecraft.util.StringIdentifiable;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;

public enum PirkkoKind implements StringIdentifiable {
BLANK(0, "blank"),
COLOR_WHITE(1, "color/white"),
COLOR_ORANGE(2, "color/orange"),
COLOR_MAGENTA(3, "color/magenta"),
COLOR_LIGHT_BLUE(4, "color/light_blue"),
COLOR_YELLOW(5, "color/yellow"),
COLOR_LIME(6, "color/lime"),
COLOR_PINK(7, "color/pink"),
COLOR_GRAY(8, "color/gray"),
COLOR_LIGHT_GRAY(9, "color/light_gray"),
COLOR_CYAN(10, "color/cyan"),
COLOR_PURPLE(11, "color/purple"),
COLOR_BLUE(12, "color/blue"),
COLOR_BROWN(13, "color/brown"),
COLOR_GREEN(14, "color/green"),
COLOR_RED(15, "color/red"),
COLOR_BLACK(16, "color/black"),
PHOZ(17, "phoz"),
KONGLIG(18, "konglig"),
GHOST(19, "ghost"),
LASERVIOLETT(20, "laserviolett"),
CERISE(21, "cerise"),
PRIDE_AROMANTIC(22, "pride/aromantic"),
PRIDE_ASEXUAL(23, "pride/asexual"),
PRIDE_BISEXUAL(24, "pride/bisexual"),
PRIDE_GAY_M(25, "pride/gay_m"),
PRIDE_GENDER_FLUID(26, "pride/genderfluid"),
PRIDE_LESBIAN(27, "pride/lesbian"),
PRIDE_NONBINARY(28, "pride/nonbinary"),
PRIDE_RAINBOW(29, "pride/rainbow"),
PRIDE_TRANSGENDER(30, "pride/transgender");
BLANK("blank", Rarity.UNCOMMON),

COLOR_WHITE("color/white", Rarity.UNCOMMON),
COLOR_ORANGE("color/orange", Rarity.UNCOMMON),
COLOR_MAGENTA("color/magenta", Rarity.UNCOMMON),
COLOR_LIGHT_BLUE("color/light_blue", Rarity.UNCOMMON),
COLOR_YELLOW("color/yellow", Rarity.UNCOMMON),
COLOR_LIME("color/lime", Rarity.UNCOMMON),
COLOR_PINK("color/pink", Rarity.UNCOMMON),
COLOR_GRAY("color/gray", Rarity.UNCOMMON),
COLOR_LIGHT_GRAY("color/light_gray", Rarity.UNCOMMON),
COLOR_CYAN("color/cyan", Rarity.UNCOMMON),
COLOR_PURPLE("color/purple", Rarity.UNCOMMON),
COLOR_BLUE("color/blue", Rarity.UNCOMMON),
COLOR_BROWN("color/brown", Rarity.UNCOMMON),
COLOR_GREEN("color/green", Rarity.UNCOMMON),
COLOR_RED("color/red", Rarity.UNCOMMON),
COLOR_BLACK("color/black", Rarity.UNCOMMON),

private final int index;
private final String id;
private final String friendlyId;
private final PirkkoKindData pirkkoKindData;
PRIDE_AROMANTIC("pride/aromantic", Rarity.UNCOMMON),
PRIDE_ASEXUAL("pride/asexual", Rarity.UNCOMMON),
PRIDE_BISEXUAL("pride/bisexual", Rarity.UNCOMMON),
PRIDE_GAY_M("pride/gay_m", Rarity.UNCOMMON),
PRIDE_GENDER_FLUID("pride/genderfluid", Rarity.UNCOMMON),
PRIDE_LESBIAN("pride/lesbian", Rarity.UNCOMMON),
PRIDE_NONBINARY("pride/nonbinary", Rarity.UNCOMMON),
PRIDE_RAINBOW("pride/rainbow", Rarity.UNCOMMON),
PRIDE_TRANSGENDER("pride/transgender", Rarity.UNCOMMON),

PirkkoKind(int index, String id) {
this.index = index;
this.id = id;
this.friendlyId = id.replace("/", "_");
this.pirkkoKindData = new PirkkoKindData();
}
LASERVIOLETT("laserviolett", Rarity.RARE),
CERISE("cerise", Rarity.RARE),
PHOZ("phoz", Rarity.RARE, true),
KONGLIG("konglig", Rarity.RARE, true),
GHOST("ghost", Rarity.RARE, true);

private final String assetPath;
private final Rarity rarity;
private final @Nullable SoundEvent soundEvent;

public static void InitializePirkkoKindData() {
GHOST.pirkkoKindData()
.setSound(Pirkko.PIRKKO_GHOST_SOUND);
PHOZ.pirkkoKindData()
.setSound(Pirkko.PIRKKO_PHOZ_SOUND);
KONGLIG.pirkkoKindData()
.setSound(Pirkko.PIRKKO_KONGLIG_SOUND);
PirkkoKind(String assetPath, Rarity rarity) {
this(assetPath, rarity, false);
}
PirkkoKind(String assetPath, Rarity rarity, boolean useCustomSound) {
this.assetPath = assetPath;
this.rarity = rarity;
var sound = SoundEvent.of(Identifier.of(Pirkko.MOD_ID, "pirkko/" + this.getPath()));
this.soundEvent = useCustomSound ? sound : null;
}

@Override
public String asString() {
return friendlyId;
public String getPath() {
return assetPath;
}
public String getId() {
return assetPath.replace("/", "_");
}
public String getTranslationKey() {
return assetPath.replace("/", ".");
}

public String realId() {
return id;
public Rarity getRarity() {
return rarity;
}
public boolean usesCustomSound() {
return soundEvent != null;
}
public SoundEvent getSound() {
return Optional.ofNullable(soundEvent).orElse(Pirkko.DEFAULT_PIRKKO_SOUND);
}

public PirkkoKindData pirkkoKindData() {
return pirkkoKindData;
@Override
public String asString() {
return this.getId();
}

public int getIndex() {
return index;
@Nullable
public static PirkkoKind fromPath(String path) {
return Stream.of(values())
.filter(kind -> kind.getPath().equals(path))
.findFirst()
.orElse(null);
}

@Nullable
public static PirkkoKind fromName(String name) {
for (PirkkoKind kind : PirkkoKind.values()) {
if (Objects.equals(kind.asString(), name)) {
return kind;
}
}
return null;
public static PirkkoKind fromId(String id) {
return Stream.of(values())
.filter(kind -> kind.getId().equals(id))
.findFirst()
.orElse(null);
}
}
}
Loading