From 53d1502e463afe1e427b771d146a4b0759a8e045 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Sat, 10 Aug 2024 18:57:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4target=EF=BC=8Ctarget=5F1?= =?UTF-8?q?=E6=9B=B4=E5=90=8D=E4=B8=BAtarget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/block/JumpPadBlock.java | 4 +- .../renderer/entity/Target1Renderer.java | 38 --- .../superbwarfare/entity/ClaymoreEntity.java | 2 +- .../entity/ProjectileEntity.java | 2 +- .../superbwarfare/entity/Target1Entity.java | 275 ------------------ .../superbwarfare/entity/TargetEntity.java | 185 +++++++----- .../entity/layer/TargetLayer.java | 2 +- .../entity/model/Target1Model.java | 38 --- .../entity/model/TargetModel.java | 20 +- .../event/LivingEventHandler.java | 4 +- .../headshot/BoundingBoxManager.java | 2 +- .../superbwarfare/init/ModEntities.java | 9 +- .../init/ModEntityRenderers.java | 1 - .../superbwarfare/item/TargetDeployer.java | 4 +- .../assets/superbwarfare/geo/target2.geo.json | 30 -- .../assets/superbwarfare/lang/en_us.json | 1 - .../assets/superbwarfare/lang/zh_cn.json | 1 - .../textures/entity/target_e.png | Bin 266 -> 261 bytes 18 files changed, 138 insertions(+), 480 deletions(-) delete mode 100644 src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Target1Renderer.java delete mode 100644 src/main/java/net/mcreator/superbwarfare/entity/Target1Entity.java delete mode 100644 src/main/java/net/mcreator/superbwarfare/entity/model/Target1Model.java delete mode 100644 src/main/resources/assets/superbwarfare/geo/target2.geo.json diff --git a/src/main/java/net/mcreator/superbwarfare/block/JumpPadBlock.java b/src/main/java/net/mcreator/superbwarfare/block/JumpPadBlock.java index 16a484914..f307e72b3 100644 --- a/src/main/java/net/mcreator/superbwarfare/block/JumpPadBlock.java +++ b/src/main/java/net/mcreator/superbwarfare/block/JumpPadBlock.java @@ -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); diff --git a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Target1Renderer.java b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Target1Renderer.java deleted file mode 100644 index 60a72cde7..000000000 --- a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Target1Renderer.java +++ /dev/null @@ -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 { - 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; - } -} diff --git a/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java index 67b7137d1..b528b0aa4 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java @@ -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(); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/ProjectileEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/ProjectileEntity.java index c936e2051..b7c51efaf 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/ProjectileEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/ProjectileEntity.java @@ -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)); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/Target1Entity.java b/src/main/java/net/mcreator/superbwarfare/entity/Target1Entity.java deleted file mode 100644 index 894614e3a..000000000 --- a/src/main/java/net/mcreator/superbwarfare/entity/Target1Entity.java +++ /dev/null @@ -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 ANIMATION = SynchedEntityData.defineId(Target1Entity.class, EntityDataSerializers.STRING); - public static final EntityDataAccessor 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 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 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; - } -} diff --git a/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java index 5653c9d38..4aec8c4f4 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java @@ -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 SHOOT = SynchedEntityData.defineId(TargetEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor ANIMATION = SynchedEntityData.defineId(TargetEntity.class, EntityDataSerializers.STRING); + public static final EntityDataAccessor 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 diff --git a/src/main/java/net/mcreator/superbwarfare/entity/layer/TargetLayer.java b/src/main/java/net/mcreator/superbwarfare/entity/layer/TargetLayer.java index 715306b71..1819cda57 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/layer/TargetLayer.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/layer/TargetLayer.java @@ -13,7 +13,7 @@ import software.bernie.geckolib.renderer.GeoRenderer; import software.bernie.geckolib.renderer.layer.GeoRenderLayer; public class TargetLayer extends GeoRenderLayer { - 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 entityRenderer) { super(entityRenderer); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/model/Target1Model.java b/src/main/java/net/mcreator/superbwarfare/entity/model/Target1Model.java deleted file mode 100644 index 6140e9ac2..000000000 --- a/src/main/java/net/mcreator/superbwarfare/entity/model/Target1Model.java +++ /dev/null @@ -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 { - @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); - } - } -} diff --git a/src/main/java/net/mcreator/superbwarfare/entity/model/TargetModel.java b/src/main/java/net/mcreator/superbwarfare/entity/model/TargetModel.java index 4164855c4..d127c341e 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/model/TargetModel.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/model/TargetModel.java @@ -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 { @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); + } + } } diff --git a/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java index 54ec0d094..ea0dd16a6 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/LivingEventHandler.java @@ -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); } } diff --git a/src/main/java/net/mcreator/superbwarfare/headshot/BoundingBoxManager.java b/src/main/java/net/mcreator/superbwarfare/headshot/BoundingBoxManager.java index b6c27bb8e..c725502f0 100644 --- a/src/main/java/net/mcreator/superbwarfare/headshot/BoundingBoxManager.java +++ b/src/main/java/net/mcreator/superbwarfare/headshot/BoundingBoxManager.java @@ -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)); diff --git a/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java b/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java index 9c9552346..51edc483d 100644 --- a/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java +++ b/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java @@ -17,8 +17,8 @@ import net.minecraftforge.registries.RegistryObject; public class ModEntities { public static final DeferredRegister> REGISTRY = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ModUtils.MODID); - public static final RegistryObject> TARGET_1 = register("target_1", - EntityType.Builder.of(Target1Entity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(Target1Entity::new).fireImmune().sized(0.875f, 2f)); + public static final RegistryObject> TARGET = register("target", + EntityType.Builder.of(TargetEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(TargetEntity::new).fireImmune().sized(0.875f, 2f)); public static final RegistryObject> MORTAR = register("mortar", EntityType.Builder.of(MortarEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(MortarEntity::new).fireImmune().sized(0.8f, 1.4f)); public static final RegistryObject> SENPAI = register("senpai", @@ -42,8 +42,6 @@ public class ModEntities { public static final RegistryObject> FRAG = register("projectile_frag", EntityType.Builder.of(FragEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(1).setCustomClientFactory(FragEntity::new).sized(0.5f, 0.5f)); - public static final RegistryObject> TARGET = register("target", - EntityType.Builder.of(TargetEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(TargetEntity::new).fireImmune().sized(0.875f, 2f)); public static final RegistryObject> RPG_ROCKET = register("projectile_rpg_rocket", EntityType.Builder.of(RpgRocketEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).setCustomClientFactory(RpgRocketEntity::new).sized(0.5f, 0.5f)); public static final RegistryObject> 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()); diff --git a/src/main/java/net/mcreator/superbwarfare/init/ModEntityRenderers.java b/src/main/java/net/mcreator/superbwarfare/init/ModEntityRenderers.java index 34304aa8e..e4c641227 100644 --- a/src/main/java/net/mcreator/superbwarfare/init/ModEntityRenderers.java +++ b/src/main/java/net/mcreator/superbwarfare/init/ModEntityRenderers.java @@ -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); diff --git a/src/main/java/net/mcreator/superbwarfare/item/TargetDeployer.java b/src/main/java/net/mcreator/superbwarfare/item/TargetDeployer.java index 86da205a8..e4fad8076 100644 --- a/src/main/java/net/mcreator/superbwarfare/item/TargetDeployer.java +++ b/src/main/java/net/mcreator/superbwarfare/item/TargetDeployer.java @@ -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 { diff --git a/src/main/resources/assets/superbwarfare/geo/target2.geo.json b/src/main/resources/assets/superbwarfare/geo/target2.geo.json deleted file mode 100644 index 21cd9ff1a..000000000 --- a/src/main/resources/assets/superbwarfare/geo/target2.geo.json +++ /dev/null @@ -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]} - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index fc318b7a7..f181361cc 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -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", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index b3d55588f..44ddb9b61 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -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", diff --git a/src/main/resources/assets/superbwarfare/textures/entity/target_e.png b/src/main/resources/assets/superbwarfare/textures/entity/target_e.png index 1ddf551b286763042cece9b5170d24ced630d793..69296f5841ebd6d427e22dff009845b61133244f 100644 GIT binary patch delta 164 zcmV;V09*fx0)+yQIe)iFL_t(|obA;y5`!=d1VA~HR|6&C+ewuoF@|vm@@~aosB~vV z0OKm(hjn|sdwyJ|xtxE+ZS(}7H!NJ&^Z&)!a5X=dDgY7fA!~j2Y+pOmi{#+ztake$5pSVdsya830%R7