From 1a4a7fba589a9fac90c187d914a3b45ce129954b Mon Sep 17 00:00:00 2001 From: Caltinor <62700786+Caltinor@users.noreply.github.com> Date: Sat, 16 Dec 2023 15:03:49 -0500 Subject: [PATCH] fix porting errors --- .../harmonised/pmmo/core/perks/FeaturePerks.java | 15 +++++++-------- .../java/harmonised/pmmo/events/EventHandler.java | 5 +---- .../harmonised/pmmo/events/impl/TradeHandler.java | 2 +- .../java/harmonised/pmmo/mixin/CampfireMixin.java | 6 +++--- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java b/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java index 5aefa677..babcd41d 100644 --- a/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java +++ b/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java @@ -37,7 +37,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; -import net.minecraftforge.registries.ForgeRegistries; public class FeaturePerks { private static final CompoundTag NONE = new CompoundTag(); @@ -46,7 +45,7 @@ public class FeaturePerks { private static Attribute getAttribute(CompoundTag nbt) { return attributeCache.computeIfAbsent(nbt.getString(APIUtils.ATTRIBUTE), - name -> ForgeRegistries.ATTRIBUTES.getValue(new ResourceLocation(name))); + name -> BuiltInRegistries.ATTRIBUTE.get(new ResourceLocation(name))); } public static final Perk ATTRIBUTE = Perk.begin() @@ -105,7 +104,7 @@ private static Attribute getAttribute(CompoundTag nbt) { public static BiFunction EFFECT_SETTER = (player, nbt) -> { MobEffect effect; - if ((effect = ForgeRegistries.MOB_EFFECTS.getValue(new ResourceLocation(nbt.getString("effect")))) != null) { + if ((effect = BuiltInRegistries.MOB_EFFECT.get(new ResourceLocation(nbt.getString("effect")))) != null) { int skillLevel = nbt.getInt(APIUtils.SKILL_LEVEL); int configDuration = nbt.getInt(APIUtils.DURATION); double perLevel = nbt.getDouble(APIUtils.PER_LEVEL); @@ -138,7 +137,7 @@ private static Attribute getAttribute(CompoundTag nbt) { .setTick((player, nbt, ticks) -> EFFECT_SETTER.apply(player, nbt)) .setDescription(LangProvider.PERK_EFFECT_DESC.asComponent()) .setStatus((player, nbt) -> List.of( - LangProvider.PERK_EFFECT_STATUS_1.asComponent(Component.translatable(ForgeRegistries.MOB_EFFECTS.getValue(new ResourceLocation(nbt.getString("effect"))).getDescriptionId())), + LangProvider.PERK_EFFECT_STATUS_1.asComponent(Component.translatable(BuiltInRegistries.MOB_EFFECT.get(new ResourceLocation(nbt.getString("effect"))).getDescriptionId())), LangProvider.PERK_EFFECT_STATUS_2.asComponent(nbt.getInt(APIUtils.MODIFIER), (nbt.getInt(APIUtils.DURATION) * nbt.getDouble(APIUtils.PER_LEVEL) * nbt.getInt(APIUtils.SKILL_LEVEL))/20))) .build(); @@ -226,12 +225,12 @@ else if (perkApplicableDamageType.endsWith(":*") && perkApplicableDamageType.sub .addConditions((player, nbt) -> { List type = nbt.getList(APPLICABLE_TO, Tag.TAG_STRING).stream().map(tag -> tag.getAsString()).toList(); for (String key : type) { - if (key.startsWith("#") && ForgeRegistries.ITEMS.tags() - .getTag(TagKey.create(ForgeRegistries.ITEMS.getRegistryKey(), new ResourceLocation(key.substring(1)))) + if (key.startsWith("#") && BuiltInRegistries.ITEM + .getTag(TagKey.create(Registries.ITEM, new ResourceLocation(key.substring(1)))) .stream().anyMatch(item -> player.getMainHandItem().getItem().equals(item))) { return true; } - else if (key.endsWith(":*") && ForgeRegistries.ITEMS.getValues().stream() + else if (key.endsWith(":*") && BuiltInRegistries.ITEM.stream() .anyMatch(item -> player.getMainHandItem().getItem().equals(item))) { return true; } @@ -261,7 +260,7 @@ else if (key.equals(RegistryUtil.getId(player.getMainHandItem()).toString())) List lines = new ArrayList<>(); MutableComponent line1 = LangProvider.PERK_DAMAGE_BOOST_STATUS_1.asComponent(); for (Tag entry : nbt.getList(APPLICABLE_TO, Tag.TAG_STRING)) { - Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(entry.getAsString())); + Item item = BuiltInRegistries.ITEM.get(new ResourceLocation(entry.getAsString())); line1.append(item.equals(Items.AIR) ? Component.literal(entry.getAsString()) : item.getDescription()); line1.append(Component.literal(", ")); } diff --git a/src/main/java/harmonised/pmmo/events/EventHandler.java b/src/main/java/harmonised/pmmo/events/EventHandler.java index 224e528c..31e6ab9f 100644 --- a/src/main/java/harmonised/pmmo/events/EventHandler.java +++ b/src/main/java/harmonised/pmmo/events/EventHandler.java @@ -23,10 +23,7 @@ import net.neoforged.neoforge.event.entity.EntityMountEvent; import net.neoforged.neoforge.event.entity.EntityTravelToDimensionEvent; import net.neoforged.neoforge.event.entity.living.*; -import net.neoforged.neoforge.event.entity.player.AnvilRepairEvent; -import net.neoforged.neoforge.event.entity.player.ItemFishedEvent; -import net.neoforged.neoforge.event.entity.player.PlayerEvent; -import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.event.entity.player.*; import net.neoforged.neoforge.event.level.BlockEvent; import net.neoforged.neoforge.event.level.ExplosionEvent; import net.neoforged.neoforge.event.level.PistonEvent; diff --git a/src/main/java/harmonised/pmmo/events/impl/TradeHandler.java b/src/main/java/harmonised/pmmo/events/impl/TradeHandler.java index f21c37f9..4322c8c3 100644 --- a/src/main/java/harmonised/pmmo/events/impl/TradeHandler.java +++ b/src/main/java/harmonised/pmmo/events/impl/TradeHandler.java @@ -7,7 +7,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.event.entity.player.TradeWithVillagerEvent; +import net.neoforged.neoforge.event.entity.player.TradeWithVillagerEvent; import java.util.List; import java.util.Map; diff --git a/src/main/java/harmonised/pmmo/mixin/CampfireMixin.java b/src/main/java/harmonised/pmmo/mixin/CampfireMixin.java index 9a446947..bcf42f7c 100644 --- a/src/main/java/harmonised/pmmo/mixin/CampfireMixin.java +++ b/src/main/java/harmonised/pmmo/mixin/CampfireMixin.java @@ -7,7 +7,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.CampfireBlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.MinecraftForge; +import net.neoforged.neoforge.common.NeoForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,7 +21,7 @@ public class CampfireMixin { target = "Lnet/minecraft/world/Containers;dropItemStack(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V"), method = "cookTick(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/CampfireBlockEntity;)V", locals = LocalCapture.CAPTURE_FAILHARD) - private static void projectmmo$handleCampfireCook(Level pLevel, BlockPos pPos, BlockState pState, CampfireBlockEntity pBlockEntity, CallbackInfo ci, boolean flag, int i, ItemStack itemstack, int j, Container container, ItemStack itemstack1) { - MinecraftForge.EVENT_BUS.post(new FurnaceBurnEvent(itemstack1, pLevel, pPos)); + private static void projectmmo$handleCampfireCook(Level p_155307_, BlockPos p_155308_, BlockState p_155309_, CampfireBlockEntity p_155310_, CallbackInfo ci, boolean flag, int i, ItemStack itemstack, Container container, ItemStack itemstack1) { + NeoForge.EVENT_BUS.post(new FurnaceBurnEvent(itemstack1, p_155307_, p_155308_)); } }