use of com.teamresourceful.resourcefulbees.item.UpgradeItem in project ResourcefulBees by Resourceful-Bees.
the class TieredBeehiveBlock method performHiveUpgrade.
@Nullable
private InteractionResult performHiveUpgrade(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, ItemStack itemstack) {
CompoundTag data = ((UpgradeItem) itemstack.getItem()).getUpgradeData();
BlockEntity tileEntity = world.getBlockEntity(pos);
if (tileEntity instanceof TieredBeehiveTileEntity) {
TieredBeehiveTileEntity beehiveTileEntity = (TieredBeehiveTileEntity) tileEntity;
if (1 + beehiveTileEntity.getTier() == data.getInt(NBTConstants.NBT_TIER)) {
int newTier = data.getInt(NBTConstants.NBT_TIER);
beehiveTileEntity.setTier(newTier);
beehiveTileEntity.setTierModifier(data.getFloat(NBTConstants.NBT_TIER_MODIFIER));
beehiveTileEntity.recalculateHoneyLevel();
itemstack.shrink(1);
state = state.setValue(TIER_PROPERTY, newTier);
world.setBlockAndUpdate(pos, state);
return InteractionResult.SUCCESS;
}
}
return null;
}
Aggregations