调整projectile amount逻辑
This commit is contained in:
parent
9a461e5b38
commit
40d991767b
8 changed files with 23 additions and 111 deletions
|
@ -18,7 +18,6 @@ public class ClientRenderHandler {
|
|||
@SubscribeEvent
|
||||
public static void registerTooltip(RegisterClientTooltipComponentFactoriesEvent event) {
|
||||
event.register(GunImageComponent.class, ClientGunImageTooltip::new);
|
||||
event.register(ShotgunImageComponent.class, ClientShotgunImageTooltip::new);
|
||||
event.register(BocekImageComponent.class, ClientBocekImageTooltip::new);
|
||||
event.register(EnergyImageComponent.class, ClientEnergyImageTooltip::new);
|
||||
event.register(CellImageComponent.class, ClientCellImageTooltip::new);
|
||||
|
|
|
@ -103,10 +103,18 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
String dmgStr = FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : "");
|
||||
if (data.projectileAmount() > 1) {
|
||||
if (extraDamage >= 0) {
|
||||
dmgStr = "(" + dmgStr + ") * " + data.projectileAmount();
|
||||
} else {
|
||||
dmgStr = dmgStr + " * " + data.projectileAmount();
|
||||
}
|
||||
}
|
||||
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : ""))
|
||||
.append(Component.literal(dmgStr)
|
||||
.withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
|
||||
|
@ -114,7 +122,9 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
* 获取武器射速的文本组件
|
||||
*/
|
||||
protected Component getRpmComponent() {
|
||||
if (this.stack.getItem() instanceof GunItem && GunData.from(this.stack).getAvailableFireModes().contains(FireMode.AUTO)) {
|
||||
if (this.stack.getItem() instanceof GunItem &&
|
||||
(GunData.from(this.stack).getAvailableFireModes().contains(FireMode.AUTO)
|
||||
|| GunData.from(this.stack).getAvailableFireModes().contains(FireMode.BURST))) {
|
||||
return Component.translatable("des.superbwarfare.guns.rpm").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format0D(data.rpm()))
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.tooltip;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent;
|
||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ClientShotgunImageTooltip extends ClientGunImageTooltip {
|
||||
|
||||
public ClientShotgunImageTooltip(GunImageComponent tooltip) {
|
||||
super(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getDamageComponent() {
|
||||
boolean slug = false;
|
||||
|
||||
var perk = data.perk.get(Perk.Type.AMMO);
|
||||
if (perk instanceof AmmoPerk ammoPerk && ammoPerk.slug) {
|
||||
slug = true;
|
||||
}
|
||||
|
||||
if (slug) {
|
||||
double damage = data.damage() * data.projectileAmount();
|
||||
double extraDamage = -1;
|
||||
for (var type : Perk.Type.values()) {
|
||||
var instance = data.perk.getInstance(type);
|
||||
if (instance != null) {
|
||||
damage = instance.perk().getDisplayDamage(damage, data, instance);
|
||||
if (instance.perk().getExtraDisplayDamage(damage, data, instance) >= 0) {
|
||||
extraDamage = instance.perk().getExtraDisplayDamage(damage, data, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : "")).withStyle(ChatFormatting.GREEN));
|
||||
} else {
|
||||
double damage = data.damage();
|
||||
double extraDamage = -1;
|
||||
for (var type : Perk.Type.values()) {
|
||||
var instance = data.perk.getInstance(type);
|
||||
if (instance != null) {
|
||||
damage = instance.perk().getDisplayDamage(damage, data, instance);
|
||||
if (instance.perk().getExtraDisplayDamage(damage, data, instance) >= 0) {
|
||||
extraDamage = instance.perk().getExtraDisplayDamage(damage, data, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + " * " + FormatTool.format0D(data.projectileAmount())).withStyle(ChatFormatting.GREEN))
|
||||
.append(Component.literal(extraDamage >= 0 ?
|
||||
("(" + FormatTool.format1D(damage) + " + " + FormatTool.format1D(extraDamage) + ") * " + FormatTool.format0D(data.projectileAmount()))
|
||||
: FormatTool.format1D(damage, " * ") + FormatTool.format0D(data.projectileAmount())
|
||||
).withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.tooltip.component;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ShotgunImageComponent extends GunImageComponent {
|
||||
|
||||
public int width;
|
||||
public int height;
|
||||
public ItemStack stack;
|
||||
|
||||
public ShotgunImageComponent(int width, int height, ItemStack stack) {
|
||||
super(width, height, stack);
|
||||
}
|
||||
|
||||
public ShotgunImageComponent(ItemStack stack) {
|
||||
this(32, 16, stack);
|
||||
}
|
||||
|
||||
}
|
|
@ -151,6 +151,9 @@ public class GunData {
|
|||
public double perkDamageRate() {
|
||||
var perk = this.perk.get(Perk.Type.AMMO);
|
||||
if (perk instanceof AmmoPerk ammoPerk) {
|
||||
if (ammoPerk.slug) {
|
||||
return ammoPerk.damageRate * rawProjectileAmount();
|
||||
}
|
||||
return ammoPerk.damageRate;
|
||||
}
|
||||
return 1;
|
||||
|
@ -207,7 +210,15 @@ public class GunData {
|
|||
return projectileInfo().type;
|
||||
}
|
||||
|
||||
public int rawProjectileAmount() {
|
||||
return defaultGunData().projectileAmount;
|
||||
}
|
||||
|
||||
public int projectileAmount() {
|
||||
var perk = this.perk.get(Perk.Type.AMMO);
|
||||
if (perk instanceof AmmoPerk ammoPerk && ammoPerk.slug) {
|
||||
return 1;
|
||||
}
|
||||
return defaultGunData().projectileAmount;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.item.gun.shotgun;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.gun.Aa12ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponent;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModEnumExtensions;
|
||||
|
@ -12,18 +11,15 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -117,11 +113,6 @@ public class Aa12Item extends GunItem implements GeoItem {
|
|||
return "AA-12";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<TooltipComponent> getTooltipImage(@NotNull ItemStack pStack) {
|
||||
return Optional.of(new ShotgunImageComponent(pStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenBolt(ItemStack stack) {
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.item.gun.shotgun;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.gun.HomemadeShotgunItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponent;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
|
@ -17,7 +16,6 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
@ -28,7 +26,6 @@ import software.bernie.geckolib.animation.*;
|
|||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -113,11 +110,6 @@ public class HomemadeShotgunItem extends GunItem implements GeoItem {
|
|||
return "Homemade Shotgun";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<TooltipComponent> getTooltipImage(@NotNull ItemStack pStack) {
|
||||
return Optional.of(new ShotgunImageComponent(pStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenBolt(ItemStack stack) {
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.item.gun.shotgun;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.gun.M870ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponent;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
|
@ -11,18 +10,15 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -126,9 +122,4 @@ public class M870Item extends GunItem implements GeoItem {
|
|||
public String getGunDisplayName() {
|
||||
return "M870 MCS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<TooltipComponent> getTooltipImage(@NotNull ItemStack pStack) {
|
||||
return Optional.of(new ShotgunImageComponent(pStack));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue