2018-11-14 19:14:03 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles;
|
|
|
|
|
|
|
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
|
|
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
|
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.block.LogBlock;
|
2018-11-14 19:14:03 +01:00
|
|
|
import net.minecraft.util.ITickable;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
|
|
|
import java.util.ArrayDeque;
|
|
|
|
import java.util.Queue;
|
|
|
|
|
|
|
|
public class TileEntityOakGenerator extends TileEntityImpl implements ITickable {
|
|
|
|
|
|
|
|
public Queue<BlockPos> scheduledBigTrees = new ArrayDeque<>();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update() {
|
|
|
|
if (!this.world.isRemote)
|
|
|
|
while (!this.scheduledBigTrees.isEmpty()) {
|
|
|
|
BlockPos pos = this.scheduledBigTrees.remove();
|
2019-10-20 22:30:49 +02:00
|
|
|
if (this.world.getBlockState(pos).getBlock() instanceof LogBlock) {
|
2019-01-29 11:46:38 +01:00
|
|
|
int toAdd = 100000;
|
2019-02-16 01:43:40 +01:00
|
|
|
boolean canGen = this.canGenerateRightNow(25, toAdd);
|
|
|
|
if (canGen)
|
|
|
|
while (toAdd > 0) {
|
|
|
|
BlockPos spot = IAuraChunk.getLowestSpot(this.world, this.pos, 25, this.pos);
|
|
|
|
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
|
|
|
}
|
2018-11-14 19:14:03 +01:00
|
|
|
|
|
|
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
|
|
|
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 12,
|
2019-02-16 01:43:40 +01:00
|
|
|
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));
|
2018-11-14 19:14:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-25 13:36:05 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean wantsLimitRemover() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-14 19:14:03 +01:00
|
|
|
}
|