From 873fb69eb8828d912357deeacf0617f1d6552285 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Thu, 31 Oct 2024 20:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/ClaymoreEntity.java | 6 +++- .../superbwarfare/entity/Mk42Entity.java | 27 ++++---------- .../superbwarfare/entity/Mle1934Entity.java | 35 ++++++------------- .../superbwarfare/entity/MortarEntity.java | 3 +- .../superbwarfare/entity/TargetEntity.java | 28 ++++++++------- 5 files changed, 39 insertions(+), 60 deletions(-) diff --git a/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java index f849326be..2c133f520 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java @@ -38,6 +38,7 @@ import java.util.UUID; import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, OwnableEntity { + protected static final EntityDataAccessor> OWNER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.OPTIONAL_UUID); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); @@ -210,7 +211,8 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, this.refreshDimensions(); } - public void destroy() { + + public void destroy() { if (level() instanceof ServerLevel) { CustomExplosion explosion = new CustomExplosion(this.level(), this, ModDamageTypes.causeMineDamage(this.level().registryAccess(), this), 15.0f, @@ -242,10 +244,12 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, return true; } + @Override public String getSyncedAnimation() { return null; } + @Override public void setAnimation(String animation) { } diff --git a/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java b/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java index 0dbf43e75..b6df5fb1a 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java @@ -42,13 +42,13 @@ import software.bernie.geckolib.util.GeckoLibUtil; import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { + public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); protected int interpolationSteps; - protected double serverYRot; protected double serverXRot; @@ -69,15 +69,15 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { @Override public void addAdditionalSaveData(CompoundTag compound) { - compound.putInt("cool_down", this.entityData.get(COOL_DOWN)); - compound.putInt("type", this.entityData.get(TYPE)); + compound.putInt("CoolDown", this.entityData.get(COOL_DOWN)); + compound.putInt("Type", this.entityData.get(TYPE)); compound.putFloat("Health", this.entityData.get(HEALTH)); } @Override public void readAdditionalSaveData(CompoundTag compound) { - this.entityData.set(COOL_DOWN, compound.getInt("cool_down")); - this.entityData.set(TYPE, compound.getInt("type")); + this.entityData.set(COOL_DOWN, compound.getInt("CoolDown")); + this.entityData.set(TYPE, compound.getInt("Type")); this.entityData.set(HEALTH, compound.getFloat("Health")); } @@ -98,7 +98,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { @Override public boolean hurt(DamageSource source, float amount) { - if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } @@ -140,12 +139,10 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { public InteractionResult interact(Player player, InteractionHand hand) { if (player.isShiftKeyDown() && player.getMainHandItem().getItem() == ModItems.CROWBAR.get() && this.getFirstPassenger() == null) { this.discard(); -// ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MK_42_SPAWN_EGG.get())); } else { player.setXRot(this.getXRot()); player.setYRot(this.getYRot()); player.startRiding(this); - } return InteractionResult.sidedSuccess(this.level().isClientSide()); @@ -315,7 +312,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { this.getX() + i * this.getLookAngle().x, this.getEyeY() + i * this.getLookAngle().y, this.getZ() + i * this.getLookAngle().z, - Mth.clamp(count--,1,5), 0.15, 0.15, 0.15, 0.0025); + Mth.clamp(count--, 1, 5), 0.15, 0.15, 0.15, 0.0025); } } } @@ -350,11 +347,8 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { } } - public static void init() { - } - protected void clampRotation(Entity entity) { - ItemStack stack = null; + ItemStack stack = ItemStack.EMPTY; if (entity instanceof Player player) { stack = player.getMainHandItem(); } @@ -384,13 +378,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle")); } - public String getSyncedAnimation() { - return null; - } - - public void setAnimation(String animation) { - } - @Override public void registerControllers(AnimatableManager.ControllerRegistrar data) { data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate)); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java b/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java index d2874c6ef..490ce1b8a 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java @@ -44,6 +44,7 @@ import software.bernie.geckolib.util.GeckoLibUtil; import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { + public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor TYPE = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); @@ -52,7 +53,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { public String animationprocedure = "empty"; protected int interpolationSteps; - protected double serverYRot; protected double serverXRot; @@ -73,15 +73,15 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { @Override public void addAdditionalSaveData(CompoundTag compound) { - compound.putInt("cool_down", this.entityData.get(COOL_DOWN)); - compound.putInt("type", this.entityData.get(TYPE)); + compound.putInt("CoolDown", this.entityData.get(COOL_DOWN)); + compound.putInt("Type", this.entityData.get(TYPE)); compound.putFloat("Health", this.entityData.get(HEALTH)); } @Override public void readAdditionalSaveData(CompoundTag compound) { - this.entityData.set(COOL_DOWN, compound.getInt("cool_down")); - this.entityData.set(TYPE, compound.getInt("type")); + this.entityData.set(COOL_DOWN, compound.getInt("CoolDown")); + this.entityData.set(TYPE, compound.getInt("Type")); this.entityData.set(HEALTH, compound.getFloat("Health")); } @@ -102,7 +102,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { @Override public boolean hurt(DamageSource source, float amount) { - if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } @@ -144,12 +143,10 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { public InteractionResult interact(Player player, InteractionHand hand) { if (player.isShiftKeyDown() && player.getMainHandItem().getItem() == ModItems.CROWBAR.get() && this.getFirstPassenger() == null) { this.discard(); -// ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MK_42_SPAWN_EGG.get())); } else { player.setXRot(this.getXRot()); player.setYRot(this.getYRot()); player.startRiding(this); - } return InteractionResult.sidedSuccess(this.level().isClientSide()); @@ -288,7 +285,7 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { leftPos.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD); leftPos.rotateY(-yRot * Mth.DEG_TO_RAD); - //左炮管 + // 左炮管 CannonShellEntity entityToSpawnLeft = new CannonShellEntity(ModEntities.CANNON_SHELL.get(), player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability); @@ -317,7 +314,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { int count = 5; for (float i = 9.5f; i < 14; i += .5f) { - var leftPosP = new Vector3d(i, 0, -0.45); leftPosP.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD); leftPosP.rotateY(-yRot * Mth.DEG_TO_RAD); @@ -326,10 +322,10 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { this.getX() + leftPosP.x, this.getEyeY() - 0.2 + leftPosP.y, this.getZ() + leftPosP.z, - Mth.clamp(count--,1,5), 0.1, 0.1, 0.1, 0.002); + Mth.clamp(count--, 1, 5), 0.1, 0.1, 0.1, 0.002); } - //右炮管 + // 右炮管 if (salvoShoot) { var rightPos = new Vector3d(0, 0, 0.45); rightPos.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD); @@ -363,7 +359,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { int countR = 5; for (float i = 9.5f; i < 14; i += .5f) { - var rightPosP = new Vector3d(i, 0, 0.45); rightPosP.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD); rightPosP.rotateY(-yRot * Mth.DEG_TO_RAD); @@ -372,7 +367,7 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { this.getX() + rightPosP.x, this.getEyeY() - 0.2 + rightPosP.y, this.getZ() + rightPosP.z, - Mth.clamp(countR--,1,5), 0.1, 0.1, 0.1, 0.002); + Mth.clamp(countR--, 1, 5), 0.1, 0.1, 0.1, 0.002); } this.entityData.set(TYPE, 1); @@ -395,7 +390,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { this.getY(), this.getZ() + 5 * this.getLookAngle().z, 100, 7, 0.02, 7, 0.005); - } } @@ -428,10 +422,8 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { } } - public static void init() { - } protected void clampRotation(Entity entity) { - ItemStack stack = null; + ItemStack stack = ItemStack.EMPTY; if (entity instanceof Player player) { stack = player.getMainHandItem(); } @@ -460,13 +452,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mle1934.idle")); } - public String getSyncedAnimation() { - return null; - } - - public void setAnimation(String animation) { - } - @Override public void registerControllers(AnimatableManager.ControllerRegistrar data) { data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate)); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java index ee21a0e23..453f265fb 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java @@ -136,7 +136,7 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { public InteractionResult interact(Player player, InteractionHand hand) { ItemStack mainHandItem = player.getMainHandItem(); if (player.isShiftKeyDown()) { - if (mainHandItem.getItem() == ModItems.CROWBAR.get()){ + if (mainHandItem.getItem() == ModItems.CROWBAR.get()) { this.discard(); ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MORTAR_DEPLOYER.get())); } @@ -219,6 +219,7 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { } return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.idle")); } + protected void destroy() { if (this.level() instanceof ServerLevel level) { var x = this.getX(); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java index 32fb10faa..518b97a17 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/TargetEntity.java @@ -40,11 +40,10 @@ import software.bernie.geckolib.util.GeckoLibUtil; @Mod.EventBusSubscriber public class TargetEntity extends LivingEntity implements GeoEntity, AnimatedEntity { + 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) { this(ModEntities.TARGET.get(), world); } @@ -225,17 +224,6 @@ public class TargetEntity extends LivingEntity implements GeoEntity, AnimatedEnt } } - public String getSyncedAnimation() { - return null; - } - - public void setAnimation(String animation) { - } - - @Override - public void setAnimationProcedure(String procedure) { - } - private PlayState movementPredicate(AnimationState event) { if (this.entityData.get(DOWN_TIME) > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.target.down")); @@ -252,4 +240,18 @@ public class TargetEntity extends LivingEntity implements GeoEntity, AnimatedEnt public AnimatableInstanceCache getAnimatableInstanceCache() { return this.cache; } + + @Override + public String getSyncedAnimation() { + return null; + } + + @Override + public void setAnimation(String animation) { + } + + @Override + public void setAnimationProcedure(String procedure) { + + } }