添加实体标签

This commit is contained in:
17146 2025-06-12 17:49:38 +08:00 committed by Light_Quanta
parent 40a8920648
commit 6447d92f81
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
13 changed files with 84 additions and 10 deletions

View file

@ -0,0 +1,3 @@
// 1.21.1 2025-06-12T21:56:29.8001208 Tags for minecraft:entity_type mod id superbwarfare
4b66f399cf351dc05891ad11d0e94889962a4327 data/superbwarfare/tags/entity_type/aerial_bomb.json
dab439adf745fde8ee3ecf56a40c617dfedc9c47 data/superbwarfare/tags/entity_type/destroyable_projectile.json

View file

@ -0,0 +1,6 @@
{
"values": [
"superbwarfare:melon_bomb",
"superbwarfare:mk_82"
]
}

View file

@ -0,0 +1,10 @@
{
"values": [
"superbwarfare:agm_65",
"superbwarfare:javelin_missile",
"superbwarfare:melon_bomb",
"superbwarfare:mk_82",
"superbwarfare:swarm_drone",
"superbwarfare:wg_missile"
]
}

View file

@ -27,6 +27,7 @@ public class DataGenerators {
generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper));
ModBlockTagProvider tagProvider = generator.addProvider(event.includeServer(), new ModBlockTagProvider(packOutput, lookupProvider, existingFileHelper));
generator.addProvider(event.includeServer(), new ModItemTagProvider(packOutput, lookupProvider, tagProvider.contentsGetter(), existingFileHelper));
generator.addProvider(event.includeServer(), new ModEntityTypeTagProvider(packOutput, lookupProvider, existingFileHelper));
generator.addProvider(event.includeServer(), new ModDamageTypeTagProvider(packOutput, lookupProvider, existingFileHelper));
generator.addProvider(event.includeServer(), new ModAdvancementProvider(packOutput, lookupProvider, existingFileHelper));
}

View file

@ -0,0 +1,45 @@
package com.atsuishio.superbwarfare.datagen;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModTags;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.EntityTypeTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
public class ModEntityTypeTagProvider extends EntityTypeTagsProvider {
public ModEntityTypeTagProvider(PackOutput pOutput, CompletableFuture<HolderLookup.Provider> pProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(pOutput, pProvider, Mod.MODID, existingFileHelper);
}
@Override
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
this.tag(ModTags.EntityTypes.AERIAL_BOMB).add(
ModEntities.MELON_BOMB.get(),
ModEntities.MK_82.get()
);
this.tag(ModTags.EntityTypes.DESTROYABLE_PROJECTILE).add(
ModEntities.AGM_65.get(),
ModEntities.JAVELIN_MISSILE.get(),
ModEntities.MELON_BOMB.get(),
ModEntities.MK_82.get(),
ModEntities.SWARM_DRONE.get(),
ModEntities.WG_MISSILE.get()
);
}
public static TagKey<EntityType<?>> cTag(String name) {
return TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath("c", name));
}
}

View file

@ -48,7 +48,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.List;
public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, DestroyableProjectileEntity, ExplosiveProjectile {
public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, ExplosiveProjectile {
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Agm65Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(Agm65Entity.class, EntityDataSerializers.STRING);
@ -58,8 +58,6 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, D
private float explosionDamage = ExplosionConfig.AGM_65_EXPLOSION_DAMAGE.get();
private float explosionRadius = ExplosionConfig.AGM_65_EXPLOSION_RADIUS.get().floatValue();
private boolean distracted = false;
private int durability = 40;
private boolean firstHit = true;
public Agm65Entity(EntityType<? extends Agm65Entity> type, Level world) {
super(type, world);

View file

@ -49,7 +49,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.List;
public class JavelinMissileEntity extends FastThrowableProjectile implements GeoEntity, DestroyableProjectileEntity, ExplosiveProjectile {
public class JavelinMissileEntity extends FastThrowableProjectile implements GeoEntity, ExplosiveProjectile {
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(JavelinMissileEntity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(JavelinMissileEntity.class, EntityDataSerializers.STRING);

View file

@ -18,7 +18,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;
public class MelonBombEntity extends FastThrowableProjectile implements DestroyableProjectileEntity, AerialBombEntity {
public class MelonBombEntity extends FastThrowableProjectile implements ExplosiveProjectile {
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(MelonBombEntity.class, EntityDataSerializers.FLOAT);

View file

@ -26,7 +26,7 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.animation.*;
import software.bernie.geckolib.util.GeckoLibUtil;
public class Mk82Entity extends FastThrowableProjectile implements GeoEntity, DestroyableProjectileEntity, AerialBombEntity {
public class Mk82Entity extends FastThrowableProjectile implements GeoEntity, ExplosiveProjectile {
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mk82Entity.class, EntityDataSerializers.FLOAT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);

View file

@ -44,7 +44,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import javax.annotation.Nullable;
import java.util.List;
public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEntity, DestroyableProjectileEntity, ExplosiveProjectile {
public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEntity, ExplosiveProjectile {
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(SwarmDroneEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Float> TARGET_X = SynchedEntityData.defineId(SwarmDroneEntity.class, EntityDataSerializers.FLOAT);

View file

@ -43,7 +43,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import javax.annotation.Nullable;
public class WgMissileEntity extends FastThrowableProjectile implements GeoEntity, DestroyableProjectileEntity, ExplosiveProjectile {
public class WgMissileEntity extends FastThrowableProjectile implements GeoEntity, ExplosiveProjectile {
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(WgMissileEntity.class, EntityDataSerializers.FLOAT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);

View file

@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.entity.vehicle;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.AerialBombEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
@ -16,6 +15,7 @@ import com.atsuishio.superbwarfare.event.ClientMouseHandler;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.tools.*;
import com.mojang.math.Axis;
import it.unimi.dsi.fastutil.Pair;
@ -136,7 +136,8 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
public DamageModifier getDamageModifier() {
return super.getDamageModifier()
.custom((source, damage) -> {
if (source.getDirectEntity() instanceof AerialBombEntity) {
var entity = source.getDirectEntity();
if (entity != null && entity.getType().is(ModTags.EntityTypes.AERIAL_BOMB)) {
damage *= 2;
}
damage *= getHealth() > 0.1f ? 0.7f : 0.05f;

View file

@ -6,6 +6,7 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
@ -63,4 +64,13 @@ public class ModTags {
return TagKey.create(Registries.DAMAGE_TYPE, Mod.loc(name));
}
}
public static class EntityTypes {
public static final TagKey<EntityType<?>> AERIAL_BOMB = tag("aerial_bomb");
public static final TagKey<EntityType<?>> DESTROYABLE_PROJECTILE = tag("destroyable_projectile");
private static TagKey<EntityType<?>> tag(String name) {
return TagKey.create(Registries.ENTITY_TYPE, Mod.loc(name));
}
}
}