-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
2,589 additions
and
138 deletions.
There are no files selected for viewing
140 changes: 130 additions & 10 deletions
140
forge2/src/main/java/flaxbeard/thaumicexploration/ThaumicExploration.java
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
forge2/src/main/java/flaxbeard/thaumicexploration/ai/EntityAICreeperDummy.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,57 @@ | ||
package flaxbeard.thaumicexploration.ai; | ||
|
||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.ai.EntityAIBase; | ||
import net.minecraft.entity.monster.EntityCreeper; | ||
|
||
public class EntityAICreeperDummy extends EntityAIBase | ||
{ | ||
/** The creeper that is swelling. */ | ||
EntityCreeper swellingCreeper; | ||
|
||
/** | ||
* The creeper's attack target. This is used for the changing of the creeper's state. | ||
*/ | ||
EntityLivingBase creeperAttackTarget; | ||
|
||
public EntityAICreeperDummy(EntityCreeper par1EntityCreeper) | ||
{ | ||
this.swellingCreeper = par1EntityCreeper; | ||
this.setMutexBits(1); | ||
} | ||
|
||
/** | ||
* Returns whether the EntityAIBase should begin execution. | ||
*/ | ||
public boolean shouldExecute() | ||
{ | ||
EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget(); | ||
return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSqToEntity(entitylivingbase) < 9.0D; | ||
} | ||
|
||
/** | ||
* Execute a one shot task or start executing a continuous task | ||
*/ | ||
public void startExecuting() | ||
{ | ||
this.swellingCreeper.getNavigator().clearPathEntity(); | ||
this.creeperAttackTarget = this.swellingCreeper.getAttackTarget(); | ||
} | ||
|
||
/** | ||
* Resets the task | ||
*/ | ||
public void resetTask() | ||
{ | ||
this.creeperAttackTarget = null; | ||
} | ||
|
||
/** | ||
* Updates the task | ||
*/ | ||
public void updateTask() | ||
{ | ||
this.swellingCreeper.setCreeperState(-1); | ||
|
||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
...e2/src/main/java/flaxbeard/thaumicexploration/ai/EntityAINearestAttackablePureTarget.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,107 @@ | ||
package flaxbeard.thaumicexploration.ai; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import net.minecraft.command.IEntitySelector; | ||
import net.minecraft.entity.EntityCreature; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.ai.EntityAINearestAttackableTargetSorter; | ||
import net.minecraft.entity.ai.EntityAITarget; | ||
|
||
public class EntityAINearestAttackablePureTarget extends EntityAITarget | ||
{ | ||
private final Class targetClass; | ||
private final int targetChance; | ||
|
||
/** Instance of EntityAINearestAttackableTargetSorter. */ | ||
private final EntityAINearestAttackableTargetSorter theNearestAttackableTargetSorter; | ||
|
||
/** | ||
* This filter is applied to the Entity search. Only matching entities will be targetted. (null -> no | ||
* restrictions) | ||
*/ | ||
private final IEntitySelector targetEntitySelector; | ||
private EntityLivingBase targetEntity; | ||
|
||
public EntityAINearestAttackablePureTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4) | ||
{ | ||
this(par1EntityCreature, par2Class, par3, par4, false); | ||
} | ||
|
||
public EntityAINearestAttackablePureTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5) | ||
{ | ||
this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector)null); | ||
} | ||
|
||
public EntityAINearestAttackablePureTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector) | ||
{ | ||
super(par1EntityCreature, par4, par5); | ||
this.targetClass = par2Class; | ||
this.targetChance = par3; | ||
this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTargetSorter(par1EntityCreature); | ||
this.setMutexBits(1); | ||
this.targetEntitySelector = new EntityAINearestAttackableTargetSelectorReplacement(this, par6IEntitySelector); | ||
} | ||
|
||
public boolean isSuitableTarget(EntityLivingBase par1EntityLivingBase, boolean par2) | ||
{ | ||
System.out.println("is suitable?"); | ||
if (par1EntityLivingBase.getEntityData().hasKey("tainted")) | ||
{ | ||
if (par1EntityLivingBase.getEntityData().getBoolean("tainted") == true) | ||
{ | ||
return false; | ||
} | ||
} | ||
System.out.println("is suitable."); | ||
return super.isSuitableTarget(par1EntityLivingBase, par2); | ||
|
||
} | ||
|
||
/** | ||
* Returns whether the EntityAIBase should begin execution. | ||
*/ | ||
public boolean shouldExecute() | ||
{ | ||
if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
double d0 = this.getTargetDistance(); | ||
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, 4.0D, d0), this.targetEntitySelector); | ||
Collections.sort(list, this.theNearestAttackableTargetSorter); | ||
List mobsToRemove = new ArrayList<Object>(); | ||
for (Object mob : list) { | ||
if (!this.isSuitableTarget((EntityLivingBase) mob, false)) { | ||
mobsToRemove.add(mob); | ||
} | ||
} | ||
for (Object mob : mobsToRemove) { | ||
list.remove(mob); | ||
} | ||
|
||
if (list.isEmpty()) | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
this.targetEntity = (EntityLivingBase)list.get(0); | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Execute a one shot task or start executing a continuous task | ||
*/ | ||
public void startExecuting() | ||
{ | ||
this.taskOwner.setAttackTarget(this.targetEntity); | ||
super.startExecuting(); | ||
} | ||
} |
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
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
Oops, something went wrong.