修改基本的图标显示
This commit is contained in:
parent
c82e034688
commit
b8074209d0
5 changed files with 43 additions and 8 deletions
|
@ -2,7 +2,9 @@ package net.mcreator.target.client.screens;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.init.TargetModKeyMappings;
|
||||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.mcreator.target.item.gun.GunItem;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.mcreator.target.tools.FireMode;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -28,29 +30,52 @@ public class AmmoBarOverlay {
|
|||
}
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (stack.is(TargetModTags.Items.GUN)) {
|
||||
if (stack.getItem() instanceof GunItem gunItem) {
|
||||
PoseStack poseStack = event.getGuiGraphics().pose();
|
||||
|
||||
// 渲染图标
|
||||
event.getGuiGraphics().blit(gunItem.getGunIcon(),
|
||||
w / 2 + 100,
|
||||
h - 40,
|
||||
0,
|
||||
0,
|
||||
64,
|
||||
16,
|
||||
64,
|
||||
16);
|
||||
|
||||
FireMode mode = getFireMode(stack);
|
||||
|
||||
// 渲染开火模式切换按键
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
"[" + TargetModKeyMappings.FIREMODE.getKey().getDisplayName().getString() + "]",
|
||||
w / 2 + 125,
|
||||
h - 18,
|
||||
0xFFFFFF,
|
||||
true
|
||||
);
|
||||
|
||||
// 渲染当前弹药量
|
||||
poseStack.pushPose();
|
||||
poseStack.scale(1.5f, 1.5f, 1f);
|
||||
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
getGunAmmoCount(player) + "",
|
||||
w / 3f + 117,
|
||||
h / 1.5f - 28,
|
||||
w / 3f + 112,
|
||||
h / 1.5f - 31,
|
||||
0xFFFFFF,
|
||||
true
|
||||
);
|
||||
poseStack.popPose();
|
||||
|
||||
// 渲染备弹量
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
getPlayerAmmoCount(player),
|
||||
w / 2 + 180,
|
||||
h - 30,
|
||||
w / 2 + 170,
|
||||
h - 35,
|
||||
0xCCCCCC,
|
||||
true
|
||||
);
|
||||
|
@ -83,12 +108,10 @@ public class AmmoBarOverlay {
|
|||
public static String getPlayerAmmoCount(Player player) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (stack.getItem() == TargetModItems.BOCEK.get()) {
|
||||
return "";
|
||||
}
|
||||
if (stack.getItem() == TargetModItems.MINIGUN.get()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (stack.is(TargetModTags.Items.RIFLE)) {
|
||||
return "" + (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.client.model.HumanoidModel;
|
|||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -191,4 +192,9 @@ public class Aa12Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
public void setAnimationProcedure(String procedure) {
|
||||
this.animationProcedure = procedure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(TargetMod.MODID, "textures/gun_icon/aa_12.png");
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.item.gun;
|
||||
|
||||
import net.mcreator.target.TargetMod;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
|
@ -7,6 +8,7 @@ import net.mcreator.target.tools.GunsTool;
|
|||
import net.mcreator.target.tools.ItemNBTTool;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
@ -93,6 +95,10 @@ public abstract class GunItem extends Item {
|
|||
return Set.of();
|
||||
}
|
||||
|
||||
public ResourceLocation getGunIcon() {
|
||||
return new ResourceLocation(TargetMod.MODID, "textures/gun_icon/default.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return stack.getOrCreateTag().getBoolean("beast");
|
||||
|
|
BIN
src/main/resources/assets/target/textures/gun_icon/aa_12.png
Normal file
BIN
src/main/resources/assets/target/textures/gun_icon/aa_12.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
src/main/resources/assets/target/textures/gun_icon/default.png
Normal file
BIN
src/main/resources/assets/target/textures/gun_icon/default.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
Loading…
Add table
Reference in a new issue