Skip to content

Commit

Permalink
remove direct holder references
Browse files Browse the repository at this point in the history
address #677
  • Loading branch information
iron431 committed Nov 30, 2024
1 parent 01d4eca commit 4faee3a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.redspace.ironsspellbooks.IronsSpellbooks;
import io.redspace.ironsspellbooks.api.attribute.MagicPercentAttribute;
import io.redspace.ironsspellbooks.api.attribute.MagicRangedAttribute;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.neoforged.bus.api.IEventBus;
Expand All @@ -13,8 +12,6 @@
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.Supplier;


@EventBusSubscriber(modid = IronsSpellbooks.MODID, bus = EventBusSubscriber.Bus.MOD)
public class AttributeRegistry {
Expand Down Expand Up @@ -54,10 +51,6 @@ public static void register(IEventBus eventBus) {
public static final DeferredHolder<Attribute, Attribute> NATURE_SPELL_POWER = newPowerAttribute("nature");
public static final DeferredHolder<Attribute, Attribute> ELDRITCH_SPELL_POWER = newPowerAttribute("eldritch");

public static Holder<Attribute> holder(Supplier<Attribute> attributeSupplier) {
return Holder.direct(attributeSupplier.get());
}

@SubscribeEvent
public static void modifyEntityAttributes(EntityAttributeModificationEvent e) {
e.getTypes().forEach(entity -> ATTRIBUTES.getEntries().forEach(attribute -> e.add(entity, attribute)));
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/io/redspace/ironsspellbooks/api/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,4 @@ public static ItemStack setPotion(ItemStack itemStack, Holder<Potion> potion) {
itemStack.set(DataComponents.POTION_CONTENTS, new PotionContents(potion));
return itemStack;
}

@Deprecated
public static ItemStack setPotion(ItemStack itemStack, Potion potion) {
itemStack.set(DataComponents.POTION_CONTENTS, new PotionContents(new Holder.Direct<>(potion)));
return itemStack;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public float getSpeed() {

@Override
public Optional<Holder<SoundEvent>> getImpactSound() {
return Optional.of(Holder.direct(SoundEvents.GENERIC_EXPLODE.value()));
return Optional.of(SoundEvents.GENERIC_EXPLODE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.redspace.ironsspellbooks.util.ParticleHelper;
import net.minecraft.core.Holder;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
Expand Down Expand Up @@ -45,7 +46,7 @@ public float getSpeed() {

@Override
public Optional<Holder<SoundEvent>> getImpactSound() {
return Optional.of(Holder.direct(SoundEvents.FIREWORK_ROCKET_BLAST));
return Optional.of(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvents.FIREWORK_ROCKET_BLAST));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import io.redspace.ironsspellbooks.api.registry.SpellRegistry;
import io.redspace.ironsspellbooks.api.spells.AbstractSpell;
import io.redspace.ironsspellbooks.api.spells.ISpellContainer;
import io.redspace.ironsspellbooks.api.util.Utils;
import io.redspace.ironsspellbooks.config.ServerConfigs;
import io.redspace.ironsspellbooks.item.InkItem;
import io.redspace.ironsspellbooks.item.Scroll;
import io.redspace.ironsspellbooks.loot.SpellFilter;
import io.redspace.ironsspellbooks.registries.ItemRegistry;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
Expand All @@ -36,7 +34,6 @@
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.village.WandererTradesEvent;
import org.ietf.jgss.Oid;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -252,7 +249,7 @@ public PotionSellTrade(@Nullable Potion potion) {
duration = effect.getDuration() / (20 * 60); //1 emerald per minute of effect
}
var potionStack = new ItemStack(Items.POTION);
potionStack.set(DataComponents.POTION_CONTENTS, new PotionContents(new Holder.Direct<>(potion1)));
potionStack.set(DataComponents.POTION_CONTENTS, new PotionContents(BuiltInRegistries.POTION.wrapAsHolder(potion1)));
return new MerchantOffer(
new ItemCost(Items.EMERALD, random.nextIntBetweenInclusive(12, 16) + random.nextIntBetweenInclusive(4, 6) * amplifier + duration),
potionStack,
Expand Down

0 comments on commit 4faee3a

Please sign in to comment.