Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Catches errors if a mob is riding another with custom ai and its chunk unloads. Mostly noticeable in the case of Alex's mobs. It even targets the right branch this time!
  • Loading branch information
Weedoof authored Jul 15, 2022
1 parent eba4676 commit 1b89af4
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/main/java/pam/pamhc2crops/events/TemptationTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,47 @@ public void onEntitySpawn(EntityJoinWorldEvent event) {

if (entity instanceof ChickenEntity) {
ChickenEntity chicken = (ChickenEntity) entity;
chicken.goalSelector.addGoal(3, new MoreTemptation(chicken, 1.0D, false, Chicken));
try {
chicken.goalSelector.addGoal(3, new MoreTemptation(chicken, 1.0D, false, Chicken));
} catch(IllegalArgumentException e) {
// whoops
}
}

if (entity instanceof CowEntity) {
CowEntity cow = (CowEntity) entity;
cow.goalSelector.addGoal(3, new MoreTemptation(cow, 1.25D, false, Grain));
try {
cow.goalSelector.addGoal(3, new MoreTemptation(cow, 1.25D, false, Grain));
} catch(IllegalArgumentException e) {
// whoops
}
}

if (entity instanceof SheepEntity) {
SheepEntity sheep = (SheepEntity) entity;
sheep.goalSelector.addGoal(3, new MoreTemptation(sheep, 1.0D, false, Grain));
try {
sheep.goalSelector.addGoal(3, new MoreTemptation(sheep, 1.0D, false, Grain));
} catch(IllegalArgumentException e) {
// whoops
}
}

if (entity instanceof PigEntity) {
PigEntity pig = (PigEntity) entity;
pig.goalSelector.addGoal(4, new MoreTemptation(pig, 1.2D, false, Pig));
try {
pig.goalSelector.addGoal(4, new MoreTemptation(pig, 1.2D, false, Pig));
} catch(IllegalArgumentException e) {
// whoops
}
}

if (entity instanceof RabbitEntity) {
RabbitEntity rabbit = (RabbitEntity) entity;
rabbit.goalSelector.addGoal(4, new MoreTemptation(rabbit, 1.2D, false, Rabbit));
try {
rabbit.goalSelector.addGoal(4, new MoreTemptation(rabbit, 1.2D, false, Rabbit));
} catch(IllegalArgumentException e) {
// whoops
}
}
}
}
}

0 comments on commit 1b89af4

Please sign in to comment.