2018-11-29 00:47:21 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles;
|
|
|
|
|
|
|
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
2020-01-21 21:04:44 +01:00
|
|
|
import net.minecraft.tileentity.ITickableTileEntity;
|
|
|
|
import net.minecraft.tileentity.TileEntityType;
|
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-21 21:04:44 +01:00
|
|
|
public TileEntityAnimalGenerator(TileEntityType<?> tileEntityTypeIn) {
|
|
|
|
super(tileEntityTypeIn);
|
|
|
|
}
|
|
|
|
|
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;
|
2019-02-16 01:43:40 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-01-21 21:04:44 +01:00
|
|
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, TODO particles
|
|
|
|
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));*/
|
2018-11-29 00:47:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.timeRemaining -= 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-25 13:36:05 +01:00
|
|
|
@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;
|
|
|
|
}
|
|
|
|
}
|