添加新的伤害类型标签

This commit is contained in:
17146 2025-06-24 01:47:23 +08:00 committed by Light_Quanta
parent 25dcbfd983
commit cf76e84186
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
8 changed files with 98 additions and 33 deletions

View file

@ -1,3 +1,5 @@
// 1.21.1 2025-03-27T19:46:28.6414823 Tags for minecraft:damage_type mod id superbwarfare
af0be8dca0b255f58322d79eff933eb855406f6b data/superbwarfare/tags/damage_type/projectile.json
3f7d47fe61dde5ebb1ecb7f0f2a4804dc1c8478d data/superbwarfare/tags/damage_type/projectile_absolute.json
// 1.21.1 2025-06-24T02:18:26.2390652 Tags for minecraft:damage_type mod id superbwarfare
ddb620a872e399a1733001853474cf0b7eb9dc88 data/superbwarfare/tags/damage_type/projectile.json
a14ba1399ece410382dce60dda85902fdd87bf23 data/superbwarfare/tags/damage_type/projectile_absolute.json
49e069125ecef20d6b00fd22e219bfdee5b90b9b data/superbwarfare/tags/damage_type/vehicle_ignore.json
146a85f38dd9a68950693b6493db746c1c1b7918 data/superbwarfare/tags/damage_type/vehicle_not_absorb.json

View file

@ -4,6 +4,34 @@
"superbwarfare:gunfire_headshot",
"minecraft:arrow",
"minecraft:trident",
"minecraft:thrown"
"minecraft:thrown",
{
"id": "tacz:bullet",
"required": false
},
{
"id": "tacz:bullet_void",
"required": false
},
{
"id": "virtuarealcraft:rain_crystal",
"required": false
},
{
"id": "virtuarealcraft:rain_shower_butterfly",
"required": false
},
{
"id": "virtuarealcraft:sparkle_butterfly",
"required": false
},
{
"id": "dreamaticvoyage:blood_crystal",
"required": false
},
{
"id": "dreamaticvoyage:leviy_beam",
"required": false
}
]
}

View file

@ -1,6 +1,18 @@
{
"values": [
"superbwarfare:gunfire_absolute",
"superbwarfare:gunfire_headshot_absolute"
"superbwarfare:gunfire_headshot_absolute",
{
"id": "tacz:bullet_ignore_armor",
"required": false
},
{
"id": "tacz:bullet_void_ignore_armor",
"required": false
},
{
"id": "dreamaticvoyage:leviy_beam_absolute",
"required": false
}
]
}

View file

@ -0,0 +1,8 @@
{
"values": [
{
"id": "sona:injury",
"required": false
}
]
}

View file

@ -0,0 +1,9 @@
{
"values": [
"minecraft:explosion",
"minecraft:player_explosion",
"superbwarfare:custom_explosion",
"superbwarfare:mine",
"superbwarfare:projectile_boom"
]
}

View file

