From 392e321d68571a9b0eb657659dce70c2063a382e Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Jan 2025 18:21:40 -0500 Subject: [PATCH] Clean up ResourceLocation creation --- .../com/legobmw99/allomancy/Allomancy.java | 4 +++ .../allomancy/datagen/Advancements.java | 28 +++++-------------- .../allomancy/datagen/EquipmentAssets.java | 12 ++++---- .../datagen/ParticleDescriptions.java | 4 +-- .../legobmw99/allomancy/datagen/Recipes.java | 1 - .../integration/AllomancyTooltip.java | 2 +- .../allomancy/modules/combat/CombatSetup.java | 17 ++++------- .../combat/item/ObsidianDaggerItem.java | 4 +-- .../allomancy/modules/extras/ExtrasSetup.java | 9 ++---- .../extras/command/AllomancyPowerCommand.java | 6 ++-- .../modules/extras/mixin/BannerDFUMixin.java | 4 +-- .../modules/materials/MaterialsSetup.java | 7 ++--- .../powers/client/gui/MetalOverlay.java | 6 ++-- .../powers/client/gui/MetalSelectScreen.java | 2 +- .../powers/network/AllomancerDataPayload.java | 4 +-- .../powers/network/BlockPushPullPayload.java | 4 +-- .../powers/network/EmotionPayload.java | 4 +-- .../powers/network/EnhanceTimePayload.java | 4 +-- .../powers/network/EntityPushPullPayload.java | 4 +-- .../powers/network/ToggleBurnPayload.java | 4 +-- 20 files changed, 44 insertions(+), 86 deletions(-) diff --git a/src/main/java/com/legobmw99/allomancy/Allomancy.java b/src/main/java/com/legobmw99/allomancy/Allomancy.java index 1c1f2025..4fe334be 100644 --- a/src/main/java/com/legobmw99/allomancy/Allomancy.java +++ b/src/main/java/com/legobmw99/allomancy/Allomancy.java @@ -13,6 +13,7 @@ import com.legobmw99.allomancy.modules.powers.network.Network; import com.legobmw99.allomancy.util.AllomancyConfig; import com.legobmw99.allomancy.util.ItemDisplay; +import net.minecraft.resources.ResourceLocation; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModContainer; @@ -31,6 +32,9 @@ public class Allomancy { public static final Logger LOGGER = LogManager.getLogger(); + public static ResourceLocation rl(String path) { + return ResourceLocation.fromNamespaceAndPath(MODID, path); + } public Allomancy(IEventBus bus, ModContainer container, Dist dist) { diff --git a/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java b/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java index a7f1a20a..9659c890 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java @@ -45,9 +45,7 @@ public void generate(HolderLookup.Provider registries, Consumer regist EquipmentClientInfo .builder() - .addLayers(EquipmentClientInfo.LayerType.HUMANOID, new EquipmentClientInfo.Layer( - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "mistcloak"), - Optional.empty(), false)) + .addLayers(EquipmentClientInfo.LayerType.HUMANOID, + new EquipmentClientInfo.Layer(Allomancy.rl("mistcloak"), Optional.empty(), + false)) .build()); registrar.accept(CombatSetup.ALUMINUM.location(), EquipmentClientInfo .builder() - .addLayers(EquipmentClientInfo.LayerType.HUMANOID, new EquipmentClientInfo.Layer( - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "aluminum"), - Optional.empty(), false)) + .addLayers(EquipmentClientInfo.LayerType.HUMANOID, + new EquipmentClientInfo.Layer(Allomancy.rl("aluminum"), Optional.empty(), + false)) .build()); } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/ParticleDescriptions.java b/src/main/java/com/legobmw99/allomancy/datagen/ParticleDescriptions.java index 31411275..45499444 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/ParticleDescriptions.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/ParticleDescriptions.java @@ -3,7 +3,6 @@ import com.legobmw99.allomancy.Allomancy; import com.legobmw99.allomancy.modules.powers.client.PowersClientSetup; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.common.data.ParticleDescriptionProvider; class ParticleDescriptions extends ParticleDescriptionProvider { @@ -14,8 +13,7 @@ protected ParticleDescriptions(PackOutput output) { @Override protected void addDescriptions() { - sprite(PowersClientSetup.SOUND_PARTICLE_TYPE.get(), - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "sound_particle")); + sprite(PowersClientSetup.SOUND_PARTICLE_TYPE.get(), Allomancy.rl("sound_particle")); } } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java b/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java index c7718b68..8bc5219e 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java @@ -14,7 +14,6 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.*; -import net.minecraft.data.recipes.packs.VanillaRecipeProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; diff --git a/src/main/java/com/legobmw99/allomancy/integration/AllomancyTooltip.java b/src/main/java/com/legobmw99/allomancy/integration/AllomancyTooltip.java index f5d28559..02bb4f23 100644 --- a/src/main/java/com/legobmw99/allomancy/integration/AllomancyTooltip.java +++ b/src/main/java/com/legobmw99/allomancy/integration/AllomancyTooltip.java @@ -54,6 +54,6 @@ public void appendTooltip(ITooltip tooltip, EntityAccessor accessor, IPluginConf @Override public ResourceLocation getUid() { - return ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "waila_bronze"); + return Allomancy.rl("waila_bronze"); } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java b/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java index da068e9e..6d0e01bf 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java @@ -56,8 +56,7 @@ public final class CombatSetup { Allomancy.MODID, "wool")); - public static final TagKey REPAIRS_MISTCLOAK = - ItemTags.create(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "repairs_wool_armor")); + public static final TagKey REPAIRS_MISTCLOAK = ItemTags.create(Allomancy.rl("repairs_wool_armor")); private static final ArmorMaterial WOOL_ARMOR = @@ -74,10 +73,9 @@ public final class CombatSetup { // note: overrides normal armor, which is fine .attributes(ItemAttributeModifiers .builder() - .add(Attributes.MOVEMENT_SPEED, new AttributeModifier( - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, - "mistcloak_speed"), 0.25, - AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL), + .add(Attributes.MOVEMENT_SPEED, + new AttributeModifier(Allomancy.rl("mistcloak_speed"), 0.25, + AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL), EquipmentSlotGroup.CHEST) .build()))); @@ -89,8 +87,7 @@ public final class CombatSetup { "aluminum")); - public static final TagKey REPAIRS_ALUMINUM = - ItemTags.create(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "repairs_aluminum_armor")); + public static final TagKey REPAIRS_ALUMINUM = ItemTags.create(Allomancy.rl("repairs_aluminum_armor")); private static final ArmorMaterial ALUMINUM_ARMOR = new ArmorMaterial(15, Util.make(new EnumMap<>(ArmorType.class), map -> { @@ -122,9 +119,7 @@ public boolean isBookEnchantable(ItemStack stack, ItemStack book) { .setShouldReceiveVelocityUpdates(true) .setUpdateInterval(20) .sized(0.25F, 0.25F) - .build(ResourceKey.create(Registries.ENTITY_TYPE, - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, - "nugget_projectile")))); + .build(ResourceKey.create(Registries.ENTITY_TYPE, Allomancy.rl("nugget_projectile")))); private CombatSetup() {} diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java b/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java index 27debb38..1397b923 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java @@ -3,7 +3,6 @@ import com.legobmw99.allomancy.Allomancy; import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponents; -import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; @@ -19,8 +18,7 @@ public class ObsidianDaggerItem extends SwordItem { private static final int ATTACK_DAMAGE = 23; private static final float ATTACK_SPEED = 9.2F; - public static final TagKey OBSIDIAN_REPAIR = - ItemTags.create(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "obsidian_tool_materials")); + public static final TagKey OBSIDIAN_REPAIR = ItemTags.create(Allomancy.rl("obsidian_tool_materials")); private static final ToolMaterial OBSIDIAN = new ToolMaterial(BlockTags.INCORRECT_FOR_WOODEN_TOOL, 2, ATTACK_SPEED, 1.0F, ATTACK_DAMAGE, OBSIDIAN_REPAIR); diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java b/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java index bb45461f..f955f39d 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java @@ -20,7 +20,6 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.TagKey; import net.minecraft.world.item.BannerPatternItem; @@ -53,7 +52,7 @@ public final class ExtrasSetup { public static final BlockCapability ALLOMANTICALLY_USABLE_BLOCK = BlockCapability.createVoid( // Provide a name to uniquely identify the capability. - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "allomantically_usable_block"), + Allomancy.rl("allomantically_usable_block"), // Provide the queried type. Here, we want to look up `IItemHandler` instances. IAllomanticallyUsable.class); @@ -99,12 +98,10 @@ public final class ExtrasSetup { for (Metal mt : Metal.values()) { String name = mt.getName(); - var pattern = ResourceKey.create(Registries.BANNER_PATTERN, - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, name)); + var pattern = ResourceKey.create(Registries.BANNER_PATTERN, Allomancy.rl(name)); PATTERNS.add(pattern); - var pattern_key = TagKey.create(Registries.BANNER_PATTERN, - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, name)); + var pattern_key = TagKey.create(Registries.BANNER_PATTERN, Allomancy.rl(name)); PATTERN_KEYS.add(pattern_key); var pattern_item = ITEMS.registerItem(name + "_pattern", diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java b/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java index 4a4f1bb2..f7a2cf5a 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java @@ -53,7 +53,7 @@ public static void register(CommandDispatcher dispatcher) { LiteralArgumentBuilder root = Commands.literal("allomancy").requires(permissions(0)); root.then(Commands .literal("get") - .requires(permissions(0)) + .requires(permissions(Commands.LEVEL_ALL)) .executes(ctx -> handleMultiPlayer(ctx, sender(ctx), AllomancyPowerCommand::getPowers)) .then(Commands .argument("targets", EntityArgument.players()) @@ -62,7 +62,7 @@ public static void register(CommandDispatcher dispatcher) { root.then(Commands .literal("add") - .requires(permissions(2)) + .requires(permissions(Commands.LEVEL_GAMEMASTERS)) .then(Commands .argument("type", AllomancyPowerType.INSTANCE) .executes(ctx -> handleMultiPlayer(ctx, sender(ctx), @@ -74,7 +74,7 @@ public static void register(CommandDispatcher dispatcher) { root.then(Commands .literal("remove") - .requires(permissions(2)) + .requires(permissions(Commands.LEVEL_GAMEMASTERS)) .then(Commands .argument("type", AllomancyPowerType.INSTANCE) .executes(ctx -> handleMultiPlayer(ctx, sender(ctx), diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/mixin/BannerDFUMixin.java b/src/main/java/com/legobmw99/allomancy/modules/extras/mixin/BannerDFUMixin.java index 7114b0d5..99d8265b 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/mixin/BannerDFUMixin.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/mixin/BannerDFUMixin.java @@ -2,7 +2,6 @@ import com.legobmw99.allomancy.Allomancy; import com.legobmw99.allomancy.api.enums.Metal; -import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.fixes.BannerPatternFormatFix; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -37,8 +36,7 @@ private static void onConstruct(CallbackInfo info) { for (Metal mt : Metal.values()) { String name = mt.getName(); Allomancy.LOGGER.info("Redirecting banner pattern for {}", name); - patternMap.put("ALLOMANCY" + name.toUpperCase(Locale.ROOT), - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, name).toString()); + patternMap.put("ALLOMANCY" + name.toUpperCase(Locale.ROOT), Allomancy.rl(name).toString()); } PATTERN_ID_MAP = patternMap; diff --git a/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java b/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java index fc007011..ab6b7345 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java @@ -12,7 +12,6 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BiomeTags; import net.minecraft.tags.BlockTags; import net.minecraft.util.valueproviders.UniformInt; @@ -49,8 +48,7 @@ private MaterialsSetup() {} public record OreConfig(String name, int size, int placementCount, int minHeight, int maxHeight) { ResourceKey getRegistryKey(ResourceKey> registry, String suffix) { - return ResourceKey.create(registry, - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, this.name + suffix)); + return ResourceKey.create(registry, Allomancy.rl(this.name + suffix)); } @Override @@ -66,8 +64,7 @@ public String toString() { new OreConfig("zinc", 8, 12, 40, 80)}; private static final ResourceKey ADD_ALLOMANCY_ORES = - ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "overworld_ores")); + ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, Allomancy.rl("overworld_ores")); public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(Allomancy.MODID); private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Allomancy.MODID); diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java index 8cf43897..132a866c 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java @@ -20,8 +20,7 @@ public final class MetalOverlay implements LayeredDraw.Layer { private static final Point[] Frames = new Point[4]; - private static final ResourceLocation meterLoc = - ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "textures/gui/overlay/meter.png"); + private static final ResourceLocation meterLoc = Allomancy.rl("textures/gui/overlay/meter.png"); private int currentFrame = 0; static { @@ -35,8 +34,7 @@ public final class MetalOverlay implements LayeredDraw.Layer { private MetalOverlay() {} public static void registerGUI(final RegisterGuiLayersEvent evt) { - evt.registerAboveAll(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "metal_display"), - new MetalOverlay()); + evt.registerAboveAll(Allomancy.rl("metal_display"), new MetalOverlay()); } private static void blit(GuiGraphics graphics, diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java index 94f54ebd..e6634196 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java @@ -40,7 +40,7 @@ public class MetalSelectScreen extends Screen { Arrays.stream(METAL_NAMES).map(s -> "metals." + s).toArray(String[]::new); private static final ResourceLocation[] METAL_ICONS = Arrays .stream(METAL_NAMES) - .map(s -> ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, String.format(GUI_METAL, s))) + .map(s -> Allomancy.rl(String.format(GUI_METAL, s))) .toArray(ResourceLocation[]::new); private final Minecraft mc; private int timeIn = PowersConfig.animate_selection.get() ? 0 : 16; diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/AllomancerDataPayload.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/AllomancerDataPayload.java index 6e5b739e..b7575890 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/AllomancerDataPayload.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/AllomancerDataPayload.java @@ -8,15 +8,13 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import java.util.UUID; public record AllomancerDataPayload(CompoundTag nbt, UUID player) implements CustomPacketPayload { - public static final Type TYPE = - new Type<>(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "player_data")); + public static final Type TYPE = new Type<>(Allomancy.rl("player_data")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ByteBufCodecs.COMPOUND_TAG, AllomancerDataPayload::nbt, UUIDUtil.STREAM_CODEC, diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/BlockPushPullPayload.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/BlockPushPullPayload.java index e91d228a..cb383bc6 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/BlockPushPullPayload.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/BlockPushPullPayload.java @@ -6,11 +6,9 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; public record BlockPushPullPayload(BlockPos block, int direction) implements CustomPacketPayload { - public static final Type TYPE = - new Type<>(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "block_push_pull")); + public static final Type TYPE = new Type<>(Allomancy.rl("block_push_pull")); public static final StreamCodec STREAM_CODEC = diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/EmotionPayload.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/EmotionPayload.java index a9fd95b8..9514d6d4 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/EmotionPayload.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/EmotionPayload.java @@ -5,12 +5,10 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; public record EmotionPayload(int entityID, boolean makeAggressive) implements CustomPacketPayload { - public static final Type TYPE = - new Type<>(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "change_emotion")); + public static final Type TYPE = new Type<>(Allomancy.rl("change_emotion")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ByteBufCodecs.INT, EmotionPayload::entityID, ByteBufCodecs.BOOL, EmotionPayload::makeAggressive, EmotionPayload::new); diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/EnhanceTimePayload.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/EnhanceTimePayload.java index 75e91755..8297987a 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/EnhanceTimePayload.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/EnhanceTimePayload.java @@ -5,12 +5,10 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; public record EnhanceTimePayload(int enhanceTime, int entityID) implements CustomPacketPayload { - public static final Type TYPE = - new Type<>(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "enhance_tick")); + public static final Type TYPE = new Type<>(Allomancy.rl("enhance_tick")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ByteBufCodecs.INT, EnhanceTimePayload::enhanceTime, ByteBufCodecs.INT, diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/EntityPushPullPayload.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/EntityPushPullPayload.java index a6e9996f..21befee8 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/EntityPushPullPayload.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/EntityPushPullPayload.java @@ -5,12 +5,10 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; public record EntityPushPullPayload(int entityID, int force) implements CustomPacketPayload { - public static final Type TYPE = - new Type<>(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "entity_push_pull")); + public static final Type TYPE = new Type<>(Allomancy.rl("entity_push_pull")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ByteBufCodecs.INT, EntityPushPullPayload::entityID, ByteBufCodecs.INT, diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/ToggleBurnPayload.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/ToggleBurnPayload.java index a78d0c08..401bfece 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/ToggleBurnPayload.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/ToggleBurnPayload.java @@ -6,12 +6,10 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs; public record ToggleBurnPayload(Metal metal, boolean on) implements CustomPacketPayload { - public static final Type TYPE = - new Type<>(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "toggle_burn")); + public static final Type TYPE = new Type<>(Allomancy.rl("toggle_burn")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(NeoForgeStreamCodecs.enumCodec(Metal.class), ToggleBurnPayload::metal,