-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to make the reducer work with the new IAF. IAF config has been split in two, one for the new and one for 1.7.1. This should give somewhat better performance in modern IAF.
- Loading branch information
1 parent
599ce32
commit fcb17a8
Showing
33 changed files
with
892 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 13 additions & 8 deletions
21
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexAIEscortEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.ai.WrappedTask; | ||
import com.charles445.aireducer.config.ModConfig; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public class WrappedTaskMyrmexAIEscortEntity extends WrappedTaskMyrmex | ||
public class WrappedTaskMyrmexAIEscortEntity extends WrappedTaskMyrmexRunDelay | ||
{ | ||
public WrappedTaskMyrmexAIEscortEntity(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
public double getUpdateChance() | ||
|
||
@Override | ||
public boolean canModify() | ||
{ | ||
return ModConfig.iceandfire.myrmexUpdateChanceEscortEntity; | ||
return ModConfig.iceandfire.myrmexModifyEscortEntity; | ||
} | ||
|
||
@Override | ||
public int getRunDelay() | ||
{ | ||
return ModConfig.iceandfire.myrmexRunDelayEscortEntity; | ||
} | ||
|
||
@Override | ||
public void updateTask() | ||
public double getUpdateChance() | ||
{ | ||
if(entity.getRNG().nextDouble() < this.getUpdateChance()) | ||
task.updateTask(); | ||
return ModConfig.iceandfire.myrmexUpdateChanceEscortEntity; | ||
} | ||
} |
19 changes: 12 additions & 7 deletions
19
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexAIFindHidingSpot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.ai.WrappedTask; | ||
import com.charles445.aireducer.config.ModConfig; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public class WrappedTaskMyrmexAIFindHidingSpot extends WrappedTaskMyrmex | ||
public class WrappedTaskMyrmexAIFindHidingSpot extends WrappedTaskMyrmexRunDelay | ||
{ | ||
public WrappedTaskMyrmexAIFindHidingSpot(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
public double getUpdateChance() | ||
@Override | ||
public boolean canModify() | ||
{ | ||
return ModConfig.iceandfire.myrmexUpdateChanceFindHidingSpot; | ||
return ModConfig.iceandfire.myrmexModifyFindHidingSpot; | ||
} | ||
|
||
@Override | ||
public int getRunDelay() | ||
{ | ||
return ModConfig.iceandfire.myrmexRunDelayFindHidingSpot; | ||
} | ||
|
||
@Override | ||
public void updateTask() | ||
public double getUpdateChance() | ||
{ | ||
if(entity.getRNG().nextDouble() < this.getUpdateChance()) | ||
task.updateTask(); | ||
return ModConfig.iceandfire.myrmexUpdateChanceFindHidingSpot; | ||
} | ||
} |
21 changes: 13 additions & 8 deletions
21
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexAIForage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.ai.WrappedTask; | ||
import com.charles445.aireducer.config.ModConfig; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public class WrappedTaskMyrmexAIForage extends WrappedTaskMyrmex | ||
public class WrappedTaskMyrmexAIForage extends WrappedTaskMyrmexRunDelay | ||
{ | ||
public WrappedTaskMyrmexAIForage(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
public double getUpdateChance() | ||
|
||
@Override | ||
public boolean canModify() | ||
{ | ||
return ModConfig.iceandfire.myrmexUpdateChanceForage; | ||
return ModConfig.iceandfire.myrmexModifyForage; | ||
} | ||
|
||
@Override | ||
public int getRunDelay() | ||
{ | ||
return ModConfig.iceandfire.myrmexRunDelayForage; | ||
} | ||
|
||
@Override | ||
public void updateTask() | ||
public double getUpdateChance() | ||
{ | ||
if(entity.getRNG().nextDouble() < this.getUpdateChance()) | ||
task.updateTask(); | ||
return ModConfig.iceandfire.myrmexUpdateChanceForage; | ||
} | ||
} |
82 changes: 9 additions & 73 deletions
82
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexAILeaveHive.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,32 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.config.ModConfig; | ||
import com.charles445.aireducer.debug.DebugUtil; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public class WrappedTaskMyrmexAILeaveHive extends WrappedTaskMyrmex | ||
public class WrappedTaskMyrmexAILeaveHive extends WrappedTaskMyrmexRunDelay | ||
{ | ||
public WrappedTaskMyrmexAILeaveHive(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
@Override | ||
public void resetTask() | ||
public boolean canModify() | ||
{ | ||
|
||
return ModConfig.iceandfire.myrmexModifyLeaveHive; | ||
} | ||
|
||
@Override | ||
public boolean shouldExecute() | ||
public int getRunDelay() | ||
{ | ||
if(!ModConfig.iceandfire.myrmexModifyLeaveHive) | ||
return super.shouldExecute(); | ||
|
||
//Follow later versions' code to use shouldEnterHive early on | ||
|
||
if(reflector.c_EntityMyrmexQueen.isInstance(entity)) | ||
return false; | ||
|
||
if(entity.isChild()) | ||
return false; | ||
|
||
if(!reflector.canMove(entity)) | ||
return false; | ||
|
||
if(!reflector.shouldLeaveHive(entity)) | ||
return false; | ||
|
||
//The change | ||
if(reflector.shouldEnterHive(entity)) | ||
return false; | ||
|
||
//Go back to normal | ||
boolean shouldExecute = super.shouldExecute(); | ||
|
||
/* | ||
if(shouldExecute) | ||
{ | ||
//Show the path with fire | ||
Path path = reflector.getMyrmexAILeaveHive_path(task); | ||
DebugUtil.dotPathPoints(entity.getEntityWorld(), path); | ||
BlockPos nextEntrance = reflector.getMyrmexAILeaveHive_nextEntrance(task); | ||
DebugUtil.sendParticle(entity.getEntityWorld(), EnumParticleTypes.BARRIER, nextEntrance.getX(), nextEntrance.getY(), nextEntrance.getZ()); | ||
} | ||
*/ | ||
|
||
return shouldExecute; | ||
return ModConfig.iceandfire.myrmexRunDelayLeaveHive; | ||
} | ||
|
||
|
||
@Override | ||
public boolean shouldContinueExecuting() | ||
public double getUpdateChance() | ||
{ | ||
//Complete override | ||
|
||
if(!ModConfig.iceandfire.myrmexModifyLeaveHive) | ||
return super.shouldContinueExecuting(); | ||
|
||
//Rearranged a little bit | ||
|
||
if(!reflector.shouldLeaveHive(entity)) | ||
return false; | ||
|
||
if(entity.getNavigator().noPath()) | ||
{ | ||
return false; | ||
} | ||
|
||
double distanceCheck = entity.getDistanceSq(reflector.getMyrmexAILeaveHive_nextEntrance(task)); | ||
|
||
if(distanceCheck <= 3.0) | ||
{ | ||
return false; | ||
} | ||
|
||
if(reflector.shouldEnterHive(entity)) | ||
return false; | ||
|
||
|
||
|
||
return true; | ||
return ModConfig.iceandfire.myrmexUpdateChanceLeaveHive; | ||
} | ||
} |
21 changes: 17 additions & 4 deletions
21
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexAIMoveThroughHive.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.config.ModConfig; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public class WrappedTaskMyrmexAIMoveThroughHive extends WrappedTaskMyrmex | ||
public class WrappedTaskMyrmexAIMoveThroughHive extends WrappedTaskMyrmexRunDelay | ||
{ | ||
|
||
public WrappedTaskMyrmexAIMoveThroughHive(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
@Override | ||
public void resetTask() | ||
public boolean canModify() | ||
{ | ||
return ModConfig.iceandfire.myrmexModifyMoveThroughHive; | ||
} | ||
|
||
@Override | ||
public int getRunDelay() | ||
{ | ||
return ModConfig.iceandfire.myrmexRunDelayMoveThroughHive; | ||
} | ||
|
||
@Override | ||
public double getUpdateChance() | ||
{ | ||
|
||
return ModConfig.iceandfire.myrmexUpdateChanceMoveThroughHive; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexAIWanderHiveCenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.config.ModConfig; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public class WrappedTaskMyrmexAIWanderHiveCenter extends WrappedTaskMyrmexRunDelay | ||
{ | ||
public WrappedTaskMyrmexAIWanderHiveCenter(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
@Override | ||
public boolean canModify() | ||
{ | ||
return ModConfig.iceandfire.myrmexModifyWanderHiveCenter; | ||
} | ||
|
||
@Override | ||
public int getRunDelay() | ||
{ | ||
return ModConfig.iceandfire.myrmexRunDelayWanderHiveCenter; | ||
} | ||
|
||
@Override | ||
public double getUpdateChance() | ||
{ | ||
return ModConfig.iceandfire.myrmexUpdateChanceWanderHiveCenter; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/com/charles445/aireducer/ai/myrmex/WrappedTaskMyrmexRunDelay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.charles445.aireducer.ai.myrmex; | ||
|
||
import com.charles445.aireducer.config.ModConfig; | ||
|
||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
|
||
public abstract class WrappedTaskMyrmexRunDelay extends WrappedTaskMyrmex | ||
{ | ||
int lastRun = -10000; | ||
|
||
public WrappedTaskMyrmexRunDelay(EntityLiving entity, EntityAIBase task) | ||
{ | ||
super(entity, task); | ||
} | ||
|
||
public abstract boolean canModify(); | ||
public abstract int getRunDelay(); | ||
public abstract double getUpdateChance(); | ||
|
||
@Override | ||
public boolean shouldExecute() | ||
{ | ||
if(!this.canModify()) | ||
return super.shouldExecute(); | ||
|
||
if(lastRun < (entity.ticksExisted - this.getRunDelay())) | ||
{ | ||
return super.shouldExecute(); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public void startExecuting() | ||
{ | ||
if(!this.canModify()) | ||
{ | ||
super.startExecuting(); | ||
return; | ||
} | ||
|
||
lastRun = entity.ticksExisted; | ||
|
||
super.startExecuting(); | ||
} | ||
|
||
@Override | ||
public void updateTask() | ||
{ | ||
if(!this.canModify()) | ||
{ | ||
super.updateTask(); | ||
return; | ||
} | ||
|
||
double updateChance = this.getUpdateChance(); | ||
|
||
if(updateChance <= 0.0d) | ||
return; | ||
|
||
if(updateChance >= 1.0d) | ||
{ | ||
super.updateTask(); | ||
return; | ||
} | ||
|
||
if(entity.getRNG().nextDouble() < updateChance) | ||
{ | ||
super.updateTask(); | ||
return; | ||
} | ||
} | ||
} |
Oops, something went wrong.