Skip to content

Commit

Permalink
修正部分问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Jan 8, 2024
1 parent 16b16ce commit 702fa18
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MaidBedTask(float movementSpeed, int closeEnoughDist) {

@Override
protected boolean checkExtraStartConditions(ServerLevel worldIn, EntityMaid maid) {
if (super.checkExtraStartConditions(worldIn, maid) && maid.getVehicle() == null && !maid.isInSittingPose()) {
if (super.checkExtraStartConditions(worldIn, maid) && this.maidStateConditions(maid)) {
BlockPos bedPos = findBed(worldIn, maid);
if (bedPos != null && maid.isWithinRestriction(bedPos)) {
if (bedPos.distToCenterSqr(maid.position()) < this.closeEnoughDist) {
Expand Down Expand Up @@ -74,4 +74,8 @@ private BlockPos findBed(ServerLevel world, EntityMaid maid) {
return poiManager.getInRange(type -> type.get().equals(InitPoi.MAID_BED.get()), blockPos, range, PoiManager.Occupancy.ANY)
.map(PoiRecord::getPos).min(Comparator.comparingDouble(pos -> pos.distSqr(blockPos))).orElse(null);
}

private boolean maidStateConditions(EntityMaid maid) {
return !maid.isInSittingPose() && !maid.isSleeping() && !maid.isLeashed() && !maid.isPassenger();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public MaidCollectHoneyTask(float speed, int closeEnoughDist) {

@Override
protected boolean checkExtraStartConditions(ServerLevel worldIn, EntityMaid maid) {
if (super.checkExtraStartConditions(worldIn, maid)) {
if (super.checkExtraStartConditions(worldIn, maid) && this.maidStateConditions(maid)) {
BlockPos beehivePos = findBeehive(worldIn, maid);
if (beehivePos != null && maid.isWithinRestriction(beehivePos)) {
if (beehivePos.distToCenterSqr(maid.position()) < this.closeEnoughDist) {
Expand Down Expand Up @@ -135,4 +135,8 @@ private boolean canCollectHoney(ServerLevel world, BlockPos hivePos) {
public void resetHoneyLevel(Level level, BlockState state, BlockPos pos) {
level.setBlock(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, 0), Block.UPDATE_ALL);
}

private boolean maidStateConditions(EntityMaid maid) {
return !maid.isInSittingPose() && !maid.isSleeping() && !maid.isLeashed() && !maid.isPassenger();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MaidGomokuTask(float movementSpeed, int closeEnoughDist) {

@Override
protected boolean checkExtraStartConditions(ServerLevel worldIn, EntityMaid maid) {
if (super.checkExtraStartConditions(worldIn, maid) && maid.getVehicle() == null && !maid.isInSittingPose()) {
if (super.checkExtraStartConditions(worldIn, maid) && this.maidStateConditions(maid)) {
BlockPos gomokuPos = findGomoku(worldIn, maid);
if (gomokuPos != null && maid.isWithinRestriction(gomokuPos)) {
if (gomokuPos.distToCenterSqr(maid.position()) < this.closeEnoughDist) {
Expand Down Expand Up @@ -81,4 +81,8 @@ private boolean isOccupied(ServerLevel worldIn, BlockPos pos) {
}
return true;
}

private boolean maidStateConditions(EntityMaid maid) {
return !maid.isInSittingPose() && !maid.isSleeping() && !maid.isLeashed() && !maid.isPassenger();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MaidJoyTask(float movementSpeed, int closeEnoughDist) {

@Override
protected boolean checkExtraStartConditions(ServerLevel worldIn, EntityMaid maid) {
if (super.checkExtraStartConditions(worldIn, maid) && maid.getVehicle() == null && !maid.isInSittingPose()) {
if (super.checkExtraStartConditions(worldIn, maid) && this.maidStateConditions(maid)) {
BlockPos joyPos = findJoy(worldIn, maid);
if (joyPos != null && maid.isWithinRestriction(joyPos)) {
if (joyPos.distToCenterSqr(maid.position()) < this.closeEnoughDist) {
Expand Down Expand Up @@ -81,4 +81,8 @@ private boolean isOccupied(ServerLevel worldIn, BlockPos pos) {
}
return true;
}

private boolean maidStateConditions(EntityMaid maid) {
return !maid.isInSittingPose() && !maid.isSleeping() && !maid.isLeashed() && !maid.isPassenger();
}
}

0 comments on commit 702fa18

Please sign in to comment.