damage bar, size in hover text
This commit is contained in:
parent
0eae3e4088
commit
79079d5b4d
@ -38,7 +38,7 @@ mod_name=QuantumBags
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.0.3
|
mod_version=0.0.4
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
@ -25,7 +25,7 @@ public class QuantumBag extends Item {
|
|||||||
ForgeConfigSpec.ConfigValue<Integer> size;
|
ForgeConfigSpec.ConfigValue<Integer> size;
|
||||||
|
|
||||||
public QuantumBag(Properties pProperties, ForgeConfigSpec.ConfigValue<Integer> size) {
|
public QuantumBag(Properties pProperties, ForgeConfigSpec.ConfigValue<Integer> size) {
|
||||||
super(pProperties);
|
super(pProperties.durability(100));
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public class QuantumBag extends Item {
|
|||||||
stored.setCount(stored.getCount() - 1);
|
stored.setCount(stored.getCount() - 1);
|
||||||
setStoredStack(item, stored);
|
setStoredStack(item, stored);
|
||||||
drop.setCount(1);
|
drop.setCount(1);
|
||||||
player.level().addFreshEntity(player.drop(drop, false, true));
|
player.drop(drop, false, true);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@ -186,13 +186,23 @@ public class QuantumBag extends Item {
|
|||||||
return itemStack;
|
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
|
@Override
|
||||||
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
|
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
|
||||||
if (hasStoredItem(pStack)) {
|
if (hasStoredItem(pStack)) {
|
||||||
ItemStack stored = getStoredStack(pStack);
|
ItemStack stored = getStoredStack(pStack);
|
||||||
if (!stored.getItem().equals(Items.AIR)) {
|
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.literal(stored.getCount() + "/" + size.get() + " ").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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
|
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user