package com.thebrokenrail.energonrelics.block.entity.reactor; import com.thebrokenrail.energonrelics.config.HardcodedConfig; 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 = HardcodedConfig.REACTOR_TIME; } @Override public void tick() { if (reactionTime > 0) { reactionTime--; } } }