2018-11-12 01:29:33 +01:00
|
|
|
package de.ellpeck.naturesaura.api.aura.type;
|
|
|
|
|
|
|
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.resources.ResourceKey;
|
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
import net.minecraft.world.level.Level;
|
2018-11-12 01:29:33 +01:00
|
|
|
|
2018-12-02 13:49:20 +01:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2018-11-12 01:29:33 +01:00
|
|
|
public class BasicAuraType implements IAuraType {
|
|
|
|
|
|
|
|
private final ResourceLocation name;
|
|
|
|
private final int color;
|
2018-12-02 13:49:20 +01:00
|
|
|
private final int priority;
|
2020-09-22 15:19:14 +02:00
|
|
|
private final Set<ResourceLocation> dimensions = new HashSet<>();
|
2018-11-12 01:29:33 +01:00
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public BasicAuraType(ResourceLocation name, ResourceKey<Level> dimension, int color, int priority) {
|
2018-11-12 01:29:33 +01:00
|
|
|
this.name = name;
|
|
|
|
this.color = color;
|
2018-12-02 13:49:20 +01:00
|
|
|
this.priority = priority;
|
|
|
|
if (dimension != null)
|
2021-12-04 15:40:09 +01:00
|
|
|
this.dimensions.add(dimension.location());
|
2018-11-12 01:29:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public BasicAuraType register() {
|
|
|
|
NaturesAuraAPI.AURA_TYPES.put(this.name, this);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ResourceLocation getName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-12-04 15:40:09 +01:00
|
|
|
public boolean isPresentInLevel(Level level) {
|
|
|
|
return this.dimensions.isEmpty() || this.dimensions.contains(level.dimension().location());
|
2018-11-12 01:29:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-11-12 01:35:02 +01:00
|
|
|
public int getColor() {
|
2018-11-12 01:29:33 +01:00
|
|
|
return this.color;
|
|
|
|
}
|
2018-12-02 13:49:20 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getPriority() {
|
|
|
|
return this.priority;
|
|
|
|
}
|
|
|
|
|
2020-09-22 15:19:14 +02:00
|
|
|
public void addDimensionType(ResourceLocation type) {
|
2020-09-22 03:17:02 +02:00
|
|
|
this.dimensions.add(type);
|
2018-12-02 13:49:20 +01:00
|
|
|
}
|
2018-11-12 01:29:33 +01:00
|
|
|
}
|