2018-11-12 01:29:33 +01:00
|
|
|
package de.ellpeck.naturesaura.api.aura.type;
|
|
|
|
|
|
|
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2020-01-21 21:04:44 +01:00
|
|
|
import net.minecraft.world.IWorld;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.world.dimension.DimensionType;
|
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-05-13 14:07:33 +02:00
|
|
|
private final Set<ResourceLocation> dimensions = new HashSet<>();
|
2018-11-12 01:29:33 +01:00
|
|
|
|
2018-12-02 13:49:20 +01:00
|
|
|
public BasicAuraType(ResourceLocation name, DimensionType 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)
|
2020-05-13 14:07:33 +02:00
|
|
|
this.dimensions.add(dimension.getRegistryName());
|
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
|
2020-01-21 21:04:44 +01:00
|
|
|
public boolean isPresentInWorld(IWorld world) {
|
2020-05-13 14:07:33 +02:00
|
|
|
return this.dimensions.isEmpty() || this.dimensions.contains(world.getDimension().getType().getRegistryName());
|
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-05-13 14:07:33 +02:00
|
|
|
public void addDimensionType(ResourceLocation typeName) {
|
|
|
|
this.dimensions.add(typeName);
|
2018-12-02 13:49:20 +01:00
|
|
|
}
|
2018-11-12 01:29:33 +01:00
|
|
|
}
|