Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pathing fixes #10388

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public abstract class AbstractFastMinecoloniesEntity extends PathfinderMob imple
*/
private long lastHorizontalCollision = 0;

/**
* Last knockback time
*/
protected long lastKnockBack = 0;

/**
* Create a new instance.
*
Expand Down Expand Up @@ -335,4 +340,14 @@ public boolean isShiftKeyDown()
{
return (this.entityData.get(DATA_SHARED_FLAGS_ID)).byteValue() == ENABLE.byteValue();
}

@Override
public void knockback(double power, double xRatio, double zRatio)
{
if (level.getGameTime() - lastKnockBack > 20 * 3)
{
lastKnockBack = level.getGameTime();
super.knockback(power, xRatio, zRatio);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,15 @@ private ICitizenData spawnCitizenOnPosition(

if (world instanceof ServerLevel serverLevel)
{
final Entity existing = serverLevel.getEntity(citizenData.getUUID());
Entity existing = serverLevel.getEntity(citizenData.getUUID());
if (existing != null)
{
existing.discard();
existing = serverLevel.getEntity(citizenData.getUUID());
if (existing != null)
{
serverLevel.entityManager.stopTracking(existing);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ public boolean refreshCitizenDataView()
if (colonyView != null)
{
this.citizenDataView = colonyView.getCitizen(citizenId);
// TODO: Why is this here on clientside?
this.getNavigation().getPathingOptions().setCanUseRails(canPathOnRails());
this.getNavigation().getPathingOptions().setCanClimbAdvanced(canClimbVines());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickingTransition;
import com.minecolonies.api.entity.mobs.AbstractEntityRaiderMob;
import com.minecolonies.api.entity.pathfinding.IPathJob;
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult;
import com.minecolonies.api.util.BlockPosUtil;
import com.minecolonies.api.util.Log;
import com.minecolonies.core.colony.buildings.AbstractBuilding;
import com.minecolonies.core.colony.events.raid.HordeRaidEvent;
import com.minecolonies.core.colony.events.raid.pirateEvent.ShipBasedRaiderUtils;
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult;
import net.minecraft.core.BlockPos;

import java.util.List;
Expand Down Expand Up @@ -156,7 +156,10 @@ protected BlockPos findRandomPositionToWalkTo()
&& !building.getCorners().getA().equals(building.getCorners().getB()))
{
randomPathResult = raider.getNavigation().moveToRandomPos(10, 0.9, building.getCorners());
randomPathResult.getJob().getPathingOptions().withCanEnterDoors(true).withToggleCost(0).withNonLadderClimbableCost(0);
if (randomPathResult != null)
{
randomPathResult.getJob().getPathingOptions().withCanEnterDoors(true).withToggleCost(0).withNonLadderClimbableCost(0);
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseRailBlock;
import net.minecraft.world.level.block.LadderBlock;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.level.pathfinder.Node;
Expand Down Expand Up @@ -383,7 +382,9 @@ else if (this.path != null && !this.path.isDone())
vector3d2.z);
}
}

}
if (wantedPosition != null)
{
mob.getMoveControl().setWantedPosition(wantedPosition.x, wantedPosition.y, wantedPosition.z, speedModifier);
}
}
Expand Down Expand Up @@ -412,6 +413,11 @@ public static double getSmartGroundY(final BlockGetter world, final BlockPos.Mut

if (!state.isAir())
{
if (state.getBlock() instanceof FenceGateBlock || state.getBlock() instanceof DoorBlock || state.getBlock() instanceof TrapDoorBlock)
{
return orgY;
}

final VoxelShape voxelshape = state.getCollisionShape(world, pos);
if (!ShapeUtil.isEmpty(voxelshape))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ protected boolean isPassable(@NotNull final BlockState block, final int x, final
if (!block.isAir())
{
final VoxelShape shape = block.getCollisionShape(world, tempWorldPos.set(x, y, z));
if (ShapeUtil.max(shape, Direction.Axis.Y) < 0.5 && PathfindingUtils.isDangerous(cachedBlockLookup.getBlockState(x, y - 1, z)))
if (!pathingOptions.canPassDanger() && ShapeUtil.max(shape, Direction.Axis.Y) < 0.5 && PathfindingUtils.isDangerous(cachedBlockLookup.getBlockState(x, y - 1, z)))
{
return false;
}
Expand Down Expand Up @@ -1282,7 +1282,7 @@ protected boolean isPassable(@NotNull final BlockState block, final int x, final
|| !block.getBlock().properties.hasCollision;
}
}
else if (PathfindingUtils.isDangerous(block))
else if (!pathingOptions.canPassDanger() && PathfindingUtils.isDangerous(block))
{
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/minecolonies/core/event/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public static void onEntityAdded(@NotNull final EntityJoinLevelEvent event)
{
if (MineColonies.getConfig().getServer().mobAttackCitizens.get() && event.getEntity() instanceof Mob && event.getEntity() instanceof Enemy && !(event.getEntity()
.getType()
.is(ModTags.mobAttackBlacklist)))
.is(ModTags.mobAttackBlacklist))
&& !(event.getEntity() instanceof AbstractFastMinecoloniesEntity))
{
((Mob) event.getEntity()).targetSelector.addGoal(6,
new NearestAttackableTargetGoal<>((Mob) event.getEntity(), EntityCitizen.class, true, citizen -> !citizen.isInvisible()));
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ public net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer f_266073_
public net.minecraft.world.entity.LivingEntity m_21333_()V # updateSwimAmount

public-f net.minecraft.world.entity.Entity m_142467_(Lnet/minecraft/world/entity/Entity$RemovalReason;)V # setRemoved

public net.minecraft.world.level.entity.PersistentEntitySectionManager m_157580_(Lnet/minecraft/world/level/entity/EntityAccess;)V # stopTracking
public net.minecraft.server.level.ServerLevel f_143244_ # entityManager