添加载具击杀播报的图标

This commit is contained in:
Atsuihsio 2025-01-31 15:05:52 +08:00
parent 21d3f10637
commit f977f9cc18
20 changed files with 137 additions and 30 deletions

View file

@ -2,6 +2,8 @@ package com.atsuishio.superbwarfare.client.overlay;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.client.KillMessageConfig; import com.atsuishio.superbwarfare.config.client.KillMessageConfig;
import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
import com.atsuishio.superbwarfare.event.KillMessageHandler; import com.atsuishio.superbwarfare.event.KillMessageHandler;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
@ -170,8 +172,50 @@ public class KillMessageOverlay {
); );
} }
Player player = Minecraft.getInstance().player;
boolean renderItem = false; boolean renderItem = false;
int itemIconW = damageTypeIcon != null ? w - targetNameWidth - 64 : w - targetNameWidth - 46; int itemIconW = damageTypeIcon != null ? w - targetNameWidth - 64 : w - targetNameWidth - 46;
if (player != null && player.getVehicle() instanceof VehicleEntity vehicleEntity) {
// 载具图标
if ((vehicleEntity instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) || record.damageType == ModDamageTypes.VEHICLE_STRIKE) {
renderItem = true;
ResourceLocation resourceLocation = vehicleEntity.getVehicleIcon();
preciseBlit(gui,
resourceLocation,
itemIconW,
top,
0,
0,
32,
8,
-32,
8
);
} else {
if (record.stack.getItem() instanceof GunItem gunItem) {
renderItem = true;
ResourceLocation resourceLocation = gunItem.getGunIcon();
preciseBlit(gui,
resourceLocation,
itemIconW,
top,
0,
0,
32,
8,
-32,
8
);
}
}
} else {
// 如果是枪械击杀则渲染枪械图标 // 如果是枪械击杀则渲染枪械图标
if (record.stack.getItem() instanceof GunItem gunItem) { if (record.stack.getItem() instanceof GunItem gunItem) {
renderItem = true; renderItem = true;
@ -207,6 +251,7 @@ public class KillMessageOverlay {
8 8
); );
} }
}
// 渲染击杀者名称 // 渲染击杀者名称
AtomicReference<String> attackerName = new AtomicReference<>(record.attacker.getDisplayName().getString()); AtomicReference<String> attackerName = new AtomicReference<>(record.attacker.getDisplayName().getString());

View file

@ -21,6 +21,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
@ -778,4 +779,9 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
public int getWeaponType() { public int getWeaponType() {
return entityData.get(WEAPON_TYPE); return entityData.get(WEAPON_TYPE);
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/ah_6_icon.png");
}
} }

View file

@ -16,6 +16,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -552,4 +553,9 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
public int zoomFov() { public int zoomFov() {
return 5; return 5;
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/annihilator_icon.png");
}
} }

View file

@ -23,6 +23,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
@ -818,4 +819,9 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ICha
public int getWeaponType() { public int getWeaponType() {
return entityData.get(WEAPON_TYPE); return entityData.get(WEAPON_TYPE);
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/bmp2_icon.png");
}
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
@ -785,4 +786,9 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
public int getWeaponType() { public int getWeaponType() {
return entityData.get(WEAPON_TYPE); return entityData.get(WEAPON_TYPE);
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/lav150_icon.png");
}
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -447,4 +448,9 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit
public int zoomFov() { public int zoomFov() {
return 5; return 5;
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/sherman_icon.png");
}
} }

View file

@ -18,6 +18,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -498,4 +499,9 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn
public int zoomFov() { public int zoomFov() {
return 5; return 5;
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/mle_1934_icon.png");
}
} }

View file

@ -20,6 +20,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
@ -568,4 +569,9 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
public int zoomFov() { public int zoomFov() {
return 1; return 1;
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/speedboat_icon.png");
}
} }

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.vehicle; package com.atsuishio.superbwarfare.entity.vehicle;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity; import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
@ -16,6 +17,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
@ -358,4 +360,9 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
public int getMaxEnergy() { public int getMaxEnergy() {
return MAX_ENERGY; return MAX_ENERGY;
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/tom_6_icon.png");
}
} }

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.vehicle; package com.atsuishio.superbwarfare.entity.vehicle;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModParticleTypes; import com.atsuishio.superbwarfare.init.ModParticleTypes;
@ -15,6 +16,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -410,4 +412,8 @@ public class VehicleEntity extends Entity {
return super.getDismountLocationForPassenger(passenger); return super.getDismountLocationForPassenger(passenger);
} }
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/gun_icon/default_icon.png");
}
} }

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity.vehicle; package com.atsuishio.superbwarfare.entity.vehicle;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.MortarEntity; import com.atsuishio.superbwarfare.entity.MortarEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModDamageTypes;
@ -13,6 +14,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
@ -302,4 +304,9 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity {
public int getMaxEnergy() { public int getMaxEnergy() {
return MAX_ENERGY; return MAX_ENERGY;
} }
@Override
public ResourceLocation getVehicleIcon() {
return ModUtils.loc("textures/vehicle_icon/wheel_chair_icon.png");
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB