重置HUD名称显示
This commit is contained in:
parent
f9b8f9d055
commit
6eb1164f33
28 changed files with 62 additions and 63 deletions
|
@ -179,20 +179,22 @@ public class AmmoBarOverlay {
|
|||
poseStack.scale(0.9f, 0.9f, 1f);
|
||||
|
||||
// 渲染物品名称
|
||||
String gunName = gunItem.getGunDisplayName();
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
centerString(gunItem.getGunDisplayName(), 20),
|
||||
w / 0.9f - 144 / 0.9f,
|
||||
gunName,
|
||||
w / 0.9f - (100 + Minecraft.getInstance().font.width(gunName) / 2f) / 0.9f,
|
||||
h / 0.9f - 60 / 0.9f,
|
||||
0xFFFFFF,
|
||||
true
|
||||
);
|
||||
|
||||
// 渲染弹药类型
|
||||
String ammoName = getGunAmmoType(stack);
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
centerString(getGunAmmoType(stack), 20),
|
||||
w / 0.9f - 144 / 0.9f,
|
||||
ammoName,
|
||||
w / 0.9f - (100 + Minecraft.getInstance().font.width(ammoName) / 2f) / 0.9f,
|
||||
h / 0.9f - 51 / 0.9f,
|
||||
0xC8A679,
|
||||
true
|
||||
|
@ -286,19 +288,4 @@ public class AmmoBarOverlay {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String centerString(String string, int length) {
|
||||
int spaceBefore = (length - string.length()) / 2;
|
||||
int spaceAfter = length - string.length() - spaceBefore;
|
||||
|
||||
return String.join("",
|
||||
repeatChar(spaceBefore),
|
||||
string,
|
||||
repeatChar(spaceAfter));
|
||||
}
|
||||
|
||||
private static String repeatChar(int count) {
|
||||
return new String(new char[count]).replace('\0', ' ');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class Glock17Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/glock_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/glock_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class Glock18Item extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -138,7 +139,7 @@ public class Glock18Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/glock_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/glock_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class M1911Item extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -138,7 +139,7 @@ public class M1911Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/m1911_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/m1911_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -136,7 +136,7 @@ public class Mp443Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/mp443_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/mp443_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,15 +49,15 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, AnimatedItem
|
|||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
public SecondaryCataclysm() {
|
||||
super(new Properties().stacksTo(1).fireResistant().rarity(Rarity.EPIC));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SoundEvent> getReloadSound() {
|
||||
return Set.of(ModSounds.M_79_RELOAD_EMPTY.get());
|
||||
}
|
||||
|
||||
public SecondaryCataclysm() {
|
||||
super(new Properties().stacksTo(1).fireResistant().rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
|
||||
super.initializeClient(consumer);
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class DevotionItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -122,7 +123,7 @@ public class DevotionItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/devotion_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/devotion_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,6 +42,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class M60Item extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class MinigunItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private static final String TAG_HEAT = "heat";
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
@ -196,7 +197,7 @@ public class MinigunItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/minigun_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/minigun_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,8 +40,8 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public String animationProcedure = "empty";
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
public RpkItem() {
|
||||
|
@ -96,7 +96,8 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {;
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
;
|
||||
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
|
||||
data.add(idleController);
|
||||
}
|
||||
|
@ -123,7 +124,7 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/rpk_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/rpk_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class HuntingRifleItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -117,7 +118,7 @@ public class HuntingRifleItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/hunting_rifle_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/hunting_rifle_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class K98Item extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -160,7 +161,7 @@ public class K98Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/k98_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/k98_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class M98bItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -138,7 +139,7 @@ public class M98bItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/m98b_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/m98b_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class MosinNagantItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -160,7 +161,7 @@ public class MosinNagantItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/mosin_nagant_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/mosin_nagant_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class Ntw20Item extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -139,7 +140,7 @@ public class Ntw20Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/ntw_20_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/ntw_20_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
public class SvdItem extends GunItem implements GeoItem, AnimatedItem {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -121,7 +122,7 @@ public class SvdItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(ModUtils.MODID, "textures/gun_icon/svd_icon.png");
|
||||
return ModUtils.loc("textures/gun_icon/svd_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue