diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSittableBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSittableBlock.java index f65df49e8..ca14dc223 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSittableBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSittableBlock.java @@ -79,6 +79,9 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt } List active = world.getEntitiesByClass(ChairEntity.class, new Box(pos), Entity::hasPassengers); + if (active == null) + return ActionResult.FAIL; + List hasPassenger = new ArrayList<>(); active.forEach(chairEntity -> hasPassenger.add(chairEntity.getPrimaryPassenger())); if (!active.isEmpty() && hasPassenger.stream().anyMatch(entity -> entity instanceof PlayerEntity)) { @@ -158,10 +161,10 @@ public ActionResult sitEntity(World world, BlockPos pos, BlockState state, Entit public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { super.onEntityCollision(state, world, pos, entity); List active = world.getEntitiesByClass(ChairEntity.class, new Box(pos), Entity::hasPassengers); - if (!active.isEmpty()) + if (active == null || !active.isEmpty()) return; - if (entity instanceof PlayerEntity || entity instanceof IronGolemEntity || entity instanceof AbstractMinecartEntity || entity.hasVehicle() || !(entity instanceof LivingEntity)) { + if (entity instanceof PlayerEntity || entity instanceof IronGolemEntity || entity instanceof AbstractMinecartEntity || entity.hasVehicle() || !(entity instanceof LivingEntity) || entity instanceof ChairEntity) { return; } if (!PaladinFurnitureMod.getPFMConfig().doMobsSitOnChairs()) diff --git a/common/src/main/java/com/unlikepaladin/pfm/entity/ChairEntity.java b/common/src/main/java/com/unlikepaladin/pfm/entity/ChairEntity.java index b3a8cd3ad..d2b7774a6 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/entity/ChairEntity.java +++ b/common/src/main/java/com/unlikepaladin/pfm/entity/ChairEntity.java @@ -7,7 +7,6 @@ import com.unlikepaladin.pfm.blocks.ToiletState; import com.unlikepaladin.pfm.client.PaladinFurnitureModClient; import dev.architectury.injectables.annotations.ExpectPlatform; -import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Dismounting; import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; @@ -16,8 +15,6 @@ import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; @@ -85,26 +82,21 @@ public boolean isPushedByFluids() { @Override public Vec3d updatePassengerForDismount(LivingEntity passenger) { Direction direction = this.getMovementDirection(); - if (direction.getAxis() == Direction.Axis.Y) { - return super.updatePassengerForDismount(passenger); - } else { - int[][] is = Dismounting.getDismountOffsets(direction); - BlockPos blockPos = this.getBlockPos(); - BlockPos.Mutable mutable = new BlockPos.Mutable(); - UnmodifiableIterator var6 = passenger.getPoses().iterator(); + if (this.world.getBlockState(this.getBlockPos()).getBlock() instanceof AbstractSittableBlock) { + direction = this.world.getBlockState(this.getBlockPos()).get(AbstractSittableBlock.FACING).getOpposite(); + } + if (direction.getAxis() != Direction.Axis.Y) { + int[][] dismountingOffsets = Dismounting.getDismountOffsets(direction); + BlockPos chairPos = this.getBlockPos(); + BlockPos.Mutable dismountPos = new BlockPos.Mutable(); - while(var6.hasNext()) { - EntityPose entityPose = (EntityPose)var6.next(); + for (EntityPose entityPose : passenger.getPoses()) { Box box = passenger.getBoundingBox(entityPose); - int[][] var9 = is; - int var10 = is.length; - - for(int var11 = 0; var11 < var10; ++var11) { - int[] js = var9[var11]; - mutable.set(blockPos.getX() + js[0], blockPos.getY() + 0.3, blockPos.getZ() + js[1]); - double d = this.world.getDismountHeight(mutable); - if (Dismounting.canDismountInBlock(d)) { - Vec3d vec3d = Vec3d.ofCenter(mutable, d); + for (int[] dismountingOffset : dismountingOffsets) { + dismountPos.set(chairPos.getX() + dismountingOffset[0], chairPos.getY() + 0.3, chairPos.getZ() + dismountingOffset[1]); + double dismountHeight = this.world.getDismountHeight(dismountPos); + if (Dismounting.canDismountInBlock(dismountHeight)) { + Vec3d vec3d = Vec3d.ofCenter(dismountPos, dismountHeight); if (Dismounting.canPlaceEntityAt(this.world, passenger, box.offset(vec3d))) { passenger.setPose(entityPose); return vec3d; @@ -112,8 +104,8 @@ public Vec3d updatePassengerForDismount(LivingEntity passenger) { } } } - return super.updatePassengerForDismount(passenger); } + return super.updatePassengerForDismount(passenger); } public static DefaultAttributeContainer.Builder createMobAttributes(){ diff --git a/gradle.properties b/gradle.properties index eac8930c0..056efd08b 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.16.5 enabled_platforms=fabric,forge archives_base_name=paladin-furniture-mod -mod_version=1.2.0 +mod_version=1.2.1 maven_group=com.unlikepaladin architectury_version=1.32.66