changed aura types to be an expandable system

This commit is contained in:
Ellpeck 2018-11-12 01:29:33 +01:00
parent 27217f5854
commit 081e48b208
39 changed files with 164 additions and 146 deletions

View file

@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger;
@Mod(modid = NaturesAura.MOD_ID, name = NaturesAura.MOD_NAME, version = NaturesAura.VERSION, dependencies = NaturesAura.DEPS)
public final class NaturesAura {
public static final String MOD_ID = "naturesaura";
public static final String MOD_ID = NaturesAuraAPI.MOD_ID;
public static final String PROXY_LOCATION = "de.ellpeck." + MOD_ID + ".proxy.";
public static final String MOD_NAME = "Nature's Aura";
public static final String VERSION = "@VERSION@";

View file

@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.api;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.BasicAuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.internal.StubHooks;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
@ -10,6 +12,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import org.apache.commons.lang3.mutable.MutableInt;
@ -25,18 +28,19 @@ import java.util.function.BiConsumer;
* internal mod functions not exposed to the API.
*/
public final class NaturesAuraAPI {
public static final String MOD_ID = "naturesaura";
private static IInternalHooks instance = new StubHooks();
/**
* The list of all {@link AltarRecipe} instances which are the recipes used
* by the Natural Altar. Newly created recipes are automatically added to
* this list.
* by the Natural Altar. Newly created recipes can be easily added using
* {@link AltarRecipe#register()}.
*/
public static final Map<ResourceLocation, AltarRecipe> ALTAR_RECIPES = new HashMap<>();
/**
* The list of all {@link TreeRitualRecipe} instances which are the recipes
* used in the Ritual of the Forest. Newly created recipes are automatically
* added to this list.
* used in the Ritual of the Forest. Newly created recipes can be easily
* added using {@link TreeRitualRecipe#register()}.
*/
public static final Map<ResourceLocation, TreeRitualRecipe> TREE_RITUAL_RECIPES = new HashMap<>();
/**
@ -51,6 +55,16 @@ public final class NaturesAuraAPI {
* by default, along with all blocks specified in the config file
*/
public static final Map<IBlockState, IBlockState> BOTANIST_PICKAXE_CONVERSIONS = new HashMap<>();
/**
* A map of all {@link IAuraType} instances which are types of Aura present
* in different types of worlds. {@link BasicAuraType} instances can be
* easily registered using {@link BasicAuraType#register()}.
*/
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
public static final IAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), DimensionType.OVERWORLD, 0xbef224).register();
public static final IAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), DimensionType.NETHER, 0x871c0c).register();
public static final IAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), DimensionType.THE_END, 0x302624).register();
public static final IAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0).register();
/**
* This method returns the active {@link IInternalHooks} instance which can

View file

@ -1,27 +0,0 @@
package de.ellpeck.naturesaura.api.aura;
import net.minecraft.world.World;
public enum AuraType {
OVERWORLD,
NETHER,
END,
OTHER;
public boolean isPresent(World world) {
return forWorld(world) == this;
}
public static AuraType forWorld(World world) {
switch (world.provider.getDimensionType()) {
case OVERWORLD:
return OVERWORLD;
case NETHER:
return NETHER;
case THE_END:
return END;
default:
return OTHER;
}
}
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.api.aura.chunk;
import de.ellpeck.naturesaura.api.NACapabilities;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -126,7 +126,7 @@ public interface IAuraChunk extends ICapabilityProvider, INBTSerializable<NBTTag
MutableInt getDrainSpot(BlockPos pos);
AuraType getType();
IAuraType getType();
void markDirty();
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.api.aura.chunk;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
@ -10,5 +10,5 @@ public interface IDrainSpotEffect {
void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot);
boolean appliesToType(AuraType type);
boolean appliesToType(IAuraType type);
}

View file

@ -1,15 +1,15 @@
package de.ellpeck.naturesaura.api.aura.container;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.nbt.NBTTagCompound;
public class BasicAuraContainer implements IAuraContainer {
protected final AuraType type;
protected final IAuraType type;
protected final int maxAura;
protected int aura;
public BasicAuraContainer(AuraType type, int maxAura) {
public BasicAuraContainer(IAuraType type, int maxAura) {
this.type = type;
this.maxAura = maxAura;
}
@ -48,7 +48,7 @@ public class BasicAuraContainer implements IAuraContainer {
}
@Override
public boolean isAcceptableType(AuraType type) {
public boolean isAcceptableType(IAuraType type) {
return this.type == null || this.type == type;
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.api.aura.container;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
public interface IAuraContainer {
int storeAura(int amountToStore, boolean simulate);
@ -13,5 +13,5 @@ public interface IAuraContainer {
int getAuraColor();
boolean isAcceptableType(AuraType type);
boolean isAcceptableType(IAuraType type);
}

View file

@ -1,16 +1,16 @@
package de.ellpeck.naturesaura.api.aura.container;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemAuraContainer implements IAuraContainer {
protected final ItemStack stack;
protected final AuraType type;
protected final IAuraType type;
protected final int maxAura;
public ItemAuraContainer(ItemStack stack, AuraType type, int maxAura) {
public ItemAuraContainer(ItemStack stack, IAuraType type, int maxAura) {
this.stack = stack;
this.type = type;
this.maxAura = maxAura;
@ -63,7 +63,7 @@ public class ItemAuraContainer implements IAuraContainer {
}
@Override
public boolean isAcceptableType(AuraType type) {
public boolean isAcceptableType(IAuraType type) {
return this.type == null || this.type == type;
}
}

View file

@ -1,13 +1,13 @@
package de.ellpeck.naturesaura.api.aura.container;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
public class NaturalAuraContainer extends BasicAuraContainer implements ISpotDrainable {
private final int drainAmount;
public NaturalAuraContainer(AuraType type, int aura, int drainAmount) {
public NaturalAuraContainer(IAuraType type, int aura, int drainAmount) {
super(type, aura);
this.aura = aura;
this.drainAmount = drainAmount;

View file

@ -0,0 +1,39 @@
package de.ellpeck.naturesaura.api.aura.type;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
public class BasicAuraType implements IAuraType {
private final ResourceLocation name;
private final DimensionType dimension;
private final int color;
public BasicAuraType(ResourceLocation name, DimensionType dimension, int color) {
this.name = name;
this.dimension = dimension;
this.color = color;
}
public BasicAuraType register() {
NaturesAuraAPI.AURA_TYPES.put(this.name, this);
return this;
}
@Override
public ResourceLocation getName() {
return this.name;
}
@Override
public boolean isPresentInWorld(World world) {
return world.provider.getDimensionType() == this.dimension;
}
@Override
public int getBottledColor() {
return this.color;
}
}

View file

@ -0,0 +1,21 @@
package de.ellpeck.naturesaura.api.aura.type;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public interface IAuraType {
static IAuraType forWorld(World world) {
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values())
if (type.isPresentInWorld(world))
return type;
return NaturesAuraAPI.TYPE_OTHER;
}
ResourceLocation getName();
boolean isPresentInWorld(World world);
int getBottledColor();
}

View file

@ -2,9 +2,9 @@ package de.ellpeck.naturesaura.aura.chunk;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NACapabilities;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.aura.chunk.effect.GrassDieEffect;
import de.ellpeck.naturesaura.aura.chunk.effect.PlantBoostEffect;
import de.ellpeck.naturesaura.aura.chunk.effect.ReplenishingEffect;
@ -32,12 +32,12 @@ import java.util.function.BiConsumer;
public class AuraChunk implements IAuraChunk {
private final Chunk chunk;
private final AuraType type;
private final IAuraType type;
private final Map<BlockPos, MutableInt> drainSpots = new HashMap<>();
private final List<IDrainSpotEffect> effects = new ArrayList<>();
private boolean needsSync;
public AuraChunk(Chunk chunk, AuraType type) {
public AuraChunk(Chunk chunk, IAuraType type) {
this.chunk = chunk;
this.type = type;
@ -96,7 +96,7 @@ public class AuraChunk implements IAuraChunk {
}
@Override
public AuraType getType() {
public IAuraType getType() {
return this.type;
}

View file

@ -1,8 +1,9 @@
package de.ellpeck.naturesaura.aura.chunk.effect;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
@ -52,7 +53,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
}
@Override
public boolean appliesToType(AuraType type) {
return type == AuraType.OVERWORLD;
public boolean appliesToType(IAuraType type) {
return type == NaturesAuraAPI.TYPE_OVERWORLD;
}
}

View file

@ -1,8 +1,9 @@
package de.ellpeck.naturesaura.aura.chunk.effect;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Block;
@ -54,7 +55,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
}
@Override
public boolean appliesToType(AuraType type) {
return type == AuraType.OVERWORLD;
public boolean appliesToType(IAuraType type) {
return type == NaturesAuraAPI.TYPE_OVERWORLD;
}
}

View file

@ -2,11 +2,11 @@ package de.ellpeck.naturesaura.aura.chunk.effect;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NACapabilities;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
@ -20,7 +20,6 @@ public class ReplenishingEffect implements IDrainSpotEffect {
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot) {
int amount = spot.intValue();
if (amount < 0) {
AuraType type = AuraType.forWorld(world);
List<ISpotDrainable> tiles = new ArrayList<>();
Helper.getTileEntitiesInArea(world, pos, 25, tile -> {
if (tile.hasCapability(NACapabilities.auraContainer, null)) {
@ -31,6 +30,7 @@ public class ReplenishingEffect implements IDrainSpotEffect {
}
});
if (!tiles.isEmpty()) {
IAuraType type = IAuraType.forWorld(world);
for (int i = world.rand.nextInt(6); i >= 0; i--) {
ISpotDrainable tile = tiles.get(world.rand.nextInt(tiles.size()));
if (!tile.isAcceptableType(type))
@ -49,7 +49,7 @@ public class ReplenishingEffect implements IDrainSpotEffect {
}
@Override
public boolean appliesToType(AuraType type) {
public boolean appliesToType(IAuraType type) {
return true;
}
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
import net.minecraft.nbt.NBTTagCompound;
@ -8,7 +8,7 @@ import net.minecraft.util.EnumFacing;
public class TileEntityAncientLeaves extends TileEntityImpl {
private final NaturalAuraContainer container = new NaturalAuraContainer(AuraType.OVERWORLD, 20, 5) {
private final NaturalAuraContainer container = new NaturalAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 20, 5) {
@Override
public int getAuraColor() {
return 0xc46df9;

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
@ -62,7 +61,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
int toAdd = Math.max(0, addAmount - curr.getValue());
if (toAdd > 0) {
BlockPos auraPos = IAuraChunk.getLowestSpot(this.world, this.pos, 30, this.pos);
if (AuraType.OVERWORLD.isPresent(this.world) && IAuraChunk.getAuraInArea(this.world, auraPos, 30) < 20000)
if (NaturesAuraAPI.TYPE_OVERWORLD.isPresentInWorld(this.world) && IAuraChunk.getAuraInArea(this.world, auraPos, 30) < 20000)
IAuraChunk.getAuraChunk(this.world, auraPos).storeAura(auraPos, toAdd);
else
toAdd = 0;

View file

@ -1,13 +1,12 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NACapabilities;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
@ -55,7 +54,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
@SideOnly(Side.CLIENT)
public int bobTimer;
private final BasicAuraContainer container = new BasicAuraContainer(AuraType.OVERWORLD, 5000);
private final BasicAuraContainer container = new BasicAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 5000);
public boolean structureFine;
private AltarRecipe currentRecipe;
@ -78,7 +77,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
if (this.structureFine) {
int space = this.container.storeAura(3, true);
if (space > 0 && this.container.isAcceptableType(AuraType.forWorld(this.world))) {
if (space > 0 && this.container.isAcceptableType(IAuraType.forWorld(this.world))) {
int toStore = Math.min(IAuraChunk.getAuraInArea(this.world, this.pos, 20), space);
if (toStore > 0) {
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos);

View file

@ -3,9 +3,9 @@ package de.ellpeck.naturesaura.events;
import baubles.api.BaublesApi;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NACapabilities;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.items.ModItems;
@ -61,7 +61,7 @@ public class ClientEvents {
left.add(prefix + drainSpot.intValue() + " @ " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ());
}));
left.add(prefix + "Total: " + amount.intValue() + " in " + spots.intValue() + " spots");
left.add(prefix + "Type: " + AuraType.forWorld(mc.world));
left.add(prefix + "Type: " + IAuraType.forWorld(mc.world).getName());
}
}
}

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.events;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NACapabilities;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import net.minecraft.util.ResourceLocation;
@ -24,7 +24,7 @@ public class CommonEvents {
@SubscribeEvent
public void onChunkCapsAttach(AttachCapabilitiesEvent<Chunk> event) {
Chunk chunk = event.getObject();
AuraType type = AuraType.forWorld(chunk.getWorld());
IAuraType type = IAuraType.forWorld(chunk.getWorld());
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "aura"), new AuraChunk(chunk, type));
}

View file

@ -1,8 +1,10 @@
package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
@ -18,13 +20,13 @@ import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemAuraBottle extends ItemImpl {
public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem {
public ItemAuraBottle() {
super("aura_bottle");
this.addPropertyOverride(new ResourceLocation(NaturesAura.MOD_ID, "type"),
(stack, worldIn, entityIn) -> getType(stack).ordinal());
MinecraftForge.EVENT_BUS.register(this);
}
@ -45,7 +47,7 @@ public class ItemAuraBottle extends ItemImpl {
held.shrink(1);
player.inventory.addItemStackToInventory(
setType(new ItemStack(this), AuraType.forWorld(player.world)));
setType(new ItemStack(this), IAuraType.forWorld(player.world)));
BlockPos spot = IAuraChunk.getHighestSpot(player.world, pos, 30, pos);
IAuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 200);
@ -59,7 +61,7 @@ public class ItemAuraBottle extends ItemImpl {
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) {
for (AuraType type : AuraType.values()) {
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values()) {
ItemStack stack = new ItemStack(this);
setType(stack, type);
items.add(stack);
@ -69,22 +71,28 @@ public class ItemAuraBottle extends ItemImpl {
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + "." + getType(stack).name().toLowerCase() + ".name").trim();
return I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + "." + getType(stack).getName() + ".name").trim();
}
public static AuraType getType(ItemStack stack) {
public static IAuraType getType(ItemStack stack) {
if (!stack.hasTagCompound())
return AuraType.OTHER;
String type = stack.getTagCompound().getString("type");
return NaturesAuraAPI.TYPE_OTHER;
String type = stack.getTagCompound().getString("stored_type");
if (type.isEmpty())
return AuraType.OTHER;
return AuraType.valueOf(type);
return NaturesAuraAPI.TYPE_OTHER;
return NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(type));
}
public static ItemStack setType(ItemStack stack, AuraType type) {
public static ItemStack setType(ItemStack stack, IAuraType type) {
if (!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setString("type", type.name());
stack.getTagCompound().setString("stored_type", type.getName().toString());
return stack;
}
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() {
return (stack, tintIndex) -> tintIndex > 0 ? getType(stack).getBottledColor() : 0xFFFFFF;
}
}

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.recipes;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.AuraType;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.blocks.ModBlocks;
@ -28,7 +28,7 @@ public final class ModRecipes {
new ItemStack(Blocks.STONE),
new ItemStack(ModItems.GOLD_LEAF),
new ItemStack(Items.GOLD_INGOT),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.OVERWORLD)).register();
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_OVERWORLD)).register();
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "ancient_sapling"),
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200,
new ItemStack(Blocks.SAPLING),
@ -46,7 +46,7 @@ public final class ModRecipes {
new ItemStack(Items.FIRE_CHARGE),
new ItemStack(Items.FLINT),
new ItemStack(Blocks.MAGMA),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.NETHER)).register();
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_NETHER)).register();
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "conversion_catalyst"),
new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600,
new ItemStack(Blocks.STONEBRICK, 1, 1),
@ -64,7 +64,7 @@ public final class ModRecipes {
null, 150, 40).register();
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "chorus"),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.END), new ItemStack(Items.DRAGON_BREATH),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_END), new ItemStack(Items.DRAGON_BREATH),
ModBlocks.CONVERSION_CATALYST, 350, 80).register();
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "leather"),
new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER),

View file

@ -2,7 +2,7 @@
"display": {
"icon": {
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"END\"}"
"nbt": "{\"stored_type\":\"naturesaura:end\"}"
},
"title": {
"translate": "advancement.naturesaura.aura_bottle_end"
@ -19,7 +19,7 @@
"items": [
{
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"END\"}"
"nbt": "{\"stored_type\":\"naturesaura:end\"}"
}
]
}

View file

@ -2,7 +2,7 @@
"display": {
"icon": {
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"NETHER\"}"
"nbt": "{\"stored_type\":\"naturesaura:nether\"}"
},
"title": {
"translate": "advancement.naturesaura.aura_bottle_nether"
@ -19,7 +19,7 @@
"items": [
{
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"NETHER\"}"
"nbt": "{\"stored_type\":\"naturesaura:nether\"}"
}
]
}

View file

@ -2,7 +2,7 @@
"display": {
"icon": {
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"OVERWORLD\"}"
"nbt": "{\"stored_type\":\"naturesaura:overworld\"}"
},
"title": {
"translate": "advancement.naturesaura.aura_bottle_overworld"
@ -19,7 +19,7 @@
"items": [
{
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"OVERWORLD\"}"
"nbt": "{\"stored_type\":\"naturesaura:overworld\"}"
}
]
}

View file

@ -44,10 +44,10 @@ item.naturesaura.color_changer.name=Bucket of Infinite Color
item.naturesaura.book.name=Book of Natural Aura
item.naturesaura.shockwave_creator.name=Amulet of Wrath
item.naturesaura.multiblock_maker.name=Multiblock Maker
item.naturesaura.aura_bottle.overworld.name=Bottled Sunlight
item.naturesaura.aura_bottle.nether.name=Bottled Ghosts
item.naturesaura.aura_bottle.end.name=Bottled Darkness
item.naturesaura.aura_bottle.other.name=Bottled Substance
item.naturesaura.aura_bottle.naturesaura:overworld.name=Bottled Sunlight
item.naturesaura.aura_bottle.naturesaura:nether.name=Bottled Ghosts
item.naturesaura.aura_bottle.naturesaura:end.name=Bottled Darkness
item.naturesaura.aura_bottle.naturesaura:other.name=Bottled Substance
item.naturesaura.farming_stencil.name=Farming Stencil
container.naturesaura.tree_ritual.name=Ritual of the Forest

View file

@ -1,26 +1,7 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/aura_bottle_overworld"
},
"overrides": [
{
"predicate": {
"naturesaura:type": 1
},
"model": "naturesaura:item/aura_bottle_nether"
},
{
"predicate": {
"naturesaura:type": 2
},
"model": "naturesaura:item/aura_bottle_end"
},
{
"predicate": {
"naturesaura:type": 3
},
"model": "naturesaura:item/aura_bottle_other"
"layer0": "naturesaura:items/aura_bottle",
"layer1": "naturesaura:items/aura_bottle_overlay"
}
]
}

View file

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/aura_bottle_end"
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/aura_bottle_nether"
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/aura_bottle_other"
}
}

View file

@ -1,6 +1,6 @@
{
"name": "Aura Bottling",
"icon": "naturesaura:aura_bottle{type:'OVERWORLD'}",
"icon": "naturesaura:aura_bottle{stored_type:'naturesaura:overworld'}",
"category": "collecting",
"advancement": "naturesaura:wood_stand",
"pages": [
@ -10,7 +10,7 @@
},
{
"type": "spotlight",
"item": "naturesaura:aura_bottle{type:'OVERWORLD'}",
"item": "naturesaura:aura_bottle{stored_type:'naturesaura:overworld'}",
"link_recipe": true,
"text": "Of course, based on the world that you are currently in, the type of $(aura) collected will slightly vary. For instance, in the normal world, $(aura) can be gathered in the form of sunlight, while in the Nether realm, $(aura) can be gathered in the form of ghosts."
}

View file

@ -21,7 +21,7 @@
"type": "minecraft:item_nbt",
"item": "naturesaura:aura_bottle",
"nbt": {
"type": "OVERWORLD"
"stored_type": "naturesaura:overworld"
}
}
},

View file

@ -19,7 +19,7 @@
"type": "minecraft:item_nbt",
"item": "naturesaura:aura_bottle",
"nbt": {
"type": "NETHER"
"stored_type": "naturesaura:nether"
}
}
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B