45 lines
1.2 KiB
Java
45 lines
1.2 KiB
Java
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(float fuelMultiplier) {
|
|
reactionTime = (int) ((float) HardcodedConfig.REACTOR_TIME * fuelMultiplier);
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
if (reactionTime > 0) {
|
|
reactionTime--;
|
|
}
|
|
}
|
|
}
|