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

51 lines
1.6 KiB
Java
Raw Normal View History

2018-10-13 23:46:30 +02:00
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
2018-11-11 13:26:19 +01:00
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
2021-12-04 15:40:09 +01:00
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.state.BlockState;
2018-10-14 14:27:18 +02:00
2021-12-04 15:40:09 +01:00
public class BlockEntityAncientLeaves extends BlockEntityImpl {
2018-10-14 14:27:18 +02:00
private final NaturalAuraContainer container = new NaturalAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 2000, 500) {
2018-10-14 14:27:18 +02:00
@Override
public int getAuraColor() {
2019-01-30 17:51:39 +01:00
return 0xCE5489;
2018-10-14 14:27:18 +02:00
}
2018-10-14 16:12:33 +02:00
@Override
public int drainAura(int amountToDrain, boolean simulate) {
2021-12-15 16:30:22 +01:00
var amount = super.drainAura(amountToDrain, simulate);
2018-10-14 16:12:33 +02:00
if (amount > 0 && !simulate) {
2021-12-04 15:40:09 +01:00
BlockEntityAncientLeaves.this.sendToClients();
2018-10-14 16:12:33 +02:00
}
return amount;
}
2018-10-14 14:27:18 +02:00
};
2021-12-04 15:40:09 +01:00
public BlockEntityAncientLeaves(BlockPos pos, BlockState state) {
super(ModTileEntities.ANCIENT_LEAVES, pos, state);
2020-01-21 23:02:39 +01:00
}
2018-10-14 14:27:18 +02:00
@Override
2020-10-19 21:26:32 +02:00
public IAuraContainer getAuraContainer() {
2018-10-14 14:27:18 +02:00
return this.container;
}
@Override
2021-12-04 15:40:09 +01:00
public void writeNBT(CompoundTag compound, SaveType type) {
2018-11-04 16:38:09 +01:00
super.writeNBT(compound, type);
if (type != SaveType.BLOCK)
this.container.writeNBT(compound);
2018-10-14 14:27:18 +02:00
}
@Override
2021-12-04 15:40:09 +01:00
public void readNBT(CompoundTag compound, SaveType type) {
2018-11-04 16:38:09 +01:00
super.readNBT(compound, type);
if (type != SaveType.BLOCK)
this.container.readNBT(compound);
2018-10-14 14:27:18 +02:00
}
2018-10-13 23:46:30 +02:00
}