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

51 lines
1.5 KiB
Java
Raw Normal View History

2018-11-29 00:47:21 +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;
2021-12-04 15:40:09 +01:00
import net.minecraft.tileentity.ITickableBlockEntity;
2018-11-29 00:47:21 +01:00
import net.minecraft.util.math.BlockPos;
2021-12-04 15:40:09 +01:00
public class BlockEntityAnimalGenerator extends BlockEntityImpl implements ITickableBlockEntity {
2018-11-29 00:47:21 +01:00
private int timeRemaining;
private int amountToRelease;
2021-12-04 15:40:09 +01:00
public BlockEntityAnimalGenerator() {
2020-01-22 01:32:26 +01:00
super(ModTileEntities.ANIMAL_GENERATOR);
2020-01-21 21:04:44 +01:00
}
2018-11-29 00:47:21 +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) {
if (this.level.getGameTime() % 10 != 0)
2018-11-29 00:47:21 +01:00
return;
if (this.timeRemaining <= 0)
return;
int remain = this.amountToRelease;
2021-03-30 15:44:31 +02:00
if (this.canGenerateRightNow(remain)) {
this.generateAura(remain);
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.ANIMAL_GEN_CREATE));
2018-11-29 00:47:21 +01:00
}
this.timeRemaining -= 10;
}
}
@Override
public boolean wantsLimitRemover() {
return true;
}
2018-11-29 00:47:21 +01:00
public boolean isBusy() {
return this.timeRemaining > 0;
}
public void setGenerationValues(int time, int amount) {
this.timeRemaining = time;
this.amountToRelease = amount;
}
}