From 081e48b208cfdcfc2c3a6651c123ea4a63118191 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 12 Nov 2018 01:29:33 +0100 Subject: [PATCH] changed aura types to be an expandable system --- .../de/ellpeck/naturesaura/NaturesAura.java | 2 +- .../naturesaura/api/NaturesAuraAPI.java | 22 ++++++++-- .../naturesaura/api/aura/AuraType.java | 27 ------------ .../api/aura/chunk/IAuraChunk.java | 4 +- .../api/aura/chunk/IDrainSpotEffect.java | 4 +- .../aura/container/BasicAuraContainer.java | 8 ++-- .../api/aura/container/IAuraContainer.java | 4 +- .../api/aura/container/ItemAuraContainer.java | 8 ++-- .../aura/container/NaturalAuraContainer.java | 4 +- .../api/aura/type/BasicAuraType.java | 39 ++++++++++++++++++ .../naturesaura/api/aura/type/IAuraType.java | 21 ++++++++++ .../naturesaura/aura/chunk/AuraChunk.java | 8 ++-- .../aura/chunk/effect/GrassDieEffect.java | 7 ++-- .../aura/chunk/effect/PlantBoostEffect.java | 7 ++-- .../aura/chunk/effect/ReplenishingEffect.java | 6 +-- .../blocks/tiles/TileEntityAncientLeaves.java | 4 +- .../tiles/TileEntityFlowerGenerator.java | 3 +- .../blocks/tiles/TileEntityNatureAltar.java | 7 ++-- .../naturesaura/events/ClientEvents.java | 4 +- .../naturesaura/events/CommonEvents.java | 4 +- .../naturesaura/items/ItemAuraBottle.java | 38 ++++++++++------- .../naturesaura/recipes/ModRecipes.java | 8 ++-- .../advancements/aura_bottle_end.json | 4 +- .../advancements/aura_bottle_nether.json | 4 +- .../advancements/aura_bottle_overworld.json | 4 +- .../assets/naturesaura/lang/en_US.lang | 8 ++-- .../naturesaura/models/item/aura_bottle.json | 25 ++--------- .../models/item/aura_bottle_end.json | 6 --- .../models/item/aura_bottle_nether.json | 6 --- .../models/item/aura_bottle_other.json | 6 --- .../en_us/entries/collecting/aura_bottle.json | 4 +- .../naturesaura/recipes/flower_generator.json | 2 +- .../naturesaura/recipes/potion_generator.json | 2 +- .../textures/items/aura_bottle.png | Bin 0 -> 272 bytes .../textures/items/aura_bottle_end.png | Bin 301 -> 0 bytes .../textures/items/aura_bottle_nether.png | Bin 316 -> 0 bytes .../textures/items/aura_bottle_other.png | Bin 310 -> 0 bytes .../textures/items/aura_bottle_overlay.png | Bin 0 -> 256 bytes .../textures/items/aura_bottle_overworld.png | Bin 294 -> 0 bytes 39 files changed, 164 insertions(+), 146 deletions(-) delete mode 100644 src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java create mode 100644 src/main/java/de/ellpeck/naturesaura/api/aura/type/BasicAuraType.java create mode 100644 src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java delete mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json delete mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json delete mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json create mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle.png delete mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png delete mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png delete mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png create mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_overlay.png delete mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index b3533b1e..44f37fa8 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -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@"; diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java index afbe36d6..2c8f377d 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -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 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 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 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 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 diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java b/src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java deleted file mode 100644 index 2f0c7932..00000000 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java +++ /dev/null @@ -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; - } - } -} diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java index a15d9947..9380b87f 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java @@ -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 drainSpots = new HashMap<>(); private final List 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; } diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java index fc81c9d7..f9697be1 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java @@ -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; } } diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java index 2f48ccb0..6007e9b7 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java @@ -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; } } diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java index 5e50386e..7cb7d410 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java @@ -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 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; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java index 45c9093d..dbf4acfc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java @@ -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; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java index 9d348523..7b86e021 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java @@ -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; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index db8e82ed..e9a0a6d9 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -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); diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index f7d98e0c..99efa64a 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -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()); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index b5898395..52fee0e0 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -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 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)); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java index 072da149..58690afb 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -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 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; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 700127f0..896a6ff1 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -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), diff --git a/src/main/resources/assets/naturesaura/advancements/aura_bottle_end.json b/src/main/resources/assets/naturesaura/advancements/aura_bottle_end.json index 1d4880ce..f6770ef4 100644 --- a/src/main/resources/assets/naturesaura/advancements/aura_bottle_end.json +++ b/src/main/resources/assets/naturesaura/advancements/aura_bottle_end.json @@ -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\"}" } ] } diff --git a/src/main/resources/assets/naturesaura/advancements/aura_bottle_nether.json b/src/main/resources/assets/naturesaura/advancements/aura_bottle_nether.json index 76f0745c..a166d3ab 100644 --- a/src/main/resources/assets/naturesaura/advancements/aura_bottle_nether.json +++ b/src/main/resources/assets/naturesaura/advancements/aura_bottle_nether.json @@ -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\"}" } ] } diff --git a/src/main/resources/assets/naturesaura/advancements/aura_bottle_overworld.json b/src/main/resources/assets/naturesaura/advancements/aura_bottle_overworld.json index 8f824d8d..509f53b4 100644 --- a/src/main/resources/assets/naturesaura/advancements/aura_bottle_overworld.json +++ b/src/main/resources/assets/naturesaura/advancements/aura_bottle_overworld.json @@ -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\"}" } ] } diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index c58f2e76..b072bd82 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -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 diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle.json index fc0685c3..8c60a4ea 100644 --- a/src/main/resources/assets/naturesaura/models/item/aura_bottle.json +++ b/src/main/resources/assets/naturesaura/models/item/aura_bottle.json @@ -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" + } } \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json deleted file mode 100644 index e4ad0195..00000000 --- a/src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "naturesaura:items/aura_bottle_end" - } -} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json deleted file mode 100644 index a7bf0b8b..00000000 --- a/src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "naturesaura:items/aura_bottle_nether" - } -} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json deleted file mode 100644 index ada33030..00000000 --- a/src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "naturesaura:items/aura_bottle_other" - } -} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json index d1802ac2..1e1b5672 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json @@ -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." } diff --git a/src/main/resources/assets/naturesaura/recipes/flower_generator.json b/src/main/resources/assets/naturesaura/recipes/flower_generator.json index 8c9b8fef..e850d3cc 100644 --- a/src/main/resources/assets/naturesaura/recipes/flower_generator.json +++ b/src/main/resources/assets/naturesaura/recipes/flower_generator.json @@ -21,7 +21,7 @@ "type": "minecraft:item_nbt", "item": "naturesaura:aura_bottle", "nbt": { - "type": "OVERWORLD" + "stored_type": "naturesaura:overworld" } } }, diff --git a/src/main/resources/assets/naturesaura/recipes/potion_generator.json b/src/main/resources/assets/naturesaura/recipes/potion_generator.json index 8562217b..28532f6f 100644 --- a/src/main/resources/assets/naturesaura/recipes/potion_generator.json +++ b/src/main/resources/assets/naturesaura/recipes/potion_generator.json @@ -19,7 +19,7 @@ "type": "minecraft:item_nbt", "item": "naturesaura:aura_bottle", "nbt": { - "type": "NETHER" + "stored_type": "naturesaura:nether" } } }, diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle.png new file mode 100644 index 0000000000000000000000000000000000000000..9fbc512bc421d8c3998e7ef9035e0f8c05f04fa4 GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`)H9!iBKQO;J&VBk3*qMW=!#FUYlnc?<_?^^FB6dVQG&fw|l K=d#Wzp$P#0uuyjZ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png deleted file mode 100644 index b1bc5c878470f70377141595044a7192135fd907..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3nto3g#}EtuWQjWuyw*McZ@aMVfB3G||Ju0( z`RCbGe)@mr*U|!>N6t$-m=$>0lXd>DFADu*e>djM|DDCpJ<3@GT-c#RocCg(En95!h-nUu=FGdYF9 r$I$F73vUDCjHDEvsf*MSfW8XZdf|opEtfQ)(-=Hm{an^LB{Ts5+b(6V diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png deleted file mode 100644 index db1fdb3094d87d42204d6f2dc16766f01f1a8e21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3nt7fsjv*HQ$r5)Sc&&T>-*#c!|L|R_|Fv@o z^3SuW{Ph3KucZY%kDQlwFe~t~C+qxQUljVs{%*{h|2vDHdz7kh3QS0wpeDh4=;E(QM|ofzG&#^?C_7xQaX*{MA;1U4l{;j zoVGk3Mhs~jn=W^nF)ZOoPwY^5&Hr3{{~elF{r G5}E+4Y-%q6 diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png deleted file mode 100644 index 360ec68cdea16d6017898a0bb7eed241a4a61972..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 310 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3ni-xhjv*HQ$r5)Sc&&T>-*#c!|L|R_|Fv@o z^3SuW{Ph3KucZY%kDQlwFe~t~C+qxQUljVs{%*{h|2vDHdz7^NM-InlF`y0=1QqlNc21v@@oZ6W4!D^E>^Gt{7 tv63fPcD*^3U^JuldDVlH68G1BWpw0K;#}i$=rqta22WQ%mvv4FO#q(SQnLU6 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png deleted file mode 100644 index 23449358b12f36c2778174ac87943d238a9143ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3nhsAF#}EtuWQjWuyw*McZ@aMVfB3G||Ju0( z`RCbGe)@mr*U|!>N6t$-m=$>0lXd>DFADu*e>djM|DDCpJ<3@d&1N#~_2I3*+)e*XMsZq=y$8|WqmPgg&ebxsLQ09fK