mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
add the concept of aura types and make some stuff inaccessible in the nether and the end
This commit is contained in:
parent
3ba7397005
commit
b34c5b482b
17 changed files with 110 additions and 17 deletions
27
src/main/java/de/ellpeck/naturesaura/aura/AuraType.java
Normal file
27
src/main/java/de/ellpeck/naturesaura/aura/AuraType.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package de.ellpeck.naturesaura.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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.aura.chunk;
|
|||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.chunk.effect.GrassDieEffect;
|
||||
import de.ellpeck.naturesaura.aura.chunk.effect.IDrainSpotEffect;
|
||||
|
@ -36,15 +37,23 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
public static final int DEFAULT_AURA = 10000;
|
||||
|
||||
private final Chunk chunk;
|
||||
private final AuraType type;
|
||||
private final Map<BlockPos, MutableInt> drainSpots = new HashMap<>();
|
||||
private final List<IDrainSpotEffect> effects = new ArrayList<>();
|
||||
private boolean needsSync;
|
||||
|
||||
public AuraChunk(Chunk chunk) {
|
||||
public AuraChunk(Chunk chunk, AuraType type) {
|
||||
this.chunk = chunk;
|
||||
this.effects.add(new ReplenishingEffect());
|
||||
this.effects.add(new GrassDieEffect());
|
||||
this.effects.add(new PlantBoostEffect());
|
||||
this.type = type;
|
||||
|
||||
this.addEffect(new ReplenishingEffect());
|
||||
this.addEffect(new GrassDieEffect());
|
||||
this.addEffect(new PlantBoostEffect());
|
||||
}
|
||||
|
||||
public void addEffect(IDrainSpotEffect effect) {
|
||||
if (effect.appliesToType(this.type))
|
||||
this.effects.add(effect);
|
||||
}
|
||||
|
||||
public static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, MutableInt> consumer) {
|
||||
|
@ -149,6 +158,10 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
this.drainSpots.putAll(spots);
|
||||
}
|
||||
|
||||
public AuraType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
this.needsSync = true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.aura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.block.*;
|
||||
|
@ -49,4 +50,9 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesToType(AuraType type) {
|
||||
return type == AuraType.OVERWORLD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.aura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -10,4 +11,5 @@ public interface IDrainSpotEffect {
|
|||
|
||||
void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot);
|
||||
|
||||
boolean appliesToType(AuraType type);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.aura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
|
@ -51,4 +52,9 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesToType(AuraType type) {
|
||||
return type == AuraType.OVERWORLD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.naturesaura.aura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.aura.chunk.ISpotDrainable;
|
||||
|
@ -19,6 +19,7 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
public void update(World world, Chunk chunk, AuraChunk 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(Capabilities.auraContainer, null)) {
|
||||
|
@ -31,7 +32,11 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
if (!tiles.isEmpty()) {
|
||||
for (int i = world.rand.nextInt(6); i >= 0; i--) {
|
||||
ISpotDrainable tile = tiles.get(world.rand.nextInt(tiles.size()));
|
||||
if (!tile.isAcceptableType(type))
|
||||
continue;
|
||||
int drained = tile.drainAuraPassively(-amount, false);
|
||||
if (drained <= 0)
|
||||
continue;
|
||||
auraChunk.storeAura(pos, drained);
|
||||
amount += drained;
|
||||
if (amount >= drained) {
|
||||
|
@ -41,4 +46,9 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesToType(AuraType type) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package de.ellpeck.naturesaura.aura.container;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class BasicAuraContainer implements IAuraContainer {
|
||||
|
||||
protected final AuraType type;
|
||||
protected final int maxAura;
|
||||
protected int aura;
|
||||
|
||||
public BasicAuraContainer(int maxAura) {
|
||||
public BasicAuraContainer(AuraType type, int maxAura) {
|
||||
this.type = type;
|
||||
this.maxAura = maxAura;
|
||||
}
|
||||
|
||||
|
@ -44,6 +47,11 @@ public class BasicAuraContainer implements IAuraContainer {
|
|||
return 0x1E891E;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptableType(AuraType type) {
|
||||
return this.type == null || this.type == type;
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("aura", this.aura);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.ellpeck.naturesaura.aura.container;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
|
||||
public interface IAuraContainer {
|
||||
int storeAura(int amountToStore, boolean simulate);
|
||||
|
||||
|
@ -10,4 +12,6 @@ public interface IAuraContainer {
|
|||
int getMaxAura();
|
||||
|
||||
int getAuraColor();
|
||||
|
||||
boolean isAcceptableType(AuraType type);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
package de.ellpeck.naturesaura.aura.container;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
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 int maxAura;
|
||||
|
||||
public ItemAuraContainer(ItemStack stack, int maxAura) {
|
||||
public ItemAuraContainer(ItemStack stack, AuraType type, int maxAura) {
|
||||
this.stack = stack;
|
||||
this.type = type;
|
||||
this.maxAura = maxAura;
|
||||
}
|
||||
|
||||
|
@ -58,4 +61,9 @@ public class ItemAuraContainer implements IAuraContainer {
|
|||
public int getAuraColor() {
|
||||
return 0x42a6bc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptableType(AuraType type) {
|
||||
return this.type == null || this.type == type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package de.ellpeck.naturesaura.aura.container;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.chunk.ISpotDrainable;
|
||||
|
||||
public class NaturalAuraContainer extends BasicAuraContainer implements ISpotDrainable {
|
||||
|
||||
private final int drainAmount;
|
||||
|
||||
public NaturalAuraContainer(int aura, int drainAmount) {
|
||||
super(aura);
|
||||
public NaturalAuraContainer(AuraType type, int aura, int drainAmount) {
|
||||
super(type, aura);
|
||||
this.aura = aura;
|
||||
this.drainAmount = drainAmount;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.container.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.container.NaturalAuraContainer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -7,7 +8,7 @@ import net.minecraft.util.EnumFacing;
|
|||
|
||||
public class TileEntityAncientLeaves extends TileEntityImpl {
|
||||
|
||||
private final NaturalAuraContainer container = new NaturalAuraContainer(20, 5) {
|
||||
private final NaturalAuraContainer container = new NaturalAuraContainer(AuraType.OVERWORLD, 20, 5) {
|
||||
@Override
|
||||
public int getAuraColor() {
|
||||
return 0xc46df9;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||
|
@ -62,7 +63,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
|||
int toAdd = Math.max(0, addAmount - curr.getValue());
|
||||
if (toAdd > 0) {
|
||||
BlockPos auraPos = AuraChunk.getLowestSpot(this.world, this.pos, 30, this.pos);
|
||||
if (AuraChunk.getAuraInArea(this.world, auraPos, 30) < 20000)
|
||||
if (AuraType.OVERWORLD.isPresent(this.world) && AuraChunk.getAuraInArea(this.world, auraPos, 30) < 20000)
|
||||
AuraChunk.getAuraChunk(this.world, auraPos).storeAura(auraPos, toAdd);
|
||||
else
|
||||
toAdd = 0;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.aura.container.BasicAuraContainer;
|
||||
|
@ -47,7 +48,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
}
|
||||
};
|
||||
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(5000);
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(AuraType.OVERWORLD, 5000);
|
||||
public boolean structureFine;
|
||||
|
||||
private AltarRecipe currentRecipe;
|
||||
|
@ -70,7 +71,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
|
||||
if (this.structureFine) {
|
||||
int space = this.container.storeAura(3, true);
|
||||
if (space > 0) {
|
||||
if (space > 0 && this.container.isAcceptableType(AuraType.forWorld(this.world))) {
|
||||
int toStore = Math.min(AuraChunk.getAuraInArea(this.world, this.pos, 20), space);
|
||||
if (toStore > 0) {
|
||||
BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos);
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.events;
|
|||
|
||||
import baubles.api.BaublesApi;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.aura.container.IAuraContainer;
|
||||
|
@ -60,6 +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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.events;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.AuraType;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
|
@ -21,7 +22,9 @@ public class CommonEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onChunkCapsAttach(AttachCapabilitiesEvent<Chunk> event) {
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "aura"), new AuraChunk(event.getObject()));
|
||||
Chunk chunk = event.getObject();
|
||||
AuraType type = AuraType.forWorld(chunk.getWorld());
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "aura"), new AuraChunk(chunk, type));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
|
|||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
return new ICapabilityProvider() {
|
||||
private final ItemAuraContainer container = new ItemAuraContainer(stack, 4000);
|
||||
private final ItemAuraContainer container = new ItemAuraContainer(stack, null, 4000);
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
"pages": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Contrary to popular belief, $(aura) isn't stored in single, floating $(italic)nodes$(), but rather, it is present everywhere in the world.$(br)While touching it is impossible, making use of its powers certainly is not. When $(aura) is used right, it can assist in the production of materials, the creation of new ideas and the harnessing of the world and its components."
|
||||
"text": "Contrary to popular belief, $(aura) isn't stored in single, floating $(italic)nodes$(), but rather, it is present everywhere in the world.$(br)While touching it is impossible, making use of its powers certainly is not. When $(aura) is used right, it can assist in the $(thing)production$() of materials, the $(thing)creation$() of new ideas and the $(thing)harnessing$() of the world and its components."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "However, it isn't always as easy as that. Making use of it wrongly, specifically draining it completely from an area, will face the culprit with diminishing returns.$(br)So while $(aura) is plentiful and useful, abusing it would certainly be ill-advised."
|
||||
"text": "However, it isn't always as easy as that. Making use of it wrongly, specifically $(thing)draining$() it completely from an area, will face the culprit with diminishing returns.$(br)So while $(aura) is plentiful and useful, abusing it would certainly be ill-advised.$(p)An additional thing to note is that, based on the world you are in - specifically, the $(item)dimension$(), different types of $(aura) will be present, making some mechanics work unlike expected."
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue