Skip to content

Commit

Permalink
fix porting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Caltinor committed Dec 16, 2023
1 parent 1d3fd0b commit 1a4a7fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()
Expand Down Expand Up @@ -105,7 +104,7 @@ private static Attribute getAttribute(CompoundTag nbt) {

public static BiFunction<Player, CompoundTag, CompoundTag> 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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -226,12 +225,12 @@ else if (perkApplicableDamageType.endsWith(":*") && perkApplicableDamageType.sub
.addConditions((player, nbt) -> {
List<String> 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;
}
Expand Down Expand Up @@ -261,7 +260,7 @@ else if (key.equals(RegistryUtil.getId(player.getMainHandItem()).toString()))
List<MutableComponent> 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(", "));
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/harmonised/pmmo/events/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/harmonised/pmmo/mixin/CampfireMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_));
}
}

0 comments on commit 1a4a7fb

Please sign in to comment.