NaturesAura/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java

44 lines
1.6 KiB
Java
Raw Normal View History

2018-11-14 19:14:03 +01:00
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
2020-01-22 23:21:52 +01:00
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
2020-09-22 03:17:02 +02:00
import net.minecraft.tags.BlockTags;
2021-12-04 15:40:09 +01:00
import net.minecraft.tileentity.ITickableBlockEntity;
2018-11-14 19:14:03 +01:00
import net.minecraft.util.math.BlockPos;
import java.util.ArrayDeque;
import java.util.Queue;
2021-12-04 15:40:09 +01:00
public class BlockEntityOakGenerator extends BlockEntityImpl implements ITickableBlockEntity {
2018-11-14 19:14:03 +01:00
public Queue<BlockPos> scheduledBigTrees = new ArrayDeque<>();
2021-12-04 15:40:09 +01:00
public BlockEntityOakGenerator() {
2020-01-22 01:32:26 +01:00
super(ModTileEntities.OAK_GENERATOR);
2020-01-21 21:04:44 +01:00
}
2018-11-14 19:14:03 +01:00
@Override
2020-01-21 21:04:44 +01:00
public void tick() {
2021-12-04 15:40:09 +01:00
if (!this.level.isClientSide)
2018-11-14 19:14:03 +01:00
while (!this.scheduledBigTrees.isEmpty()) {
BlockPos pos = this.scheduledBigTrees.remove();
2021-12-04 15:40:09 +01:00
if (this.level.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) {
int toAdd = 100000;
2021-03-30 15:44:31 +02:00
boolean canGen = this.canGenerateRightNow(toAdd);
2019-02-16 01:43:40 +01:00
if (canGen)
2021-03-30 15:44:31 +02:00
this.generateAura(toAdd);
2018-11-14 19:14:03 +01:00
2021-12-04 15:40:09 +01:00
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.OAK_GENERATOR,
2020-01-22 23:21:52 +01:00
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));
2018-11-14 19:14:03 +01:00
}
}
}
@Override
public boolean wantsLimitRemover() {
return true;
}
2018-11-14 19:14:03 +01:00
}