EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/block/entity/reactor/ReactorCoreBlockEntity.java

45 lines
1.1 KiB
Java

package com.thebrokenrail.energonrelics.block.entity.reactor;
import com.thebrokenrail.energonrelics.Config;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Tickable;
public class ReactorCoreBlockEntity extends BlockEntity implements Tickable {
private int reactionTime = 0;
public ReactorCoreBlockEntity(BlockEntityType<?> type) {
super(type);
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
tag.putInt("ReactionTime", reactionTime);
return tag;
}
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
reactionTime = tag.getInt("ReactionTime");
}
boolean isReacting() {
return reactionTime > 0;
}
void startReaction() {
reactionTime = Config.REACTOR_TIME;
}
@Override
public void tick() {
if (reactionTime > 0) {
reactionTime--;
}
}
}