Skip to content

Commit

Permalink
0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaxbeard committed Feb 4, 2014
1 parent e7387f5 commit 69aec9e
Show file tree
Hide file tree
Showing 51 changed files with 2,589 additions and 138 deletions.

Large diffs are not rendered by default.

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);

}
}
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public EntityAINearestAttackableTargetNecromancy(EntityCreature par1EntityCreatu
this.targetChance = par3;
this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTargetSorter(par1EntityCreature);
this.setMutexBits(1);
this.targetEntitySelector = new EntityAINearestAttackableTargetSelectorReplacement(this, par6IEntitySelector);
this.targetEntitySelector = null;
//this.targetEntitySelector = new EntityAINearestAttackableTargetSelectorReplacement(this, par6IEntitySelector);
}

public boolean isSuitableTarget(EntityLivingBase par1EntityLivingBase, boolean par2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class EntityAINearestAttackableTargetSelectorReplacement implements IEnti
{
final IEntitySelector field_111103_c;

final EntityAINearestAttackableTargetNecromancy field_111102_d;
final EntityAINearestAttackablePureTarget field_111102_d;

public EntityAINearestAttackableTargetSelectorReplacement(EntityAINearestAttackableTargetNecromancy par1EntityAINearestAttackableTargetNecromancy, IEntitySelector par2IEntitySelector)
EntityAINearestAttackableTargetSelectorReplacement(EntityAINearestAttackablePureTarget par1EntityAINearestAttackableTargetNecromancy, IEntitySelector par2IEntitySelector)
{
this.field_111102_d = par1EntityAINearestAttackableTargetNecromancy;
this.field_111103_c = par2IEntitySelector;
Expand All @@ -20,7 +20,7 @@ public EntityAINearestAttackableTargetSelectorReplacement(EntityAINearestAttacka
* Return whether the specified entity is applicable to this filter.
*/
public boolean isEntityApplicable(Entity par1Entity)
{
{
return !(par1Entity instanceof EntityLivingBase) ? false : (this.field_111103_c != null && !this.field_111103_c.isEntityApplicable(par1Entity) ? false : this.field_111102_d.isSuitableTarget((EntityLivingBase)par1Entity, false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ public void breakBlock(World par1World, int par2, int par3, int par4, int par5,
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (!world.isRemote) {
int id = ((TileEntityBoundJar)world.getBlockTileEntity(x, y, z)).id;
int amt1 = ((TileEntityBoundJar)world.getBlockTileEntity(x, y, z)).myJarData.getJarAmount();
int amt2 = ((TileEntityBoundJar)world.getBlockTileEntity(x, y, z)).amount;
System.out.println("ID: " + id + " Bound amount: " + amt1 + " Contained amount: " + amt2);
world.markBlockForUpdate(x, y, z);
}
TileEntity te = world.getBlockTileEntity(x, y, z);
Expand Down
Loading

0 comments on commit 69aec9e

Please sign in to comment.