@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.init.ModTags;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.DamageTypeTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.damagesource.DamageTypes;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
@ -22,18 +23,21 @@ public class ModDamageTypeTagProvider extends DamageTypeTagsProvider {
@Override
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
this.tag(ModTags.DamageTypes.PROJECTILE).add(ModDamageTypes.GUN_FIRE, ModDamageTypes.GUN_FIRE_HEADSHOT,
DamageTypes.ARROW, DamageTypes.TRIDENT, DamageTypes.THROWN);
// .addOptional(new ResourceLocation("tacz", "bullet"))
// .addOptional(new ResourceLocation("tacz", "bullet_void"))
// .addOptional(new ResourceLocation("virtuarealcraft", "rain_crystal"))
// .addOptional(new ResourceLocation("virtuarealcraft", "rain_shower_butterfly"))
// .addOptional(new ResourceLocation("virtuarealcraft", "sparkle_butterfly"))
// .addOptional(new ResourceLocation("dreamaticvoyage", "blood_crystal"))
// .addOptional(new ResourceLocation("dreamaticvoyage", "leviy_beam"));
this.tag(ModTags.DamageTypes.PROJECTILE_ABSOLUTE).add(ModDamageTypes.GUN_FIRE_ABSOLUTE, ModDamageTypes.GUN_FIRE_HEADSHOT_ABSOLUTE);
// .addOptional(new ResourceLocation("tacz", "bullet_ignore_armor"))
// .addOptional(new ResourceLocation("tacz", "bullet_void_ignore_armor"))
// .addOptional(new ResourceLocation("dreamaticvoyage", "leviy_beam_absolute"));
DamageTypes.ARROW, DamageTypes.TRIDENT, DamageTypes.THROWN)
.addOptional(ResourceLocation.fromNamespaceAndPath("tacz", "bullet"))
.addOptional(ResourceLocation.fromNamespaceAndPath("tacz", "bullet_void"))
.addOptional(ResourceLocation.fromNamespaceAndPath("virtuarealcraft", "rain_crystal"))
.addOptional(ResourceLocation.fromNamespaceAndPath("virtuarealcraft", "rain_shower_butterfly"))
.addOptional(ResourceLocation.fromNamespaceAndPath("virtuarealcraft", "sparkle_butterfly"))
.addOptional(ResourceLocation.fromNamespaceAndPath("dreamaticvoyage", "blood_crystal"))
.addOptional(ResourceLocation.fromNamespaceAndPath("dreamaticvoyage", "leviy_beam"));
this.tag(ModTags.DamageTypes.PROJECTILE_ABSOLUTE).add(ModDamageTypes.GUN_FIRE_ABSOLUTE, ModDamageTypes.GUN_FIRE_HEADSHOT_ABSOLUTE)
.addOptional(ResourceLocation.fromNamespaceAndPath("tacz", "bullet_ignore_armor"))
.addOptional(ResourceLocation.fromNamespaceAndPath("tacz", "bullet_void_ignore_armor"))
.addOptional(ResourceLocation.fromNamespaceAndPath("dreamaticvoyage", "leviy_beam_absolute"));
this.tag(ModTags.DamageTypes.VEHICLE_IGNORE)
.addOptional(ResourceLocation.fromNamespaceAndPath("sona", "injury"));
this.tag(ModTags.DamageTypes.VEHICLE_NOT_ABSORB)
.add(DamageTypes.EXPLOSION, DamageTypes.PLAYER_EXPLOSION, ModDamageTypes.CUSTOM_EXPLOSION, ModDamageTypes.MINE, ModDamageTypes.PROJECTILE_BOOM);
}
}

View file

@ -101,23 +101,20 @@ public class LivingEventHandler {
private static void handleVehicleHurt(LivingIncomingDamageEvent event) {
var vehicle = event.getEntity().getVehicle();
if (vehicle instanceof VehicleEntity) {
if (vehicle instanceof ArmedVehicleEntity iArmedVehicle) {
if (iArmedVehicle.hidePassenger(event.getEntity())) {
if (!event.getSource().is(ModDamageTypes.VEHICLE_EXPLOSION)) {
event.setCanceled(true);
}
} else {
if (!(event.getSource().is(DamageTypes.EXPLOSION)
|| event.getSource().is(DamageTypes.PLAYER_EXPLOSION)
|| event.getSource().is(ModDamageTypes.CUSTOM_EXPLOSION)
|| event.getSource().is(ModDamageTypes.MINE)
|| event.getSource().is(ModDamageTypes.PROJECTILE_BOOM))) {
vehicle.hurt(event.getSource(), 0.7f * event.getAmount());
}
if (vehicle instanceof VehicleEntity && vehicle instanceof ArmedVehicleEntity iArmedVehicle) {
var source = event.getSource();
if (source.is(ModTags.DamageTypes.VEHICLE_IGNORE)) return;
event.setAmount(0.3f * event.getAmount());
if (iArmedVehicle.hidePassenger(event.getEntity())) {
if (!source.is(ModDamageTypes.VEHICLE_EXPLOSION)) {
event.setCanceled(true);
}
} else {
if (!source.is(ModTags.DamageTypes.VEHICLE_NOT_ABSORB)) {
vehicle.hurt(event.getSource(), 0.7f * event.getAmount());
}
event.setAmount(0.3f * event.getAmount());
}
}
}

View file

@ -60,6 +60,11 @@ public class ModTags {
public static final TagKey<DamageType> PROJECTILE = tag("projectile");
public static final TagKey<DamageType> PROJECTILE_ABSOLUTE = tag("projectile_absolute");
// 在载具上的实体受到带有此标签的伤害类型的伤害时不会将伤害转移到载具上
public static final TagKey<DamageType> VEHICLE_IGNORE = tag("vehicle_ignore");
// 在载具上的实体受到带有此标签的伤害类型的伤害时只会受到伤害减免而不会转移到载具上
public static final TagKey<DamageType> VEHICLE_NOT_ABSORB = tag("vehicle_not_absorb");
private static TagKey<DamageType> tag(String name) {
return TagKey.create(Registries.DAMAGE_TYPE, Mod.loc(name));
}