damage bar, size in hover text
This commit is contained in:
2 files changed
+15
-5
No files matched your search
@@ -25,7 +25,7 @@ public class QuantumBag extends Item {
|
||||
ForgeConfigSpec.ConfigValue<Integer> size;
|
||||
|
||||
public QuantumBag(Properties pProperties, ForgeConfigSpec.ConfigValue<Integer> size) {
|
||||
super(pProperties);
|
||||
super(pProperties.durability(100));
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class QuantumBag extends Item {
|
||||
stored.setCount(stored.getCount() - 1);
|
||||
setStoredStack(item, stored);
|
||||
drop.setCount(1);
|
||||
player.level().addFreshEntity(player.drop(drop, false, true));
|
||||
player.drop(drop, false, true);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -186,13 +186,23 @@ public class QuantumBag extends Item {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage(ItemStack stack) {
|
||||
int maxDamage = ServerConfig.SPEC.isLoaded() ? size.get() : 1;
|
||||
float percentage = (float) storedItemCount(stack) / maxDamage;
|
||||
if (percentage != 1) {
|
||||
return (int) Math.ceil(100 - (100 * percentage));
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
|
||||
if (hasStoredItem(pStack)) {
|
||||
ItemStack stored = getStoredStack(pStack);
|
||||
if (!stored.getItem().equals(Items.AIR)) {
|
||||
pTooltipComponents.add(Component.literal(stored.getCount() + " ").withStyle(ChatFormatting.GRAY).append(Component.translatable(stored.getDescriptionId()).withStyle(ChatFormatting.WHITE)));
|
||||
//pTooltipComponents.add(Component.translatable(stored.getDescriptionId()).append(Component.literal(" : " + stored.getCount())).withStyle(ChatFormatting.DARK_BLUE));
|
||||
pTooltipComponents.add(Component.literal(stored.getCount() + "/" + size.get() + " ").withStyle(ChatFormatting.GRAY).append(Component.translatable(stored.getDescriptionId()).withStyle(ChatFormatting.WHITE)));
|
||||
}
|
||||
}
|
||||
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
|
||||
|
||||
Reference in new issue
Block a user