This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/block/entity/shifter/PhasedItem.java

35 lines
990 B
Java

package com.thebrokenrail.energonrelics.block.entity.shifter;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
class PhasedItem {
final ItemStack item;
int cooldown = 0;
int roll = 0;
PhasedItem(ItemStack item) {
this.item = item;
}
int getRange() {
return HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_BASE + (roll * HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_INCREMENT);
}
CompoundTag toTag() {
CompoundTag tag = new CompoundTag();
tag.put("Item", item.toTag(new CompoundTag()));
tag.putInt("Cooldown", cooldown);
tag.putInt("Roll", roll);
return tag;
}
static PhasedItem fromTag(CompoundTag tag) {
PhasedItem item = new PhasedItem(ItemStack.fromTag(tag.getCompound("Item")));
item.cooldown = tag.getInt("Cooldown");
item.roll = tag.getInt("Roll");
return item;
}
}