优化部分代码
This commit is contained in:
parent
042fe34b2b
commit
873fb69eb8
5 changed files with 39 additions and 60 deletions
|
@ -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<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.OPTIONAL_UUID);
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.FLOAT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
@ -210,6 +211,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
|
|||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (level() instanceof ServerLevel) {
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||
|
@ -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) {
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Float> 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());
|
||||
|
@ -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));
|
||||
|
|
|
@ -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<Integer> COOL_DOWN = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Float> 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());
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -40,11 +40,10 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
|
||||
@Mod.EventBusSubscriber
|
||||
public class TargetEntity extends LivingEntity implements GeoEntity, AnimatedEntity {
|
||||
|
||||
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) {
|
||||
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<TargetEntity> 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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue