Call markDirty properly in a bunch of places, notably when mana changes. Encapsulate mana in magical flowers

This commit is contained in:
Vincent Lee committed 2019-11-11 12:45:49 -06:00
1 parent 886e8b0bcc
commit 0898173bb2
39 files changed
+111 -97

No files matched your search

@@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@@ -42,7 +43,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
private static final String TAG_POOL_Y = "poolY";
private static final String TAG_POOL_Z = "poolZ";
public int mana;
private int mana;
public int redstoneSignal = 0;
@@ -104,7 +105,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
if(getWorld().isBlockLoaded(cachedPoolCoordinates)) {
needsNew = true;
TileEntity tileAt = getWorld().getTileEntity(cachedPoolCoordinates);
if(tileAt != null && tileAt instanceof IManaPool && !tileAt.isRemoved()) {
if(tileAt instanceof IManaPool && !tileAt.isRemoved()) {
linkedPool = tileAt;
needsNew = false;
}
@@ -113,7 +114,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
}
} else {
TileEntity tileAt = getWorld().getTileEntity(linkedPool.getPos());
if(tileAt != null && tileAt instanceof IManaPool)
if(tileAt instanceof IManaPool)
linkedPool = tileAt;
}
@@ -125,14 +126,22 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
sizeLastCheck = size;
}
}
markDirty();
}
public void linkToForcefully(TileEntity pool) {
linkedPool = pool;
markDirty();
}
public int getMana() {
return mana;
}
public void addMana(int mana) {
this.mana = Math.min(getMaxMana(), this.mana + mana);
this.mana = MathHelper.clamp(this.mana + mana, 0, getMaxMana());
markDirty();
}
@Override
@@ -50,7 +50,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
private static final String TAG_COLLECTOR_Z = "collectorZ";
private static final String TAG_PASSIVE_DECAY_TICKS = "passiveDecayTicks";
protected int mana;
private int mana;
public int redstoneSignal = 0;
@@ -97,7 +97,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
}
if(getWorld().isRemote) {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
double particleChance = 1F - (double) getMana() / (double) getMaxMana() / 3.5F;
Color color = new Color(getColor());
if(Math.random() > particleChance) {
Vec3d offset = getWorld().getBlockState(getPos()).getOffset(getWorld(), getPos());
@@ -161,15 +161,16 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
}
public void addMana(int mana) {
this.mana = Math.min(getMaxMana(), this.mana + mana);
this.mana = Math.min(getMaxMana(), this.getMana() + mana);
markDirty();
}
public void emptyManaIntoCollector() {
if(linkedCollector != null && isValidBinding()) {
IManaCollector collector = (IManaCollector) linkedCollector;
if(!collector.isFull() && mana > 0) {
int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana());
mana -= manaval;
if(!collector.isFull() && getMana() > 0) {
int manaval = Math.min(getMana(), collector.getMaxMana() - collector.getCurrentMana());
mana = getMana() - manaval;
collector.recieveMana(manaval);
}
}
@@ -228,7 +229,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
if(!player.world.isRemote)
sync();
knownMana = mana;
knownMana = getMana();
SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT);
if(evt != null)
player.playSound(evt, 0.1F, 1F);
@@ -260,7 +261,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
@Override
public void writeToPacketNBT(CompoundNBT cmp) {
super.writeToPacketNBT(cmp);
cmp.putInt(TAG_MANA, mana);
cmp.putInt(TAG_MANA, getMana());
cmp.putInt(TAG_TICKS_EXISTED, ticksExisted);
cmp.putInt(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks);
@@ -326,4 +327,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
return !isPassiveFlower();
}
public int getMana() {
return mana;
}
}
@@ -143,6 +143,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
public void tickFlower() {
ticksExisted++;
// todo 1.14 this isn't being markDirtied, but do we even want to keep this field around?
}
@Override
@@ -65,9 +65,9 @@ public class SubTileAgricarnation extends TileEntityFunctionalFlower {
if(getWorld().isAirBlock(pos))
continue;
if(isPlant(pos) && mana > 5) {
if(isPlant(pos) && getMana() > 5) {
Block block = getWorld().getBlockState(pos).getBlock();
mana -= 5;
addMana(-5);
getWorld().getPendingBlockTicks().scheduleTick(pos, block, 1);
if(ConfigHandler.COMMON.blockBreakParticles.get())
getWorld().playEvent(2005, pos, 6 + getWorld().rand.nextInt(4));
@@ -67,13 +67,13 @@ public class SubTileBellethorn extends TileEntityFunctionalFlower {
List<LivingEntity> entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getPos().add(-range, -range, -range), getPos().add(range + 1, range + 1, range + 1)), getSelector()::test);
for(LivingEntity entity : entities) {
if(entity.hurtTime == 0 && mana >= manaToUse) {
if(entity.hurtTime == 0 && getMana() >= manaToUse) {
int dmg = 4;
if(entity instanceof WitchEntity)
dmg = 20;
entity.attackEntityFrom(DamageSource.MAGIC, dmg);
mana -= manaToUse;
addMana(-manaToUse);
break;
}
}
@@ -54,8 +54,8 @@ public class SubTileBubbell extends TileEntityFunctionalFlower {
if(ticksExisted % 200 == 0)
sync();
if(mana > COST_PER_TICK) {
mana -= COST_PER_TICK;
if(getMana() > COST_PER_TICK) {
addMana(-COST_PER_TICK);
if(ticksExisted % 10 == 0 && range < getRange())
range++;
@@ -76,7 +76,7 @@ public class SubTileBubbell extends TileEntityFunctionalFlower {
public static boolean isValidBubbell(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof SubTileBubbell) {
return ((SubTileBubbell) tile).mana > COST_PER_TICK;
return ((SubTileBubbell) tile).getMana() > COST_PER_TICK;
}
return false;
@@ -50,7 +50,7 @@ public class SubTileClayconia extends TileEntityFunctionalFlower {
super.tickFlower();
if(!getWorld().isRemote && ticksExisted % 5 == 0) {
if(mana >= COST) {
if(getMana() >= COST) {
BlockPos coords = getCoordsToPut();
if(coords != null) {
getWorld().removeBlock(coords, false);
@@ -58,7 +58,7 @@ public class SubTileClayconia extends TileEntityFunctionalFlower {
getWorld().playEvent(2001, coords, Block.getStateId(Blocks.SAND.getDefaultState()));
ItemEntity item = new ItemEntity(getWorld(), coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, new ItemStack(Items.CLAY_BALL));
getWorld().addEntity(item);
mana -= COST;
addMana(-COST);
}
}
}
@@ -57,9 +57,9 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower {
world.addParticle(data, getPos().getX() + Math.random(), getPos().getY() + Math.random(), getPos().getZ() + Math.random(), orientation.getXOffset() * 0.1F, orientation.getYOffset() * 0.1F, orientation.getZOffset() * 0.1F);
}
if(windTicks == 0 && mana > 0) {
if(windTicks == 0 && getMana() > 0) {
windTicks = 20;
mana--;
addMana(-1);
}
if(windTicks > 0 && redstoneSignal == 0) {
@@ -73,34 +73,34 @@ public class SubTileExoflame extends TileEntityFunctionalFlower {
AbstractCookingRecipe recipe = p.getFirst();
boolean canSmelt = p.getSecond();
if(canSmelt && mana > 2) {
if(canSmelt && getMana() > 2) {
if(furnace.burnTime < 2) {
if(furnace.burnTime == 0)
getWorld().setBlockState(pos, state.with(BlockStateProperties.LIT, true));
furnace.burnTime = 200;
mana = Math.max(0, mana - COST);
addMana(-COST);
}
if(ticksExisted % 2 == 0)
furnace.cookTime = Math.min(recipe.getCookTime() - 1, furnace.cookTime + 1);
did = true;
if(mana <= 0)
if(getMana() <= 0)
break;
}
} else if(tile instanceof IExoflameHeatable) {
IExoflameHeatable heatable = (IExoflameHeatable) tile;
if(heatable.canSmelt() && mana > 2) {
if(heatable.canSmelt() && getMana() > 2) {
if(heatable.getBurnTime() == 0) {
heatable.boostBurnTime();
mana = Math.max(0, mana - COST);
addMana(-COST);
}
if(ticksExisted % 2 == 0)
heatable.boostCookTime();
if(mana <= 0)
if(getMana() <= 0)
break;
}
}
@@ -42,9 +42,9 @@ public class SubTileFallenKanade extends TileEntityFunctionalFlower {
boolean did = false;
List<PlayerEntity> players = getWorld().getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(PlayerEntity player : players) {
if(player.getActivePotionEffect(Effects.REGENERATION) == null && mana >= COST) {
if(player.getActivePotionEffect(Effects.REGENERATION) == null && getMana() >= COST) {
player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 59, 2, true, true));
mana -= COST;
addMana(-COST);
did = true;
}
}
@@ -31,6 +31,7 @@ public class SubTileHeiseiDream extends TileEntityFunctionalFlower {
public static TileEntityType<SubTileHeiseiDream> TYPE;
private static final int RANGE = 5;
private static final int COST = 100;
public SubTileHeiseiDream() {
super(TYPE);
@@ -43,17 +44,15 @@ public class SubTileHeiseiDream extends TileEntityFunctionalFlower {
if(getWorld().isRemote)
return;
final int cost = 100;
@SuppressWarnings("unchecked")
List<IMob> mobs = (List) getWorld().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)), Predicates.instanceOf(IMob.class));
if(mobs.size() > 1 && mana >= cost)
if(mobs.size() > 1 && getMana() >= COST)
for(IMob mob : mobs) {
if(mob instanceof MobEntity) {
MobEntity entity = (MobEntity) mob;
if(brainwashEntity(entity, mobs)) {
mana -= cost;
addMana(-COST);
sync();
break;
}
@@ -123,8 +123,8 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower {
}
}
if(pulledAny && mana > 0)
mana--;
if(pulledAny && getMana() > 0)
addMana(-1);
}
public boolean canAcceptItem(ItemStack stack, List<ItemStack> filter, int filterType) {
@@ -211,7 +211,7 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower {
}
public int getRange() {
return mana > 0 ? RANGE_MANA : RANGE;
return getMana() > 0 ? RANGE_MANA : RANGE;
}
@Override
@@ -262,6 +262,6 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower {
super(TYPE);
}
@Override public int getRange() { return mana > 0 ? RANGE_MANA_MINI : RANGE_MINI; }
@Override public int getRange() { return getMana() > 0 ? RANGE_MANA_MINI : RANGE_MINI; }
}
}
@@ -29,6 +29,7 @@ public class SubTileHyacidus extends TileEntityFunctionalFlower {
public static TileEntityType<SubTileHyacidus> TYPE;
private static final int RANGE = 6;
private static final int COST = 20;
public SubTileHyacidus() {
super(TYPE);
@@ -41,13 +42,11 @@ public class SubTileHyacidus extends TileEntityFunctionalFlower {
if(getWorld().isRemote || redstoneSignal > 0)
return;
final int cost = 20;
List<LivingEntity> entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(LivingEntity entity : entities) {
if(!(entity instanceof PlayerEntity) && entity.getActivePotionEffect(Effects.POISON) == null && mana >= cost && !entity.world.isRemote && entity.getCreatureAttribute() != CreatureAttribute.UNDEAD) {
if(!(entity instanceof PlayerEntity) && entity.getActivePotionEffect(Effects.POISON) == null && getMana() >= COST && !entity.world.isRemote && entity.getCreatureAttribute() != CreatureAttribute.UNDEAD) {
entity.addPotionEffect(new EffectInstance(Effects.POISON, 60, 0));
mana -= cost;
addMana(-COST);
}
}
}
@@ -41,7 +41,7 @@ public class SubTileJadedAmaranthus extends TileEntityFunctionalFlower {
if(getWorld().isRemote || redstoneSignal > 0)
return;
if(ticksExisted % 30 == 0 && mana >= COST) {
if(ticksExisted % 30 == 0 && getMana() >= COST) {
BlockPos pos = new BlockPos(
getPos().getX() - RANGE + getWorld().rand.nextInt(RANGE * 2 + 1),
getPos().getY() + RANGE,
@@ -59,7 +59,7 @@ public class SubTileJadedAmaranthus extends TileEntityFunctionalFlower {
if(ConfigHandler.COMMON.blockBreakParticles.get())
getWorld().playEvent(2001, up, Block.getStateId(flower));
getWorld().setBlockState(up, flower);
mana -= COST;
addMana(-COST);
sync();
break;
@@ -74,7 +74,7 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower {
super.tickFlower();
World world = getWorld();
if(!world.isRemote && redstoneSignal == 0 && ticksExisted % 100 == 0 && mana >= COST) {
if(!world.isRemote && redstoneSignal == 0 && ticksExisted % 100 == 0 && getMana() >= COST) {
Random rand = world.rand;
ItemStack stack;
@@ -155,7 +155,7 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower {
world.addEntity(entity);
entity.spawnExplosionParticle();
mana -= COST;
addMana(-COST);
sync();
}
}
@@ -65,7 +65,7 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower {
if(getWorld().isRemote || redstoneSignal > 0)
return;
if(mana >= COST && ticksExisted % 2 == 0) {
if(getMana() >= COST && ticksExisted % 2 == 0) {
BlockPos coords = getCoordsToPut();
if(coords != null) {
BlockState state = getStoneToPut(coords);
@@ -74,7 +74,7 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower {
if(ConfigHandler.COMMON.blockBreakParticles.get())
getWorld().playEvent(2001, coords, Block.getStateId(state));
mana -= COST;
addMana(-COST);
sync();
}
}
@@ -37,14 +37,14 @@ public class SubTileMedumone extends TileEntityFunctionalFlower {
public void tickFlower() {
super.tickFlower();
if(!getWorld().isRemote && mana > 0) {
if(!getWorld().isRemote && getMana() > 0) {
List<LivingEntity> entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(LivingEntity entity : entities)
if(!(entity instanceof PlayerEntity)) {
entity.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 2, 100));
mana--;
if(mana == 0)
addMana(-1);
if(getMana() == 0)
return;
}
}
@@ -62,7 +62,7 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
return;
int cost = getCost();
if(mana >= cost && ticksExisted % getDelay() == 0) {
if(getMana() >= cost && ticksExisted % getDelay() == 0) {
BlockPos coords = getCoordsToPut();
if(coords != null) {
BlockState state = getOreToPut();
@@ -72,7 +72,7 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
getWorld().playEvent(2001, coords, Block.getStateId(state));
getWorld().playSound(null, getPos(), ModSounds.orechid, SoundCategory.BLOCKS, 2F, 1F);
mana -= cost;
addMana(-cost);
sync();
}
}
@@ -27,6 +27,7 @@ public class SubTilePollidisiac extends TileEntityFunctionalFlower {
public static TileEntityType<SubTilePollidisiac> TYPE;
private static final int RANGE = 6;
private static final int MANA_COST = 12;
public SubTilePollidisiac() {
super(TYPE);
@@ -37,14 +38,13 @@ public class SubTilePollidisiac extends TileEntityFunctionalFlower {
super.tickFlower();
if(!getWorld().isRemote) {
int manaCost = 12;
List<ItemEntity> items = getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
List<AnimalEntity> animals = getWorld().getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
int slowdown = getSlowdownFactor();
for(AnimalEntity animal : animals) {
if(mana < manaCost)
if(getMana() < MANA_COST)
break;
if(animal.getGrowingAge() == 0 && !animal.isInLove()) {
@@ -56,8 +56,7 @@ public class SubTilePollidisiac extends TileEntityFunctionalFlower {
if(!stack.isEmpty() && animal.isBreedingItem(stack)) {
stack.shrink(1);
mana -= manaCost;
addMana(-MANA_COST);
animal.setInLove(1200);
getWorld().setEntityState(animal, (byte)18);
}
@@ -105,8 +105,8 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower {
getWorld().playEvent(2001, coords, Block.getStateId(state));
}
validPositions.remove(coords);
if(mana > 1)
mana--;
if(getMana() > 1)
addMana(-1);
return;
}
}
@@ -172,7 +172,7 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower {
}
public int getRange() {
return mana > 0 ? RANGE_PLACE_MANA : RANGE_PLACE;
return getMana() > 0 ? RANGE_PLACE_MANA : RANGE_PLACE;
}
public int getRangeY() {
@@ -197,7 +197,7 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower {
super(TYPE);
}
@Override public int getRange() { return mana > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; }
@Override public int getRange() { return getMana() > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; }
@Override public int getRangeY() { return RANGE_PLACE_Y_MINI; }
}
@@ -77,13 +77,13 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower {
continue;
int cost = stack.getCount() * COST;
if(mana >= cost) {
if(getMana() >= cost) {
spawnExplosionParticles(item, 10);
item.setPosition(bindPos.getX() + 0.5, bindPos.getY() + 1.5, bindPos.getZ() + 0.5);
item.getPersistentData().putBoolean(TAG_TELEPORTED, true);
item.setMotion(Vec3d.ZERO);
spawnExplosionParticles(item, 10);
mana -= cost;
addMana(-cost);
did = true;
}
}
@@ -40,7 +40,7 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower {
public void tickFlower() {
super.tickFlower();
if(mana > 0) {
if(getMana() > 0) {
double x1 = getPos().getX() + 0.5;
double y1 = getPos().getY() + 0.5;
double z1 = getPos().getZ() + 0.5;
@@ -71,7 +71,7 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower {
}
if(ticksExisted % 4 == 0) {
mana--;
addMana(-1);
sync();
}
}
@@ -34,6 +34,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
private static final int RANGE = 10;
private static final int RANGE_Y = 4;
private static final int COST = 70;
public SubTileTigerseye() {
super(TYPE);
@@ -46,9 +47,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
if(getWorld().isRemote)
return;
final int cost = 70;
boolean shouldAfffect = mana >= cost;
boolean shouldAfffect = getMana() >= COST;
List<MobEntity> entities = getWorld().getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE_Y, -RANGE), getPos().add(RANGE + 1, RANGE_Y + 1, RANGE + 1)));
@@ -72,7 +71,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
}
if(avoidsOcelots) {
mana -= cost;
addMana(-COST);
sync();
shouldAfffect = false;
}
@@ -84,7 +84,7 @@ public class SubTileVinculotus extends TileEntityFunctionalFlower {
SubTileVinculotus flower = e.getKey();
BlockPos activePos = e.getValue();
if(flower == null || flower.redstoneSignal > 0 || flower.mana <= cost || flower.getWorld() != event.getEntityLiving().world || flower.getWorld().getTileEntity(flower.getPos()) != flower)
if(flower == null || flower.redstoneSignal > 0 || flower.getMana() <= cost || flower.getWorld() != event.getEntityLiving().world || flower.getWorld().getTileEntity(flower.getPos()) != flower)
continue;
double x = activePos.getX() + 0.5;
@@ -107,7 +107,7 @@ public class SubTileVinculotus extends TileEntityFunctionalFlower {
event.setTargetX(x + Math.random() * 3 - 1);
event.setTargetY(y);
event.setTargetZ(z + Math.random() * 3 - 1);
flower.mana -= cost;
flower.addMana(-cost);
flower.sync();
}
}
@@ -36,22 +36,24 @@ public class SubTileArcaneRose extends TileEntityGeneratingFlower {
public void tickFlower() {
super.tickFlower();
if(mana >= getMaxMana())
if(getMana() >= getMaxMana())
return;
List<PlayerEntity> players = getWorld().getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(PlayerEntity player : players)
if(ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) {
ExperienceHelper.drainPlayerXP(player, 1);
mana += 50;
addMana(50);
return;
}
List<ExperienceOrbEntity> orbs = getWorld().getEntitiesWithinAABB(ExperienceOrbEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(ExperienceOrbEntity orb : orbs) {
mana += orb.getXpValue() * 35;
orb.remove();
return;
if (orb.isAlive()) {
addMana(orb.getXpValue() * 35);
orb.remove();
return;
}
}
}
@@ -173,8 +173,7 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower {
TileEntity tile = world.getTileEntity(pos);
if(gen == -2) {
int val = Math.min(MAX_MANA_GENERATIONS, prevGen) * MANA_PER_GEN;
mana = Math.min(getMaxMana(), mana + val);
//world.setBlockToAir(x, y, z);
addMana(val);
} else if(blockAt == ModBlocks.cellBlock) {
if(gen < 0)
world.removeBlock(pos, false);
@@ -60,7 +60,7 @@ public class SubTileEndoflame extends TileEntityGeneratingFlower {
if(linkedCollector != null) {
if(burnTime == 0) {
if(mana < getMaxMana()) {
if(getMana() < getMaxMana()) {
int slowdown = getSlowdownFactor();
for(ItemEntity item : getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)))) {
@@ -40,13 +40,13 @@ public class SubTileEntropinnyum extends TileEntityGeneratingFlower {
public void tickFlower() {
super.tickFlower();
if(!getWorld().isRemote && mana == 0) {
if(!getWorld().isRemote && getMana() == 0) {
List<TNTEntity> tnts = getWorld().getEntitiesWithinAABB(TNTEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(TNTEntity tnt : tnts) {
if(tnt.getFuse() == 1 && !tnt.removed && !getWorld().getBlockState(new BlockPos(tnt)).getMaterial().isLiquid()) {
tnt.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 0.2F, (1F + (getWorld().rand.nextFloat() - getWorld().rand.nextFloat()) * 0.2F) * 0.7F);
tnt.remove();
mana += getMaxMana();
addMana(getMaxMana());
sync();
getWorld().addBlockEvent(getPos(), getBlockState().getBlock(), EXPLODE_EFFECT_EVENT, tnt.getEntityId());
@@ -61,7 +61,7 @@ public class SubTileGourmaryllis extends TileEntityGeneratingFlower {
int munchInterval = 2 + (2 * lastFoodCount);
if(cooldown == 0) {
mana = Math.min(getMaxMana(), mana + digestingMana);
addMana(digestingMana);
digestingMana = 0;
float burpPitch = 1 - (lastFoodCount - 1) * 0.05F;
@@ -70,7 +70,7 @@ public class SubTileHydroangeas extends TileEntityGeneratingFlower {
}
if(burnTime == 0) {
if(mana < getMaxMana() && !getWorld().isRemote) {
if(getMana() < getMaxMana() && !getWorld().isRemote) {
List<BlockPos> offsets = Arrays.asList(OFFSETS);
Collections.shuffle(offsets);
@@ -41,7 +41,7 @@ public class SubTileKekimurus extends TileEntityGeneratingFlower {
int mana = 1800;
if(getMaxMana() - this.mana >= mana && !getWorld().isRemote && ticksExisted % 80 == 0) {
if(getMaxMana() - this.getMana() >= mana && !getWorld().isRemote && ticksExisted % 80 == 0) {
for(int i = 0; i < RANGE * 2 + 1; i++)
for(int j = 0; j < RANGE * 2 + 1; j++)
for(int k = 0; k < RANGE * 2 + 1; k++) {
@@ -56,7 +56,7 @@ public class SubTileKekimurus extends TileEntityGeneratingFlower {
getWorld().playEvent(2001, pos, Block.getStateId(state));
getWorld().playSound(null, getPos(), SoundEvents.ENTITY_GENERIC_EAT, SoundCategory.BLOCKS, 1F, 0.5F + (float) Math.random() * 0.5F);
this.mana += mana;
addMana(mana);
sync();
return;
}
@@ -66,7 +66,7 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower {
int manaPerLeaf = 160;
eatLeaves : {
if(getMaxMana() - mana >= manaPerLeaf && ticksExisted % 4 == 0) {
if(getMaxMana() - getMana() >= manaPerLeaf && ticksExisted % 4 == 0) {
List<BlockPos> coords = new ArrayList<>();
BlockPos pos = getPos();
@@ -94,7 +94,7 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower {
ateOnce = true;
if(ConfigHandler.COMMON.blockBreakParticles.get())
getWorld().playEvent(2001, breakCoords, Block.getStateId(state));
mana += manaPerLeaf;
addMana(manaPerLeaf);
}
}
@@ -58,7 +58,7 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower {
if(!slime.world.isRemote) {
slime.remove();
slime.playSound(size > 1 ? SoundEvents.ENTITY_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH_SMALL, 1, 0.02F);
this.mana = Math.min(getMaxMana(), this.mana + mana);
addMana(mana);
sync();
}
@@ -54,7 +54,7 @@ public class SubTileRafflowsia extends TileEntityGeneratingFlower {
int mana = 2100;
if(getMaxMana() - this.mana >= mana && !getWorld().isRemote && ticksExisted % 40 == 0) {
if(getMaxMana() - this.getMana() >= mana && !getWorld().isRemote && ticksExisted % 40 == 0) {
for(int i = 0; i < RANGE * 2 + 1; i++)
for(int j = 0; j < RANGE * 2 + 1; j++)
for(int k = 0; k < RANGE * 2 + 1; k++) {
@@ -72,7 +72,7 @@ public class SubTileRafflowsia extends TileEntityGeneratingFlower {
float mod = 1F / lastFlowerTimes;
getWorld().destroyBlock(pos, false);
this.mana += mana * mod;
addMana((int) (mana * mod));
sync();
return;
}
@@ -43,7 +43,7 @@ public class SubTileShulkMeNot extends TileEntityGeneratingFlower {
List<ShulkerEntity> shulkers = world.getEntitiesWithinAABB(ShulkerEntity.class, new AxisAlignedBB(pos).grow(RADIUS));
if(!world.isRemote)
for(ShulkerEntity shulker : shulkers) {
if(getMaxMana() - mana < generate)
if(getMaxMana() - getMana() < generate)
break;
if(shulker.isAlive() && shulker.getDistanceSq(posD) < RADIUS * RADIUS) {
@@ -57,8 +57,8 @@ public class SubTileShulkMeNot extends TileEntityGeneratingFlower {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ENTITY_SHULKER_DEATH, SoundCategory.BLOCKS, 10F, 0.1F);
particles(world, pos, target);
particles(world, pos, shulker);
mana += generate;
addMana(generate);
sync();
}
}
@@ -107,7 +107,7 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower {
}
private void addManaAndCycle(int toAdd) {
mana = Math.min(getMaxMana(), mana + toAdd);
addMana(toAdd);
nextColor = nextColor == DyeColor.BLACK ? DyeColor.WHITE : DyeColor.values()[nextColor.ordinal() + 1];
sync();
}
@@ -37,6 +37,7 @@ public class TileFakeAir extends TileMod {
public void setFlower(TileEntity tile) {
flowerPos = tile.getPos();
markDirty();
}
public boolean canStay() {
@@ -90,7 +90,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
private boolean outputting = false;
public DyeColor color = DyeColor.WHITE;
int mana;
private int mana;
private int knownMana = -1;
public int manaCap = -1;
@@ -122,6 +122,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
int old = this.mana;
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap));
if(old != this.mana) {
markDirty();
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
markDispatchable();
}
@@ -131,7 +131,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
UUID identity;
int mana;
private int mana;
private int knownMana = -1;
public float rotationX, rotationY;
@@ -169,6 +169,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
@Override
public void recieveMana(int mana) {
this.mana = Math.min(this.mana + mana, getMaxMana());
this.markDirty();
}
@Override