Skip to content

Commit

Permalink
cleaned through code removing debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Dec 30, 2023
1 parent f99bc24 commit 8b9980c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ public void updateFoodHolder(Animal mob, Ingredient temptations, FakePlayer food
newPos = througPos.add(direction.normalize().scale(-1));
}

// debug to visualize where fake player is
/*
ItemEntity e = new ItemEntity(level, newPos.x, newPos.y+2, newPos.z, Items.EMERALD.getDefaultInstance(), 0,0,0);
e.setNoGravity(true);
e.noPhysics =true;
level.addFreshEntity(e);
*/

foodHolder.moveTo(newPos.x, newPos.y, newPos.z, angles.x, angles.y);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void onOrbSpawn(ZEntityJoinLevel event) {

TroughPointer pointer = NEARBY_TROUGH_CACHE.get(animal);

//there's no cached trough nearby.
//There's no cached trough nearby.
//Randomize whether we actually look for a new trough, to hopefully not eat all the tick time.
if (pointer == null && level.random.nextFloat() <= lookChance) {
pointer = TroughPointer.find(level, animal, temptations);
Expand All @@ -149,11 +149,7 @@ public void onOrbSpawn(ZEntityJoinLevel event) {
BlockHitResult ray = level.clip(new ClipContext(eyesPos, targetPos, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, animal));
if (ray.getType() == HitResult.Type.BLOCK && ray.getBlockPos().equals(location)) {
return pointer.foodHolder;
} else {
int error = 0;
}
}else{
int aa = 1;
}
}

Expand Down Expand Up @@ -202,22 +198,18 @@ boolean valid(Animal animal) {
}
//check if it has food and tile is valid
if(animal.level().getBlockEntity(pos) instanceof FeedingTroughBlockEntity trough){
//this should be called in tick but we save one tile call by doing this...
//this should be called in tick, but we save one tile call by doing this...
trough.updateFoodHolder(animal, temptations, foodHolder);
//if it still has food
var v = !foodHolder.getMainHandItem().isEmpty();
if(!v){
int aa = 1;
}
return v;
return !foodHolder.getMainHandItem().isEmpty();
}
return false;
}

void tryEatingOrTickCooldown(Animal animal) {
giveUpCooldown--;
if (eatCooldown == 0) {
//I wish this could be made smaller. Vanilla AI will not keep animals too close to player holding food
//I wish this could be made smaller. Vanilla AI will not keep animals too close to a player holding food
float feedDistance = 1.5f;
if (pos.distToCenterSqr(animal.position()) < (feedDistance * feedDistance)) {
if (animal.level().getBlockEntity(pos) instanceof FeedingTroughBlockEntity trough) {
Expand Down

0 comments on commit 8b9980c

Please sign in to comment.