mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-06-01 19:23:36 +02:00
51 lines
1.5 KiB
Java
51 lines
1.5 KiB
Java
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;
|
|
import net.minecraft.util.ITickable;
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickable {
|
|
|
|
private int timeRemaining;
|
|
private int amountToRelease;
|
|
|
|
@Override
|
|
public void update() {
|
|
if (!this.world.isRemote) {
|
|
if (this.world.getTotalWorldTime() % 10 != 0)
|
|
return;
|
|
if (this.timeRemaining <= 0)
|
|
return;
|
|
|
|
int remain = this.amountToRelease;
|
|
if (this.canGenerateRightNow(35, remain)) {
|
|
while (remain > 0) {
|
|
BlockPos spot = IAuraChunk.getLowestSpot(this.world, this.pos, 35, this.pos);
|
|
remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain);
|
|
}
|
|
|
|
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
|
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));
|
|
}
|
|
|
|
this.timeRemaining -= 10;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean wantsLimitRemover() {
|
|
return true;
|
|
}
|
|
|
|
public boolean isBusy() {
|
|
return this.timeRemaining > 0;
|
|
}
|
|
|
|
public void setGenerationValues(int time, int amount) {
|
|
this.timeRemaining = time;
|
|
this.amountToRelease = amount;
|
|
}
|
|
}
|