优化部分冗余代码
This commit is contained in:
parent
9b2e093a46
commit
b3524d203a
9 changed files with 21 additions and 50 deletions
|
@ -48,10 +48,6 @@ public class BocekArrowEntity extends AbstractArrow implements ItemSupplier {
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
public BocekArrowEntity(EntityType<? extends BocekArrowEntity> type, double x, double y, double z, Level world) {
|
||||
super(type, x, y, z, world);
|
||||
}
|
||||
|
||||
public BocekArrowEntity(LivingEntity entity, Level level, int monsterMultiplier) {
|
||||
super(ModEntities.BOCEK_ARROW.get(), entity, level);
|
||||
this.monsterMultiplier = monsterMultiplier;
|
||||
|
|
|
@ -39,8 +39,7 @@ import software.bernie.geckolib.core.animation.RawAnimation;
|
|||
import software.bernie.geckolib.core.object.PlayState;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
public class CannonShellEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity{
|
||||
|
||||
public class CannonShellEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity {
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(CannonShellEntity.class, EntityDataSerializers.STRING);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
||||
|
@ -57,14 +56,6 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
public CannonShellEntity(EntityType<? extends CannonShellEntity> type, double x, double y, double z, Level world) {
|
||||
super(type, x, y, z, world);
|
||||
}
|
||||
|
||||
public CannonShellEntity(EntityType<? extends CannonShellEntity> type, LivingEntity entity, Level world) {
|
||||
super(type, entity, world);
|
||||
}
|
||||
|
||||
public CannonShellEntity(EntityType<? extends CannonShellEntity> type, LivingEntity entity, Level world, float damage, float explosionRadius, float explosionDamage, float fireProbability, int fireTime) {
|
||||
super(type, entity, world);
|
||||
this.damage = damage;
|
||||
|
@ -222,14 +213,14 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
|||
this.discard();
|
||||
}
|
||||
|
||||
private PlayState movementPredicate(AnimationState event) {
|
||||
private PlayState movementPredicate(AnimationState<CannonShellEntity> event) {
|
||||
if (this.animationprocedure.equals("empty")) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.cannon_shell.idle"));
|
||||
}
|
||||
return PlayState.STOP;
|
||||
}
|
||||
|
||||
private PlayState procedurePredicate(AnimationState event) {
|
||||
private PlayState procedurePredicate(AnimationState<CannonShellEntity> 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) {
|
||||
|
|
|
@ -65,6 +65,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
// TODO 重做无人机
|
||||
public class DroneEntity extends PathfinderMob implements GeoEntity {
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
|
||||
public static final EntityDataAccessor<Boolean> LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN);
|
||||
|
@ -464,7 +465,6 @@ public class DroneEntity extends PathfinderMob implements GeoEntity {
|
|||
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityDimensions getDimensions(Pose p_33597_) {
|
||||
return super.getDimensions(p_33597_).scale((float) 1);
|
||||
|
|
|
@ -32,7 +32,6 @@ import net.minecraftforge.network.PacketDistributor;
|
|||
import net.minecraftforge.network.PlayMessages;
|
||||
|
||||
public class GunGrenadeEntity extends ThrowableItemProjectile {
|
||||
|
||||
private int monsterMultiplier = 0;
|
||||
private float damage = 5f;
|
||||
|
||||
|
@ -101,7 +100,7 @@ public class GunGrenadeEntity extends ThrowableItemProjectile {
|
|||
super.onHitBlock(blockHitResult);
|
||||
BlockPos resultPos = blockHitResult.getBlockPos();
|
||||
BlockState state = this.level().getBlockState(resultPos);
|
||||
if(state.getBlock() instanceof BellBlock bell) {
|
||||
if (state.getBlock() instanceof BellBlock bell) {
|
||||
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
|
||||
}
|
||||
if (this.tickCount > 0) {
|
||||
|
|
|
@ -40,10 +40,6 @@ public class HandGrenadeEntity extends ThrowableItemProjectile {
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
public HandGrenadeEntity(EntityType<? extends HandGrenadeEntity> type, LivingEntity entity, Level world) {
|
||||
super(type, entity, world);
|
||||
}
|
||||
|
||||
public HandGrenadeEntity(LivingEntity entity, Level level, int fuse) {
|
||||
super(ModEntities.HAND_GRENADE_ENTITY.get(), entity, level);
|
||||
this.fuse = fuse;
|
||||
|
@ -82,7 +78,7 @@ public class HandGrenadeEntity extends ThrowableItemProjectile {
|
|||
}
|
||||
this.bounce(blockResult.getDirection());
|
||||
|
||||
if(state.getBlock() instanceof BellBlock bell) {
|
||||
if (state.getBlock() instanceof BellBlock bell) {
|
||||
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,6 @@ public class MortarShellEntity extends ThrowableItemProjectile {
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
public MortarShellEntity(EntityType<? extends MortarShellEntity> type, double x, double y, double z, Level world) {
|
||||
super(type, x, y, z, world);
|
||||
}
|
||||
|
||||
public MortarShellEntity(EntityType<? extends MortarShellEntity> type, LivingEntity entity, Level world) {
|
||||
super(type, entity, world);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache
|
|||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity{
|
||||
public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity {
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(RgoGrenadeEntity.class, EntityDataSerializers.STRING);
|
||||
private int fuse = 80;
|
||||
|
||||
|
@ -49,10 +49,6 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
public RgoGrenadeEntity(EntityType<? extends RgoGrenadeEntity> type, LivingEntity entity, Level world) {
|
||||
super(type, entity, world);
|
||||
}
|
||||
|
||||
public RgoGrenadeEntity(LivingEntity entity, Level level, int fuse) {
|
||||
super(ModEntities.RGO_GRENADE.get(), entity, level);
|
||||
this.fuse = fuse;
|
||||
|
@ -84,7 +80,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
|||
BlockHitResult blockResult = (BlockHitResult) result;
|
||||
BlockPos resultPos = blockResult.getBlockPos();
|
||||
BlockState state = this.level().getBlockState(resultPos);
|
||||
if(state.getBlock() instanceof BellBlock bell) {
|
||||
if (state.getBlock() instanceof BellBlock bell) {
|
||||
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
||||
}
|
||||
causeExplode();
|
||||
|
@ -102,7 +98,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
|||
}
|
||||
}
|
||||
|
||||
causeEntityhitExplode(entity);
|
||||
causeEntityHitExplode(entity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -126,7 +122,8 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
|||
1, 0, 0, 0, 0.01, true);
|
||||
}
|
||||
}
|
||||
private void causeEntityhitExplode(Entity entity) {
|
||||
|
||||
private void causeEntityHitExplode(Entity entity) {
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 75,
|
||||
entity.getX(), entity.getY(), entity.getZ(), 5.75f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1.25f);
|
||||
|
|
|
@ -43,9 +43,8 @@ import software.bernie.geckolib.core.animation.RawAnimation;
|
|||
import software.bernie.geckolib.core.object.PlayState;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity{
|
||||
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(CannonShellEntity.class, EntityDataSerializers.STRING);
|
||||
public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity {
|
||||
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(RpgRocketEntity.class, EntityDataSerializers.STRING);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
||||
public String animationprocedure = "empty";
|
||||
|
@ -57,10 +56,6 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
public RpgRocketEntity(EntityType<? extends RpgRocketEntity> type, LivingEntity entity, Level world) {
|
||||
super(type, entity, world);
|
||||
}
|
||||
|
||||
public RpgRocketEntity(LivingEntity entity, Level level, float damage, int monsterMultiplier) {
|
||||
super(ModEntities.RPG_ROCKET.get(), entity, level);
|
||||
this.damage = damage;
|
||||
|
@ -105,7 +100,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
|||
|
||||
if (this.tickCount > 1) {
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
causeEntityhitExplode(entity);
|
||||
causeEntityHitExplode(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,9 +117,11 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
|||
super.onHitBlock(blockHitResult);
|
||||
BlockPos resultPos = blockHitResult.getBlockPos();
|
||||
BlockState state = this.level().getBlockState(resultPos);
|
||||
if(state.getBlock() instanceof BellBlock bell) {
|
||||
|
||||
if (state.getBlock() instanceof BellBlock bell) {
|
||||
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
|
||||
}
|
||||
|
||||
if (this.tickCount > 1) {
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
causeExplode();
|
||||
|
@ -171,7 +168,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
|||
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||
}
|
||||
|
||||
private void causeEntityhitExplode(Entity entity) {
|
||||
private void causeEntityHitExplode(Entity entity) {
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), (float) 2 / 3 * this.damage,
|
||||
entity.getX(), entity.getY(), entity.getZ(), 10f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(this.monsterMultiplier);
|
||||
|
@ -182,14 +179,14 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
|||
this.discard();
|
||||
}
|
||||
|
||||
private PlayState movementPredicate(AnimationState event) {
|
||||
private PlayState movementPredicate(AnimationState<RpgRocketEntity> event) {
|
||||
if (this.animationprocedure.equals("empty")) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.rpg.idle"));
|
||||
}
|
||||
return PlayState.STOP;
|
||||
}
|
||||
|
||||
private PlayState procedurePredicate(AnimationState event) {
|
||||
private PlayState procedurePredicate(AnimationState<RpgRocketEntity> 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) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package net.mcreator.superbwarfare.entity;
|
||||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
|
@ -106,7 +105,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
|
|||
super.onHitBlock(blockHitResult);
|
||||
BlockPos resultPos = blockHitResult.getBlockPos();
|
||||
BlockState state = this.level().getBlockState(resultPos);
|
||||
if(state.getBlock() instanceof BellBlock bell) {
|
||||
if (state.getBlock() instanceof BellBlock bell) {
|
||||
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue