mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
allow custom types to imitate existing types so that passive effects don't have to be copied
This commit is contained in:
parent
ca7b37b087
commit
5873bd99e8
7 changed files with 12 additions and 6 deletions
|
@ -42,7 +42,7 @@ public final class NaturesAuraAPI {
|
|||
|
||||
public static final String MOD_ID = "naturesaura";
|
||||
public static final String API_ID = MOD_ID + "api";
|
||||
public static final String VERSION = "8";
|
||||
public static final String VERSION = "9";
|
||||
|
||||
/**
|
||||
* The list of all {@link AltarRecipe} instances which are the recipes used
|
||||
|
|
|
@ -49,7 +49,7 @@ public class BasicAuraContainer implements IAuraContainer {
|
|||
|
||||
@Override
|
||||
public boolean isAcceptableType(IAuraType type) {
|
||||
return this.type == null || this.type == type;
|
||||
return this.type == null || this.type.isSimilar(type);
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound compound) {
|
||||
|
|
|
@ -21,4 +21,8 @@ public interface IAuraType {
|
|||
int getColor();
|
||||
|
||||
int getPriority();
|
||||
|
||||
default boolean isSimilar(IAuraType type) {
|
||||
return this == type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
|
@ -32,7 +33,7 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
|||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
if (!world.isRemote && NaturesAuraAPI.TYPE_OVERWORLD.isPresentInWorld(world)
|
||||
if (!world.isRemote && IAuraType.forWorld(world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
||||
&& world.getBlockState(pos).getBlock() instanceof BlockSapling) {
|
||||
Helper.getTileEntitiesInArea(world, pos, 10, tile -> {
|
||||
if (!(tile instanceof TileEntityOakGenerator))
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
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.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
|
@ -53,7 +54,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
|||
int addAmount = 25000;
|
||||
int toAdd = Math.max(0, addAmount - curr.getValue() * 100);
|
||||
if (toAdd > 0) {
|
||||
if (NaturesAuraAPI.TYPE_OVERWORLD.isPresentInWorld(this.world) && this.canGenerateRightNow(30, toAdd)) {
|
||||
if (IAuraType.forWorld(this.world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) && this.canGenerateRightNow(30, toAdd)) {
|
||||
int remain = toAdd;
|
||||
while (remain > 0) {
|
||||
BlockPos spot = IAuraChunk.getLowestSpot(this.world, this.pos, 30, this.pos);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
|||
|
||||
@Override
|
||||
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||
return ModConfig.enabledFeatures.grassDieEffect && type == NaturesAuraAPI.TYPE_OVERWORLD;
|
||||
return ModConfig.enabledFeatures.grassDieEffect && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,7 +90,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
|
||||
@Override
|
||||
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||
return ModConfig.enabledFeatures.plantBoostEffect && type == NaturesAuraAPI.TYPE_OVERWORLD;
|
||||
return ModConfig.enabledFeatures.plantBoostEffect && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue