删除target,target_1更名为target

This commit is contained in:
Atsuihsio 2024-08-10 18:57:17 +08:00
parent 641870dff5
commit 53d1502e46
18 changed files with 138 additions and 480 deletions

View file

@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.block;
import net.mcreator.superbwarfare.entity.Mk42Entity;
import net.mcreator.superbwarfare.entity.Mle1934Entity;
import net.mcreator.superbwarfare.entity.Target1Entity;
import net.mcreator.superbwarfare.entity.TargetEntity;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.core.BlockPos;
@ -79,7 +79,7 @@ public class JumpPadBlock extends Block {
super.entityInside(blockstate, level, pos, entity);
// 禁止套娃
if (entity instanceof Target1Entity || entity instanceof Mk42Entity || entity instanceof Mle1934Entity) return;
if (entity instanceof TargetEntity || entity instanceof Mk42Entity || entity instanceof Mle1934Entity) return;
boolean zooming = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.zooming).orElse(false);

View file

@ -1,38 +0,0 @@
package net.mcreator.superbwarfare.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.mcreator.superbwarfare.entity.Target1Entity;
import net.mcreator.superbwarfare.entity.model.Target1Model;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;
public class Target1Renderer extends GeoEntityRenderer<Target1Entity> {
public Target1Renderer(EntityRendererProvider.Context renderManager) {
super(renderManager, new Target1Model());
this.shadowRadius = 0f;
}
@Override
public RenderType getRenderType(Target1Entity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
return RenderType.entityTranslucent(getTextureLocation(animatable));
}
@Override
public void preRender(PoseStack poseStack, Target1Entity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green,
float blue, float alpha) {
float scale = 1f;
this.scaleHeight = scale;
this.scaleWidth = scale;
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
}
@Override
protected float getDeathMaxRotation(Target1Entity entityLivingBaseIn) {
return 0.0F;
}
}

View file

@ -224,7 +224,7 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
var condition = this.getOwner() != target
&& target instanceof LivingEntity
&& !(target instanceof ClaymoreEntity)
&& !(target instanceof Target1Entity)
&& !(target instanceof TargetEntity)
&& !(target instanceof Player player && (player.isCreative() || player.isSpectator()))
&& (!this.isAlliedTo(target) || target.getTeam() == null || target.getTeam().getName().equals("TDM"))
&& !target.isShiftKeyDown();

View file

@ -358,7 +358,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
if (beast && entity instanceof LivingEntity living) {
if (living.isDeadOrDying()) return;
if (living instanceof Target1Entity) return;
if (living instanceof TargetEntity) return;
if (this.shooter instanceof ServerPlayer player) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));

View file

@ -1,275 +0,0 @@
package net.mcreator.superbwarfare.entity;
import net.mcreator.superbwarfare.init.ModEntities;
import net.mcreator.superbwarfare.init.ModItems;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.tools.SoundTool;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PlayMessages;
import software.bernie.geckolib.animatable.GeoEntity;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil;
// TODO 重置靶子
@Mod.EventBusSubscriber
public class Target1Entity extends PathfinderMob implements GeoEntity, AnimatedEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Integer> DOWN_TIME = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.INT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public String animationProcedure = "empty";
public Target1Entity(PlayMessages.SpawnEntity packet, Level world) {
this(ModEntities.TARGET_1.get(), world);
}
public Target1Entity(EntityType<Target1Entity> type, Level world) {
super(type, world);
xpReward = 0;
setNoAi(true);
setPersistenceRequired();
}
@Override
protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(ANIMATION, "undefined");
this.entityData.define(DOWN_TIME, 0);
}
@Override
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
protected PathNavigation createNavigation(Level world) {
return new FlyingPathNavigation(this, world);
}
@Override
public MobType getMobType() {
return super.getMobType();
}
@Override
public boolean removeWhenFarAway(double distanceToClosestPlayer) {
return false;
}
@Override
public boolean causeFallDamage(float l, float d, DamageSource source) {
return false;
}
@Override
public boolean hurt(DamageSource source, float amount) {
if (source.is(DamageTypes.IN_FIRE)
|| source.getDirectEntity() instanceof ThrownPotion
|| source.getDirectEntity() instanceof AreaEffectCloud
|| source.is(DamageTypes.FALL)
|| source.is(DamageTypes.CACTUS)
|| source.is(DamageTypes.DROWN)
|| source.is(DamageTypes.LIGHTNING_BOLT)
|| source.is(DamageTypes.FALLING_ANVIL)
|| source.is(DamageTypes.DRAGON_BREATH)
|| source.is(DamageTypes.WITHER)
|| source.is(DamageTypes.WITHER_SKULL)
|| source.is(DamageTypes.MAGIC)
|| this.entityData.get(DOWN_TIME) > 0) {
return false;
}
if (!this.level().isClientSide()) {
this.level().playSound(null, BlockPos.containing(this.getX(), this.getY(), this.getZ()), ModSounds.HIT.get(), SoundSource.BLOCKS, 8, 1);
} else {
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), ModSounds.HIT.get(), SoundSource.BLOCKS, 8, 1, false);
}
return super.hurt(source, amount);
}
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("DownTime", this.entityData.get(DOWN_TIME));
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
if (compound.contains("DownTime"))
this.entityData.set(DOWN_TIME, compound.getInt("DownTime"));
}
@SubscribeEvent
public static void onTarget1Down(LivingDeathEvent event) {
var entity = event.getEntity();
var sourceEntity = event.getSource().getEntity();
if (entity == null) return;
if (entity instanceof Target1Entity target1) {
event.setCanceled(true);
target1.setHealth(target1.getMaxHealth());
if (sourceEntity == null) return;
if (sourceEntity instanceof Player player) {
player.displayClientMessage(Component.literal(("Target Down " + new java.text.DecimalFormat("##.#").format((entity.position()).distanceTo((sourceEntity.position()))) + "M")), true);
SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 100, 1);
((Target1Entity) entity).entityData.set(DOWN_TIME,90);
}
}
}
@Override
public void die(DamageSource source) {
super.die(source);
}
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
InteractionResult result = InteractionResult.sidedSuccess(this.level().isClientSide());
super.mobInteract(player, hand);
if (player.isShiftKeyDown()) {
if (!this.level().isClientSide()) {
this.discard();
}
player.addItem(new ItemStack(ModItems.TARGET_DEPLOYER.get()));
} else {
if (!(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zooming) {
this.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((player.getX()), this.getY(), (player.getZ())));
this.setYRot(this.getYRot());
this.setXRot(0);
this.setYBodyRot(this.getYRot());
this.setYHeadRot(this.getYRot());
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
this.entityData.set(DOWN_TIME, 0);
}
}
return result;
}
@Override
public void baseTick() {
super.baseTick();
if (this.entityData.get(DOWN_TIME) > 0) {
this.entityData.set(DOWN_TIME,this.entityData.get(DOWN_TIME) - 1);
}
}
@Override
public boolean isPushable() {
return false;
}
@Override
protected void doPush(Entity entityIn) {
}
@Override
protected void pushEntities() {
}
@Override
protected void checkFallDamage(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
}
@Override
public void setNoGravity(boolean ignored) {
super.setNoGravity(true);
}
@Override
public void aiStep() {
super.aiStep();
this.updateSwingTime();
this.setNoGravity(true);
}
public static void init() {
}
public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes()
.add(Attributes.MOVEMENT_SPEED, 0)
.add(Attributes.MAX_HEALTH, 40)
.add(Attributes.ARMOR, 0)
.add(Attributes.ATTACK_DAMAGE, 0)
.add(Attributes.FOLLOW_RANGE, 16)
.add(Attributes.KNOCKBACK_RESISTANCE, 10)
.add(Attributes.FLYING_SPEED, 0);
}
@Override
protected void tickDeath() {
++this.deathTime;
if (this.deathTime >= 100) {
this.spawnAtLocation(new ItemStack(ModItems.TARGET_DEPLOYER.get()));
this.remove(Target1Entity.RemovalReason.KILLED);
}
}
public String getSyncedAnimation() {
return this.entityData.get(ANIMATION);
}
public void setAnimation(String animation) {
this.entityData.set(ANIMATION, animation);
}
@Override
public void setAnimationProcedure(String procedure) {
this.animationProcedure = procedure;
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.cache;
}
}

View file

@ -1,43 +1,52 @@
package net.mcreator.superbwarfare.entity;
import net.mcreator.superbwarfare.init.ModEntities;
import net.mcreator.superbwarfare.init.ModItems;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.tools.SoundTool;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PlayMessages;
import net.minecraftforge.registries.ForgeRegistries;
import software.bernie.geckolib.animatable.GeoEntity;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.core.animation.AnimationController;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil;
// TODO 重置靶子
@Mod.EventBusSubscriber
public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEntity {
public static final EntityDataAccessor<Boolean> SHOOT = SynchedEntityData.defineId(TargetEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(TargetEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Integer> DOWN_TIME = SynchedEntityData.defineId(TargetEntity.class, EntityDataSerializers.INT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public String animationProcedure = "empty";
public TargetEntity(PlayMessages.SpawnEntity packet, Level world) {
@ -49,14 +58,13 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
xpReward = 0;
setNoAi(true);
setPersistenceRequired();
this.moveControl = new FlyingMoveControl(this, 10, true);
}
@Override
protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(SHOOT, false);
this.entityData.define(ANIMATION, "undefined");
this.entityData.define(DOWN_TIME, 0);
}
@Override
@ -71,7 +79,7 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
@Override
public MobType getMobType() {
return MobType.UNDEFINED;
return super.getMobType();
}
@Override
@ -79,16 +87,6 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
return false;
}
@Override
public SoundEvent getHurtSound(DamageSource ds) {
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("superbwarfare:hit"));
}
@Override
public SoundEvent getDeathSound() {
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("superbwarfare:hit"));
}
@Override
public boolean causeFallDamage(float l, float d, DamageSource source) {
return false;
@ -96,51 +94,109 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
@Override
public boolean hurt(DamageSource source, float amount) {
if (source.is(DamageTypes.IN_FIRE))
return false;
if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud)
return false;
if (source.is(DamageTypes.FALL))
return false;
if (source.is(DamageTypes.CACTUS))
return false;
if (source.is(DamageTypes.DROWN))
return false;
if (source.is(DamageTypes.LIGHTNING_BOLT))
return false;
if (source.is(DamageTypes.EXPLOSION))
return false;
if (source.is(DamageTypes.FALLING_ANVIL))
return false;
if (source.is(DamageTypes.DRAGON_BREATH))
return false;
if (source.is(DamageTypes.WITHER))
return false;
if (source.is(DamageTypes.WITHER_SKULL))
if (source.is(DamageTypes.IN_FIRE)
|| source.getDirectEntity() instanceof ThrownPotion
|| source.getDirectEntity() instanceof AreaEffectCloud
|| source.is(DamageTypes.FALL)
|| source.is(DamageTypes.CACTUS)
|| source.is(DamageTypes.DROWN)
|| source.is(DamageTypes.LIGHTNING_BOLT)
|| source.is(DamageTypes.FALLING_ANVIL)
|| source.is(DamageTypes.DRAGON_BREATH)
|| source.is(DamageTypes.WITHER)
|| source.is(DamageTypes.WITHER_SKULL)
|| source.is(DamageTypes.MAGIC)
|| this.entityData.get(DOWN_TIME) > 0) {
return false;
}
if (!this.level().isClientSide()) {
this.level().playSound(null, BlockPos.containing(this.getX(), this.getY(), this.getZ()), ModSounds.HIT.get(), SoundSource.BLOCKS, 8, 1);
} else {
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), ModSounds.HIT.get(), SoundSource.BLOCKS, 8, 1, false);
}
return super.hurt(source, amount);
}
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("DownTime", this.entityData.get(DOWN_TIME));
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
if (compound.contains("DownTime"))
this.entityData.set(DOWN_TIME, compound.getInt("DownTime"));
}
@SubscribeEvent
public static void onTarget1Down(LivingDeathEvent event) {
var entity = event.getEntity();
var sourceEntity = event.getSource().getEntity();
if (entity == null) return;
if (entity instanceof TargetEntity target1) {
event.setCanceled(true);
target1.setHealth(target1.getMaxHealth());
if (sourceEntity == null) return;
if (sourceEntity instanceof Player player) {
player.displayClientMessage(Component.literal(("Target Down " + new java.text.DecimalFormat("##.#").format((entity.position()).distanceTo((sourceEntity.position()))) + "M")), true);
SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 100, 1);
((TargetEntity) entity).entityData.set(DOWN_TIME,90);
}
}
}
@Override
public void die(DamageSource source) {
super.die(source);
}
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
InteractionResult result = InteractionResult.sidedSuccess(this.level().isClientSide());
super.mobInteract(player, hand);
if (player.isShiftKeyDown()) {
if (!this.level().isClientSide()) {
this.discard();
}
player.addItem(new ItemStack(ModItems.TARGET_DEPLOYER.get()));
} else {
if (!(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zooming) {
this.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((player.getX()), this.getY(), (player.getZ())));
this.setYRot(this.getYRot());
this.setXRot(0);
this.setYBodyRot(this.getYRot());
this.setYHeadRot(this.getYRot());
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
this.entityData.set(DOWN_TIME, 0);
}
}
return result;
}
@Override
public void baseTick() {
super.baseTick();
this.refreshDimensions();
if (this.entityData.get(DOWN_TIME) > 0) {
this.entityData.set(DOWN_TIME,this.entityData.get(DOWN_TIME) - 1);
}
}
@Override
public EntityDimensions getDimensions(Pose p_33597_) {
return super.getDimensions(p_33597_).scale((float) 1);
}
@Override
public boolean isPushable() {
@ -177,7 +233,7 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes()
.add(Attributes.MOVEMENT_SPEED, 0)
.add(Attributes.MAX_HEALTH, 5)
.add(Attributes.MAX_HEALTH, 40)
.add(Attributes.ARMOR, 0)
.add(Attributes.ATTACK_DAMAGE, 0)
.add(Attributes.FOLLOW_RANGE, 16)
@ -185,43 +241,20 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
.add(Attributes.FLYING_SPEED, 0);
}
private PlayState movementPredicate(AnimationState event) {
if (this.animationProcedure.equals("empty")) {
if (this.isDeadOrDying()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.target2.down"));
}
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.target2.idle"));
}
return PlayState.STOP;
}
private PlayState procedurePredicate(AnimationState event) {
if (!animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
this.animationProcedure = "empty";
event.getController().forceAnimationReset();
}
} else if (animationProcedure.equals("empty")) {
return PlayState.STOP;
}
return PlayState.CONTINUE;
}
@Override
protected void tickDeath() {
++this.deathTime;
if (this.deathTime >= 20) {
this.remove(Target1Entity.RemovalReason.KILLED);
if (this.deathTime >= 100) {
this.spawnAtLocation(new ItemStack(ModItems.TARGET_DEPLOYER.get()));
this.remove(TargetEntity.RemovalReason.KILLED);
}
}
@Override
public String getSyncedAnimation() {
return this.entityData.get(ANIMATION);
}
@Override
public void setAnimation(String animation) {
this.entityData.set(ANIMATION, animation);
}
@ -233,8 +266,6 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
data.add(new AnimationController<>(this, "procedure", 0, this::procedurePredicate));
}
@Override

View file

@ -13,7 +13,7 @@ import software.bernie.geckolib.renderer.GeoRenderer;
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
public class TargetLayer extends GeoRenderLayer<TargetEntity> {
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/entities/target_e.png");
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/entity/target_e.png");
public TargetLayer(GeoRenderer<TargetEntity> entityRenderer) {
super(entityRenderer);

View file

@ -1,38 +0,0 @@
package net.mcreator.superbwarfare.entity.model;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.Target1Entity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import static net.mcreator.superbwarfare.entity.Target1Entity.DOWN_TIME;
public class Target1Model extends GeoModel<Target1Entity> {
@Override
public ResourceLocation getAnimationResource(Target1Entity entity) {
return new ResourceLocation(ModUtils.MODID, "animations/target.animation.json");
}
@Override
public ResourceLocation getModelResource(Target1Entity entity) {
return new ResourceLocation(ModUtils.MODID, "geo/target.geo.json");
}
@Override
public ResourceLocation getTextureResource(Target1Entity entity) {
return new ResourceLocation(ModUtils.MODID, "textures/entity/target.png");
}
@Override
public void setCustomAnimations(Target1Entity animatable, long instanceId, AnimationState animationState) {
CoreGeoBone head = getAnimationProcessor().getBone("ba");
if (animatable.getEntityData().get(DOWN_TIME) > 20) {
head.setRotX(Mth.clamp(90 - animatable.getEntityData().get(DOWN_TIME),0,3) * 30 * Mth.DEG_TO_RAD);
} else {
head.setRotX(4.5f * animatable.getEntityData().get(DOWN_TIME) * Mth.DEG_TO_RAD);
}
}
}

View file

@ -3,22 +3,36 @@ package net.mcreator.superbwarfare.entity.model;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.TargetEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import static net.mcreator.superbwarfare.entity.TargetEntity.DOWN_TIME;
public class TargetModel extends GeoModel<TargetEntity> {
@Override
public ResourceLocation getAnimationResource(TargetEntity entity) {
return new ResourceLocation(ModUtils.MODID, "animations/target2.animation.json");
return new ResourceLocation(ModUtils.MODID, "animations/target.animation.json");
}
@Override
public ResourceLocation getModelResource(TargetEntity entity) {
return new ResourceLocation(ModUtils.MODID, "geo/target2.geo.json");
return new ResourceLocation(ModUtils.MODID, "geo/target.geo.json");
}
@Override
public ResourceLocation getTextureResource(TargetEntity entity) {
return new ResourceLocation(ModUtils.MODID, "textures/entity/superbwarfare.png");
return new ResourceLocation(ModUtils.MODID, "textures/entity/target.png");
}
@Override
public void setCustomAnimations(TargetEntity animatable, long instanceId, AnimationState animationState) {
CoreGeoBone head = getAnimationProcessor().getBone("ba");
if (animatable.getEntityData().get(DOWN_TIME) > 20) {
head.setRotX(Mth.clamp(90 - animatable.getEntityData().get(DOWN_TIME),0,3) * 30 * Mth.DEG_TO_RAD);
} else {
head.setRotX(4.5f * animatable.getEntityData().get(DOWN_TIME) * Mth.DEG_TO_RAD);
}
}
}

View file

@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.event;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.ProjectileEntity;
import net.mcreator.superbwarfare.entity.Target1Entity;
import net.mcreator.superbwarfare.entity.TargetEntity;
import net.mcreator.superbwarfare.init.*;
import net.mcreator.superbwarfare.item.gun.GunItem;
import net.mcreator.superbwarfare.network.ModVariables;
@ -90,7 +90,7 @@ public class LivingEventHandler {
stack.getOrCreateTag().putDouble("damagetotal", stack.getOrCreateTag().getDouble("damagetotal") + damage);
}
if (entity instanceof Target1Entity && sourceentity instanceof Player player) {
if (entity instanceof TargetEntity && sourceentity instanceof Player player) {
player.displayClientMessage(Component.literal("Damage:" + new java.text.DecimalFormat("##.#").format(damage) + " Distance:" + new java.text.DecimalFormat("##.#").format((entity.position()).distanceTo((sourceentity.position()))) + "M"), false);
}
}

View file

@ -41,7 +41,7 @@ public class BoundingBoxManager {
return new AABB(headBox.minX * scale, headBox.minY * scale, headBox.minZ * scale, headBox.maxX * scale, headBox.maxY * scale, headBox.maxZ * scale);
});
registerHeadshotBox(ModEntities.SENPAI.get(), new BasicHeadshotBox<>(8.0, 22.0));
registerHeadshotBox(ModEntities.TARGET_1.get(), new BasicHeadshotBox<>(14.0, 20.0));
registerHeadshotBox(ModEntities.TARGET.get(), new BasicHeadshotBox<>(14.0, 20.0));
registerHeadshotBox(EntityType.ENDERMAN, new BasicHeadshotBox<>(8.0, 38.0));
registerHeadshotBox(EntityType.ZOMBIE, new ChildHeadshotBox<>(8.0, 26.0, 0.75, 0.5));
registerHeadshotBox(EntityType.ZOMBIFIED_PIGLIN, new ChildHeadshotBox<>(8.0, 26.0, 0.75, 0.5));

View file

@ -17,8 +17,8 @@ import net.minecraftforge.registries.RegistryObject;
public class ModEntities {
public static final DeferredRegister<EntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ModUtils.MODID);
public static final RegistryObject<EntityType<Target1Entity>> TARGET_1 = register("target_1",
EntityType.Builder.<Target1Entity>of(Target1Entity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(Target1Entity::new).fireImmune().sized(0.875f, 2f));
public static final RegistryObject<EntityType<TargetEntity>> TARGET = register("target",
EntityType.Builder.<TargetEntity>of(TargetEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(TargetEntity::new).fireImmune().sized(0.875f, 2f));
public static final RegistryObject<EntityType<MortarEntity>> MORTAR = register("mortar",
EntityType.Builder.<MortarEntity>of(MortarEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(MortarEntity::new).fireImmune().sized(0.8f, 1.4f));
public static final RegistryObject<EntityType<SenpaiEntity>> SENPAI = register("senpai",
@ -42,8 +42,6 @@ public class ModEntities {
public static final RegistryObject<EntityType<FragEntity>> FRAG = register("projectile_frag",
EntityType.Builder.<FragEntity>of(FragEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(1).setCustomClientFactory(FragEntity::new).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<TargetEntity>> TARGET = register("target",
EntityType.Builder.<TargetEntity>of(TargetEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(TargetEntity::new).fireImmune().sized(0.875f, 2f));
public static final RegistryObject<EntityType<RpgRocketEntity>> RPG_ROCKET = register("projectile_rpg_rocket",
EntityType.Builder.<RpgRocketEntity>of(RpgRocketEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).setCustomClientFactory(RpgRocketEntity::new).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<MortarShellEntity>> MORTAR_SHELL = register("projectile_mortar_shell",
@ -71,11 +69,10 @@ public class ModEntities {
@SubscribeEvent
public static void registerAttributes(EntityAttributeCreationEvent event) {
event.put(TARGET_1.get(), Target1Entity.createAttributes().build());
event.put(TARGET.get(), TargetEntity.createAttributes().build());
event.put(MORTAR.get(), MortarEntity.createAttributes().build());
event.put(SENPAI.get(), SenpaiEntity.createAttributes().build());
event.put(CLAYMORE.get(), ClaymoreEntity.createAttributes().build());
event.put(TARGET.get(), TargetEntity.createAttributes().build());
event.put(MK_42.get(), Mk42Entity.createAttributes().build());
event.put(DRONE.get(), DroneEntity.createAttributes().build());
event.put(MLE_1934.get(), Mle1934Entity.createAttributes().build());

View file

@ -10,7 +10,6 @@ import net.minecraftforge.fml.common.Mod;
public class ModEntityRenderers {
@SubscribeEvent
public static void registerEntityRenderers(EntityRenderersEvent.RegisterRenderers event) {
event.registerEntityRenderer(ModEntities.TARGET_1.get(), Target1Renderer::new);
event.registerEntityRenderer(ModEntities.MORTAR.get(), MortarRenderer::new);
event.registerEntityRenderer(ModEntities.SENPAI.get(), SenpaiRenderer::new);
event.registerEntityRenderer(ModEntities.CLAYMORE.get(), ClaymoreRenderer::new);

View file

@ -46,7 +46,7 @@ public class TargetDeployer extends Item {
blockpos1 = blockpos.relative(direction);
}
if (ModEntities.TARGET_1.get().spawn((ServerLevel)level, itemstack, pContext.getPlayer(), blockpos1, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) {
if (ModEntities.TARGET.get().spawn((ServerLevel)level, itemstack, pContext.getPlayer(), blockpos1, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) {
itemstack.shrink(1);
level.gameEvent(pContext.getPlayer(), GameEvent.ENTITY_PLACE, blockpos);
}
@ -68,7 +68,7 @@ public class TargetDeployer extends Item {
if (!(pLevel.getBlockState(blockpos).getBlock() instanceof LiquidBlock)) {
return InteractionResultHolder.pass(itemstack);
} else if (pLevel.mayInteract(pPlayer, blockpos) && pPlayer.mayUseItemAt(blockpos, blockhitresult.getDirection(), itemstack)) {
Entity entity = ModEntities.TARGET_1.get().spawn((ServerLevel)pLevel, itemstack, pPlayer, blockpos, MobSpawnType.SPAWN_EGG, false, false);
Entity entity = ModEntities.TARGET.get().spawn((ServerLevel)pLevel, itemstack, pPlayer, blockpos, MobSpawnType.SPAWN_EGG, false, false);
if (entity == null) {
return InteractionResultHolder.pass(itemstack);
} else {

View file

@ -1,30 +0,0 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.unknown",
"texture_width": 128,
"texture_height": 128,
"visible_bounds_width": 2,
"visible_bounds_height": 3.5,
"visible_bounds_offset": [0, 1.25, 0]
},
"bones": [
{
"name": "0",
"pivot": [0, 0, 0]
},
{
"name": "ba",
"parent": "0",
"pivot": [0, 0.5, 0],
"cubes": [
{"origin": [-7, 4, -0.5], "size": [14, 28, 1], "uv": [0, 0]},
{"origin": [-7, 0, -0.5], "size": [14, 4, 1], "uv": [0, 18]}
]
}
]
}
]
}

View file

@ -246,7 +246,6 @@
"entity.superbwarfare.projectile_rgo_grenade": "Exploding RGO Grenade",
"entity.superbwarfare.mortar": "Mortar",
"entity.superbwarfare.target": "Target",
"entity.superbwarfare.target_1": "Target",
"entity.superbwarfare.claymore": "Claymore",
"entity.superbwarfare.senpai": "Senpai",
"entity.superbwarfare.mk_42": "5''/54 Mk42",

View file

@ -246,7 +246,6 @@
"entity.superbwarfare.projectile_rgo_grenade": "快爆炸的RGO手榴弹",
"entity.superbwarfare.mortar": "迫击炮",
"entity.superbwarfare.target": "标靶",
"entity.superbwarfare.target_1": "标靶",
"entity.superbwarfare.claymore": "阔剑地雷",
"entity.superbwarfare.senpai": "野兽先辈",
"entity.superbwarfare.mk_42": "5''/54 Mk42",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 261 B