forked from TheBrokenRail/EnergonRelics
37 lines
866 B
Java
37 lines
866 B
Java
package com.thebrokenrail.energonrelics.block.entity.battery;
|
|
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.entity.BlockEntity;
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
public class BatteryCoreBlockEntity extends BlockEntity {
|
|
private long energy = 0;
|
|
|
|
public BatteryCoreBlockEntity(BlockEntityType<?> type) {
|
|
super(type);
|
|
}
|
|
|
|
@Override
|
|
public CompoundTag toTag(CompoundTag tag) {
|
|
super.toTag(tag);
|
|
tag.putLong("Energy", energy);
|
|
return tag;
|
|
}
|
|
|
|
@Override
|
|
public void fromTag(BlockState state, CompoundTag tag) {
|
|
super.fromTag(state, tag);
|
|
energy = tag.getLong("Energy");
|
|
}
|
|
|
|
long getEnergy() {
|
|
return energy;
|
|
}
|
|
|
|
void setEnergy(long value) {
|
|
energy = value;
|
|
markDirty();
|
|
}
|
|
}
|