mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Non-Plural registries
This commit is contained in:
parent
312f5a2929
commit
150ef3e497
12 changed files with 48 additions and 46 deletions
|
@ -1,29 +1,30 @@
|
||||||
package com.simibubi.create;
|
package com.simibubi.create;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
||||||
import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType;
|
import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType;
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import net.minecraftforge.registries.NewRegistryEvent;
|
import net.minecraftforge.registries.NewRegistryEvent;
|
||||||
import net.minecraftforge.registries.RegistryBuilder;
|
import net.minecraftforge.registries.RegistryBuilder;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class AllRegistries {
|
public class AllRegistries {
|
||||||
public static Supplier<IForgeRegistry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPES;
|
public static Supplier<IForgeRegistry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPE;
|
||||||
public static Supplier<IForgeRegistry<FanProcessingType>> FAN_PROCESSING_TYPES;
|
public static Supplier<IForgeRegistry<FanProcessingType>> FAN_PROCESSING_TYPE;
|
||||||
public static Supplier<IForgeRegistry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPES;
|
public static Supplier<IForgeRegistry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPE;
|
||||||
|
|
||||||
public static final class Keys {
|
public static final class Keys {
|
||||||
public static final ResourceKey<Registry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPES = key("arm_interaction_point_types");
|
public static final ResourceKey<Registry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPE = key("arm_interaction_point_type");
|
||||||
public static final ResourceKey<Registry<FanProcessingType>> FAN_PROCESSING_TYPES = key("fan_processing_types");
|
public static final ResourceKey<Registry<FanProcessingType>> FAN_PROCESSING_TYPE = key("fan_processing_type");
|
||||||
public static final ResourceKey<Registry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPES = key("item_attribute_types");
|
public static final ResourceKey<Registry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPE = key("item_attribute_type");
|
||||||
|
|
||||||
private static <T> ResourceKey<Registry<T>> key(String name) {
|
private static <T> ResourceKey<Registry<T>> key(String name) {
|
||||||
return ResourceKey.createRegistryKey(Create.asResource(name));
|
return ResourceKey.createRegistryKey(Create.asResource(name));
|
||||||
|
@ -32,16 +33,16 @@ public class AllRegistries {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerRegistries(NewRegistryEvent event) {
|
public static void registerRegistries(NewRegistryEvent event) {
|
||||||
ARM_INTERACTION_POINT_TYPES = event.create(new RegistryBuilder<ArmInteractionPointType>()
|
ARM_INTERACTION_POINT_TYPE = event.create(new RegistryBuilder<ArmInteractionPointType>()
|
||||||
.setName(Keys.ARM_INTERACTION_POINT_TYPES.location())
|
.setName(Keys.ARM_INTERACTION_POINT_TYPE.location())
|
||||||
.disableSaving());
|
|
||||||
|
|
||||||
FAN_PROCESSING_TYPES = event.create(new RegistryBuilder<FanProcessingType>()
|
|
||||||
.setName(Keys.FAN_PROCESSING_TYPES.location())
|
|
||||||
.disableSaving());
|
.disableSaving());
|
||||||
|
|
||||||
ITEM_ATTRIBUTE_TYPES = event.create(new RegistryBuilder<ItemAttributeType>()
|
FAN_PROCESSING_TYPE = event.create(new RegistryBuilder<FanProcessingType>()
|
||||||
.setName(Keys.ITEM_ATTRIBUTE_TYPES.location())
|
.setName(Keys.FAN_PROCESSING_TYPE.location())
|
||||||
|
.disableSaving());
|
||||||
|
|
||||||
|
ITEM_ATTRIBUTE_TYPE = event.create(new RegistryBuilder<ItemAttributeType>()
|
||||||
|
.setName(Keys.ITEM_ATTRIBUTE_TYPE.location())
|
||||||
.disableSaving());
|
.disableSaving());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,16 +80,16 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
||||||
nbt.putInt("InSegment", insertedAt);
|
nbt.putInt("InSegment", insertedAt);
|
||||||
nbt.putInt("Angle", angle);
|
nbt.putInt("Angle", angle);
|
||||||
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
|
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
|
||||||
|
|
||||||
if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) {
|
if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) {
|
||||||
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPES.get().getKey(processedBy);
|
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPE.get().getKey(processedBy);
|
||||||
if (key == null)
|
if (key == null)
|
||||||
throw new IllegalArgumentException("Could not get id for FanProcessingType " + processedBy + "!");
|
throw new IllegalArgumentException("Could not get id for FanProcessingType " + processedBy + "!");
|
||||||
|
|
||||||
nbt.putString("FanProcessingType", key.toString());
|
nbt.putString("FanProcessingType", key.toString());
|
||||||
nbt.putInt("FanProcessingTime", processingTime);
|
nbt.putInt("FanProcessingTime", processingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locked)
|
if (locked)
|
||||||
nbt.putBoolean("Locked", locked);
|
nbt.putBoolean("Locked", locked);
|
||||||
if (lockedExternally)
|
if (lockedExternally)
|
||||||
|
@ -108,18 +108,18 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
||||||
stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection"));
|
stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection"));
|
||||||
stack.locked = nbt.getBoolean("Locked");
|
stack.locked = nbt.getBoolean("Locked");
|
||||||
stack.lockedExternally = nbt.getBoolean("LockedExternally");
|
stack.lockedExternally = nbt.getBoolean("LockedExternally");
|
||||||
|
|
||||||
if (nbt.contains("FanProcessingType")) {
|
if (nbt.contains("FanProcessingType")) {
|
||||||
stack.processedBy = AllFanProcessingTypes.parseLegacy(nbt.getString("FanProcessingType"));
|
stack.processedBy = AllFanProcessingTypes.parseLegacy(nbt.getString("FanProcessingType"));
|
||||||
stack.processingTime = nbt.getInt("FanProcessingTime");
|
stack.processingTime = nbt.getInt("FanProcessingTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearFanProcessingData() {
|
public void clearFanProcessingData() {
|
||||||
processedBy = null;
|
processedBy = null;
|
||||||
processingTime = 0;
|
processingTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
|
||||||
public class AllFanProcessingTypes {
|
public class AllFanProcessingTypes {
|
||||||
private static final DeferredRegister<FanProcessingType> REGISTER = DeferredRegister.create(AllRegistries.Keys.FAN_PROCESSING_TYPES, Create.ID);
|
private static final DeferredRegister<FanProcessingType> REGISTER = DeferredRegister.create(AllRegistries.Keys.FAN_PROCESSING_TYPE, Create.ID);
|
||||||
|
|
||||||
public static final NoneType NONE = register("none", new NoneType());
|
public static final NoneType NONE = register("none", new NoneType());
|
||||||
public static final BlastingType BLASTING = register("blasting", new BlastingType());
|
public static final BlastingType BLASTING = register("blasting", new BlastingType());
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class FanProcessing {
|
||||||
CompoundTag processing = createData.getCompound("Processing");
|
CompoundTag processing = createData.getCompound("Processing");
|
||||||
|
|
||||||
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
|
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
|
||||||
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPES.get().getKey(type);
|
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPE.get().getKey(type);
|
||||||
if (key == null)
|
if (key == null)
|
||||||
throw new IllegalArgumentException("Could not get id for FanProcessingType " + type + "!");
|
throw new IllegalArgumentException("Could not get id for FanProcessingType " + type + "!");
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public interface FanProcessingType {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return AllFanProcessingTypes.NONE;
|
return AllFanProcessingTypes.NONE;
|
||||||
}
|
}
|
||||||
FanProcessingType type = AllRegistries.FAN_PROCESSING_TYPES.get().getValue(id);
|
FanProcessingType type = AllRegistries.FAN_PROCESSING_TYPE.get().getValue(id);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return AllFanProcessingTypes.NONE;
|
return AllFanProcessingTypes.NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.simibubi.create.content.kinetics.fan.processing;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.UnmodifiableView;
|
||||||
|
|
||||||
import com.simibubi.create.AllRegistries;
|
import com.simibubi.create.AllRegistries;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||||
|
|
||||||
import org.jetbrains.annotations.UnmodifiableView;
|
|
||||||
|
|
||||||
public class FanProcessingTypeRegistry {
|
public class FanProcessingTypeRegistry {
|
||||||
private static List<FanProcessingType> sortedTypes = null;
|
private static List<FanProcessingType> sortedTypes = null;
|
||||||
@UnmodifiableView
|
@UnmodifiableView
|
||||||
|
@ -19,7 +19,7 @@ public class FanProcessingTypeRegistry {
|
||||||
if (sortedTypes == null) {
|
if (sortedTypes == null) {
|
||||||
sortedTypes = new ReferenceArrayList<>();
|
sortedTypes = new ReferenceArrayList<>();
|
||||||
|
|
||||||
sortedTypes.addAll(AllRegistries.FAN_PROCESSING_TYPES.get().getValues());
|
sortedTypes.addAll(AllRegistries.FAN_PROCESSING_TYPE.get().getValues());
|
||||||
sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority());
|
sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority());
|
||||||
|
|
||||||
sortedTypesView = Collections.unmodifiableList(sortedTypes);
|
sortedTypesView = Collections.unmodifiableList(sortedTypes);
|
||||||
|
|
|
@ -64,7 +64,7 @@ import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
|
||||||
public class AllArmInteractionPointTypes {
|
public class AllArmInteractionPointTypes {
|
||||||
private static final DeferredRegister<ArmInteractionPointType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPES, Create.ID);
|
private static final DeferredRegister<ArmInteractionPointType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPE, Create.ID);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
register("basin", new BasinType());
|
register("basin", new BasinType());
|
||||||
|
|
|
@ -5,8 +5,8 @@ import javax.annotation.Nullable;
|
||||||
import com.simibubi.create.AllRegistries;
|
import com.simibubi.create.AllRegistries;
|
||||||
import com.simibubi.create.content.contraptions.StructureTransform;
|
import com.simibubi.create.content.contraptions.StructureTransform;
|
||||||
|
|
||||||
import net.createmod.catnip.nbt.NBTHelper;
|
|
||||||
import net.createmod.catnip.math.VecHelper;
|
import net.createmod.catnip.math.VecHelper;
|
||||||
|
import net.createmod.catnip.nbt.NBTHelper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -17,6 +17,7 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
@ -89,7 +90,8 @@ public class ArmInteractionPoint {
|
||||||
return type.canCreatePoint(level, pos, cachedState);
|
return type.canCreatePoint(level, pos, cachedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keepAlive() {}
|
public void keepAlive() {
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected IItemHandler getHandler() {
|
protected IItemHandler getHandler() {
|
||||||
|
@ -136,7 +138,7 @@ public class ArmInteractionPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CompoundTag serialize(BlockPos anchor) {
|
public final CompoundTag serialize(BlockPos anchor) {
|
||||||
ResourceLocation key = AllRegistries.ARM_INTERACTION_POINT_TYPES.get().getKey(type);
|
ResourceLocation key = AllRegistries.ARM_INTERACTION_POINT_TYPE.get().getKey(type);
|
||||||
if (key == null)
|
if (key == null)
|
||||||
throw new IllegalArgumentException("Could not get id for ArmInteractionPointType " + type + "!");
|
throw new IllegalArgumentException("Could not get id for ArmInteractionPointType " + type + "!");
|
||||||
|
|
||||||
|
@ -152,7 +154,7 @@ public class ArmInteractionPoint {
|
||||||
ResourceLocation id = ResourceLocation.tryParse(nbt.getString("Type"));
|
ResourceLocation id = ResourceLocation.tryParse(nbt.getString("Type"));
|
||||||
if (id == null)
|
if (id == null)
|
||||||
return null;
|
return null;
|
||||||
ArmInteractionPointType type = AllRegistries.ARM_INTERACTION_POINT_TYPES.get().getValue(id);
|
ArmInteractionPointType type = AllRegistries.ARM_INTERACTION_POINT_TYPE.get().getValue(id);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
BlockPos pos = NbtUtils.readBlockPos(nbt.getCompound("Pos")).offset(anchor);
|
BlockPos pos = NbtUtils.readBlockPos(nbt.getCompound("Pos")).offset(anchor);
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.UnmodifiableView;
|
||||||
|
|
||||||
import com.simibubi.create.AllRegistries;
|
import com.simibubi.create.AllRegistries;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||||
|
@ -13,8 +15,6 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import org.jetbrains.annotations.UnmodifiableView;
|
|
||||||
|
|
||||||
public abstract class ArmInteractionPointType {
|
public abstract class ArmInteractionPointType {
|
||||||
private static List<ArmInteractionPointType> sortedTypes = null;
|
private static List<ArmInteractionPointType> sortedTypes = null;
|
||||||
@UnmodifiableView
|
@UnmodifiableView
|
||||||
|
@ -29,7 +29,7 @@ public abstract class ArmInteractionPointType {
|
||||||
if (sortedTypes == null) {
|
if (sortedTypes == null) {
|
||||||
sortedTypes = new ReferenceArrayList<>();
|
sortedTypes = new ReferenceArrayList<>();
|
||||||
|
|
||||||
sortedTypes.addAll(AllRegistries.ARM_INTERACTION_POINT_TYPES.get().getValues());
|
sortedTypes.addAll(AllRegistries.ARM_INTERACTION_POINT_TYPE.get().getValues());
|
||||||
sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority());
|
sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority());
|
||||||
|
|
||||||
sortedTypesView = Collections.unmodifiableList(sortedTypes);
|
sortedTypesView = Collections.unmodifiableList(sortedTypes);
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterM
|
||||||
.plainCopy()
|
.plainCopy()
|
||||||
.append("..."));
|
.append("..."));
|
||||||
attributesOfItem.clear();
|
attributesOfItem.clear();
|
||||||
for (ItemAttributeType type : AllRegistries.ITEM_ATTRIBUTE_TYPES.get())
|
for (ItemAttributeType type : AllRegistries.ITEM_ATTRIBUTE_TYPE.get())
|
||||||
attributesOfItem.addAll(type.getAllAttributes(stack, minecraft.level));
|
attributesOfItem.addAll(type.getAllAttributes(stack, minecraft.level));
|
||||||
List<Component> options = attributesOfItem.stream()
|
List<Component> options = attributesOfItem.stream()
|
||||||
.map(a -> a.format(false))
|
.map(a -> a.format(false))
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.logistics.item.filter.attribute;
|
||||||
|
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
|
||||||
// TODO - Documentation
|
// TODO - Documentation
|
||||||
public class AllItemAttributeTypes {
|
public class AllItemAttributeTypes {
|
||||||
private static final DeferredRegister<ItemAttributeType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ITEM_ATTRIBUTE_TYPES, Create.ID);
|
private static final DeferredRegister<ItemAttributeType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ITEM_ATTRIBUTE_TYPE, Create.ID);
|
||||||
private static final RecipeWrapper RECIPE_WRAPPER = new RecipeWrapper(new ItemStackHandler(1));
|
private static final RecipeWrapper RECIPE_WRAPPER = new RecipeWrapper(new ItemStackHandler(1));
|
||||||
|
|
||||||
public static final ItemAttributeType
|
public static final ItemAttributeType
|
||||||
|
@ -72,7 +71,7 @@ public class AllItemAttributeTypes {
|
||||||
BLASTABLE = singleton("blastable", (s, w) -> testRecipe(s, w, RecipeType.BLASTING)),
|
BLASTABLE = singleton("blastable", (s, w) -> testRecipe(s, w, RecipeType.BLASTING)),
|
||||||
COMPOSTABLE = singleton("compostable", s -> ComposterBlock.COMPOSTABLES.containsKey(s.getItem())),
|
COMPOSTABLE = singleton("compostable", s -> ComposterBlock.COMPOSTABLES.containsKey(s.getItem())),
|
||||||
|
|
||||||
IN_TAG = register("in_tag", new InTagAttribute.Type()),
|
IN_TAG = register("in_tag", new InTagAttribute.Type()),
|
||||||
IN_ITEM_GROUP = register("in_item_group", new InItemGroupAttribute.Type()),
|
IN_ITEM_GROUP = register("in_item_group", new InItemGroupAttribute.Type()),
|
||||||
ADDED_BY = register("added_by", new AddedByAttribute.Type()),
|
ADDED_BY = register("added_by", new AddedByAttribute.Type()),
|
||||||
HAS_ENCHANT = register("has_enchant", new EnchantAttribute.Type()),
|
HAS_ENCHANT = register("has_enchant", new EnchantAttribute.Type()),
|
||||||
|
@ -83,7 +82,7 @@ public class AllItemAttributeTypes {
|
||||||
BOOK_AUTHOR = register("book_author", new BookAuthorAttribute.Type()),
|
BOOK_AUTHOR = register("book_author", new BookAuthorAttribute.Type()),
|
||||||
BOOK_COPY = register("book_copy", new BookCopyAttribute.Type()),
|
BOOK_COPY = register("book_copy", new BookCopyAttribute.Type()),
|
||||||
|
|
||||||
ASTRAL_AMULET = register("astral_amulet", new AstralSorceryAmuletAttribute.Type()),
|
ASTRAL_AMULET = register("astral_amulet", new AstralSorceryAmuletAttribute.Type()),
|
||||||
ASTRAL_ATTUNMENT = register("astral_attunment", new AstralSorceryAttunementAttribute.Type()),
|
ASTRAL_ATTUNMENT = register("astral_attunment", new AstralSorceryAttunementAttribute.Type()),
|
||||||
ASTRAL_CRYSTAL = register("astral_crystal", new AstralSorceryCrystalAttribute.Type()),
|
ASTRAL_CRYSTAL = register("astral_crystal", new AstralSorceryCrystalAttribute.Type()),
|
||||||
ASTRAL_PERK_GEM = register("astral_perk_gem", new AstralSorceryPerkGemAttribute.Type());
|
ASTRAL_PERK_GEM = register("astral_perk_gem", new AstralSorceryPerkGemAttribute.Type());
|
||||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
public interface ItemAttribute {
|
public interface ItemAttribute {
|
||||||
static CompoundTag saveStatic(ItemAttribute attribute) {
|
static CompoundTag saveStatic(ItemAttribute attribute) {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundTag nbt = new CompoundTag();
|
||||||
ResourceLocation id = AllRegistries.ITEM_ATTRIBUTE_TYPES.get().getKey(attribute.getType());
|
ResourceLocation id = AllRegistries.ITEM_ATTRIBUTE_TYPE.get().getKey(attribute.getType());
|
||||||
|
|
||||||
if (id == null)
|
if (id == null)
|
||||||
throw new IllegalArgumentException("Cannot get " + attribute.getType() + "as it does not exist in AllRegistries.ITEM_ATTRIBUTE_TYPES");
|
throw new IllegalArgumentException("Cannot get " + attribute.getType() + "as it does not exist in AllRegistries.ITEM_ATTRIBUTE_TYPES");
|
||||||
|
@ -42,7 +42,7 @@ public interface ItemAttribute {
|
||||||
if (id == null)
|
if (id == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ItemAttributeType type = AllRegistries.ITEM_ATTRIBUTE_TYPES.get().getValue(id);
|
ItemAttributeType type = AllRegistries.ITEM_ATTRIBUTE_TYPE.get().getValue(id);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public interface ItemAttribute {
|
||||||
|
|
||||||
static List<ItemAttribute> getAllAttributes(ItemStack stack, Level level) {
|
static List<ItemAttribute> getAllAttributes(ItemStack stack, Level level) {
|
||||||
List<ItemAttribute> attributes = new ArrayList<>();
|
List<ItemAttribute> attributes = new ArrayList<>();
|
||||||
for (ItemAttributeType type : AllRegistries.ITEM_ATTRIBUTE_TYPES.get()) {
|
for (ItemAttributeType type : AllRegistries.ITEM_ATTRIBUTE_TYPE.get()) {
|
||||||
attributes.addAll(type.getAllAttributes(stack, level));
|
attributes.addAll(type.getAllAttributes(stack, level));
|
||||||
}
|
}
|
||||||
return attributes;
|
return attributes;
|
||||||
|
|
Loading…
Add table
Reference in a new issue