More cleanup! Haza!

This commit is contained in:
Sollace 2022-09-11 17:06:05 +02:00
parent 7b58fdb6ba
commit 0ffa55a20c
8 changed files with 28 additions and 33 deletions

View file

@ -19,7 +19,7 @@ public class BlazeBehaviour extends EntityBehaviour<BlazeEntity> {
Entity src = source.getEntity();
if (src.isOnGround() || src instanceof PlayerEntity && ((PlayerEntity)src).getAbilities().flying) {
if (src.isOnGround() || src instanceof PlayerEntity player && player.getAbilities().flying) {
return;
}
@ -67,7 +67,7 @@ public class BlazeBehaviour extends EntityBehaviour<BlazeEntity> {
if (fireballsFired > 0) {
if (!entity.isSilent()) {
entity.world.syncWorldEvent((PlayerEntity)null, WorldEvents.BLAZE_SHOOTS, entity.getBlockPos(), 0);
entity.world.syncWorldEvent(null, WorldEvents.BLAZE_SHOOTS, entity.getBlockPos(), 0);
}
Vec3d rot = player.getEntity().getRotationVec(1);

View file

@ -23,10 +23,7 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
public void update(Caster<?> source, ChickenEntity entity, Disguise spell) {
entity.eggLayTime = Integer.MAX_VALUE;
if (source instanceof Pony) {
Pony player = (Pony)source;
if (source instanceof Pony player) {
if (player.sneakingChanged()) {
ItemStack egg = entity.getEquippedStack(EquipmentSlot.OFFHAND);
@ -53,7 +50,7 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
Entity src = source.getEntity();
if (src.isOnGround() || src instanceof PlayerEntity && ((PlayerEntity)src).getAbilities().flying) {
if (src.isOnGround() || src instanceof PlayerEntity player && player.getAbilities().flying) {
return;
}

View file

@ -17,8 +17,8 @@ public class EndermanBehaviour extends EntityBehaviour<EndermanEntity> {
}
ItemStack stack = source.getMaster().getStackInHand(Hand.MAIN_HAND);
if (stack.getItem() instanceof BlockItem) {
entity.setCarriedBlock(((BlockItem)stack.getItem()).getBlock().getDefaultState());
if (stack.getItem() instanceof BlockItem bi) {
entity.setCarriedBlock(bi.getBlock().getDefaultState());
} else {
entity.setCarriedBlock(null);
}

View file

@ -46,8 +46,8 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
entity.handleFallDamage(distance, damageMultiplier, cause);
BlockState state = entity.getBlockState();
if (state.getBlock() instanceof FallingBlock) {
((FallingBlock)state.getBlock()).onLanding(entity.world, entity.getBlockPos(), state, state, entity);
if (state.getBlock() instanceof FallingBlock fb) {
fb.onLanding(entity.world, entity.getBlockPos(), state, state, entity);
}
}
}
@ -77,8 +77,8 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
return configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block);
}
if (block instanceof BlockEntityProvider) {
context.addBlockEntity(((BlockEntityProvider)block).createBlockEntity(entity.getBlockPos(), state));
if (block instanceof BlockEntityProvider bep) {
context.addBlockEntity(bep.createBlockEntity(entity.getBlockPos(), state));
}
return configure(entity, block);
@ -106,10 +106,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
BlockEntity be = disguise.getBlockEntity();
if (source instanceof Pony && be instanceof Tickable && (be instanceof ChestBlockEntity || be instanceof EnderChestBlockEntity)) {
Pony player = (Pony)source;
Tickable ceb = (Tickable)disguise.getBlockEntity();
if (source instanceof Pony player && be instanceof Tickable ceb && (be instanceof ChestBlockEntity || be instanceof EnderChestBlockEntity)) {
if (player.sneakingChanged()) {
be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0);
}

View file

@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.mob.GhastEntity;
import net.minecraft.entity.projectile.FireballEntity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.WorldEvents;
public class GhastBehaviour extends MobBehaviour<GhastEntity> {
@ -18,11 +19,11 @@ public class GhastBehaviour extends MobBehaviour<GhastEntity> {
if (sneaking) {
if (!entity.isSilent()) {
entity.world.syncWorldEvent(null, 1015, entity.getBlockPos(), 0);
entity.world.syncWorldEvent(null, WorldEvents.GHAST_WARNS, entity.getBlockPos(), 0);
}
} else {
if (!entity.isSilent()) {
entity.world.syncWorldEvent(null, 1016, entity.getBlockPos(), 0);
entity.world.syncWorldEvent(null, WorldEvents.GHAST_SHOOTS, entity.getBlockPos(), 0);
}
Vec3d rot = player.getEntity().getRotationVec(1);

View file

@ -12,14 +12,16 @@ public class HoppingBehaviour extends EntityBehaviour<LivingEntity> {
if (player.getEntity().isOnGround()) {
if (player.getEntity().getVelocity().horizontalLengthSquared() > 0.01) {
player.getMaster().jump();
if (entity instanceof RabbitEntity) {
((RabbitEntity)entity).startJump();
}
startJump(entity);
}
} else if (player.landedChanged()) {
if (entity instanceof RabbitEntity) {
((RabbitEntity)entity).startJump();
}
startJump(entity);
}
}
private void startJump(LivingEntity entity) {
if (entity instanceof RabbitEntity rabbit) {
rabbit.startJump();
}
}
}

View file

@ -25,11 +25,9 @@ public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
entity.setPitch(0);
entity.prevPitch = 0;
if (source.getEntity() instanceof LivingEntity) {
int hurt = ((LivingEntity)source.getEntity()).hurtTime;
if (hurt > 0) {
entity.setDamageWobbleTicks(hurt);
if (source.getEntity() instanceof LivingEntity living) {
if (living.hurtTime > 0) {
entity.setDamageWobbleTicks(living.hurtTime);
entity.setDamageWobbleStrength(1);
entity.setDamageWobbleSide(20 + (int)source.getEntity().fallDistance / 10);
}

View file

@ -297,17 +297,17 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
if (isFlying() && !entity.isFallFlying()) {
float pitch = ((Leaner)entity).getLeaningPitch();
float pitch = ((LivingEntityDuck)entity).getLeaningPitch();
if (pitch < 1) {
if (pitch < 0.9F) {
pitch += 0.1F;
}
pitch += 0.09F;
((Leaner)entity).setLeaningPitch(Math.max(0, pitch));
((LivingEntityDuck)entity).setLeaningPitch(Math.max(0, pitch));
}
entity.limbAngle = 20 + (float)Math.cos(entity.age / 7F) - 0.5F;
entity.limbDistance = this.thrustScale;
entity.limbDistance = thrustScale;
}
}