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;
2020-01-21 21:04:44 +01:00
import net.minecraft.tileentity.ITickableTileEntity;
2018-11-29 00:47:21 +01:00
import net.minecraft.util.math.BlockPos;
2020-01-21 21:04:44 +01:00
public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickableTileEntity {
2018-11-29 00:47:21 +01:00
private int timeRemaining;
private int amountToRelease;
2020-01-22 01:32:26 +01:00
public TileEntityAnimalGenerator() {
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() {
2018-11-29 00:47:21 +01:00
if (!this.world.isRemote) {
2020-01-21 21:04:44 +01:00
if (this.world.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);
2020-01-22 23:21:52 +01:00
PacketHandler.sendToAllAround(this.world, this.pos, 32,
2020-01-26 00:16:06 +01:00
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.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;
}
}