2018-11-14 19:14:03 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles;
|
|
|
|
|
2020-01-22 23:21:52 +01:00
|
|
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
|
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
2021-12-08 00:31:29 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
2020-09-22 03:17:02 +02:00
|
|
|
import net.minecraft.tags.BlockTags;
|
2021-12-08 00:31:29 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
2018-11-14 19:14:03 +01:00
|
|
|
|
|
|
|
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-08 00:31:29 +01:00
|
|
|
public BlockEntityOakGenerator(BlockPos pos, BlockState state) {
|
2021-12-19 15:32:45 +01:00
|
|
|
super(ModBlockEntities.OAK_GENERATOR, pos, state);
|
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()) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var pos = this.scheduledBigTrees.remove();
|
2022-03-04 15:59:04 +01:00
|
|
|
if (this.level.getBlockState(pos).is(BlockTags.LOGS)) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var toAdd = 100000;
|
|
|
|
var 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-25 13:36:05 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean wantsLimitRemover() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-14 19:14:03 +01:00
|
|
|
}
|