本文整理汇总了Java中net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry类的典型用法代码示例。如果您正苦于以下问题:Java EntityAITaskEntry类的具体用法?Java EntityAITaskEntry怎么用?Java EntityAITaskEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityAITaskEntry类属于net.minecraft.entity.ai.EntityAITasks包,在下文中一共展示了EntityAITaskEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spawnEvent
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
if (event.entity instanceof EntityPig) {
EntityPig pig = (EntityPig) event.entity;
if (EtFuturum.enableBeetroot)
pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
} else if (event.entity instanceof EntityChicken) {
EntityChicken chicken = (EntityChicken) event.entity;
if (EtFuturum.enableBeetroot)
chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
} else if (event.entity instanceof EntityWolf) {
EntityWolf wolf = (EntityWolf) event.entity;
if (EtFuturum.enableRabbit)
wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
} else if (event.entity instanceof EntityVillager) {
EntityVillager villager = (EntityVillager) event.entity;
for (Object obj : villager.tasks.taskEntries) {
EntityAITaskEntry entry = (EntityAITaskEntry) obj;
if (entry.action instanceof EntityAIOpenDoor) {
villager.tasks.removeTask(entry.action);
villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
break;
}
}
}
}
示例2: onUpdate
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (stack.getItemDamage() != 20)
return;
if (!(entity instanceof EntityPlayer) || (entity instanceof FakePlayer))
return;
if (itemSlot < ((EntityPlayer)entity).inventory.getHotbarSize()) {
List<EntityLiving> entities = entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(entity.getPosition().add(-range, -range, -range), entity.getPosition().add(range, range, range)));
for (EntityLiving ent : entities) {
List<EntityAITaskEntry> entries = new ArrayList(ent.tasks.taskEntries);
entries.addAll(new ArrayList(ent.targetTasks.taskEntries));
for (EntityAITaskEntry entry : entries) {
if (entry.action instanceof EntityAIAttackRangedBow) {
makeSkellyShootSlower((EntityAIAttackRangedBow)entry.action);
}
}
if (ent instanceof EntityCreeper)
ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper)ent, 60, this.FUSETIME);
}
}
}
示例3: initEntityAI
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@Override
protected void initEntityAI() {
super.initEntityAI();
EntityAIBase remove = null;
for(EntityAITaskEntry task : this.tasks.taskEntries) {
if(task.action.getClass().getSimpleName().equals("AIFireballAttack")) {
remove = task.action;
break;
}
}
if(remove != null) {
this.tasks.removeTask(remove);
this.tasks.addTask(7, new AIUnderworldFireballAttack(this));
} else {
Log.logger.error(this.getName() + " failed to override Ghast fireball AI.");
}
}
示例4: applyLists
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
public static void applyLists(Entity entity, List<EntityAITaskEntry> tasks, List<EntityAITaskEntry> targetTasks)
{
if(hasEntityAI(entity))
{
clearExecutingTasks(entity);
clearExecutingTargetTasks(entity);
getTasksList(entity).clear();
getTargetTasksList(entity).clear();
getTargetTasksList(entity).addAll(targetTasks);
getTasksList(entity).addAll(tasks);
for(EntityAITaskEntry entry : tasks)
{
if(entry != null && entry.action != null)
{
setOwner(entry.action, entity);
if(entry.action instanceof EntityAIDoorInteract)
{
((EntityLiving)entity).getNavigator().setEnterDoors(true);
((EntityLiving)entity).getNavigator().setBreakDoors(true);
}
}
}
}
}
示例5: removeDummyAIBlockerTask
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
/**
* Removes the (last found) dummy blocker AI task, if any
* @param tasks
*/
public static void removeDummyAIBlockerTask(EntityAITasks tasks)
{
EntityAIBase task = null;
for (EntityAITaskEntry taskEntry : tasks.taskEntries)
{
if (taskEntry.action instanceof EntityAIDummyBlockerTask)
{
task = taskEntry.action;
}
// Restore the default mutex bits.
// TODO: If modded mob tasks use this bit, then we should store the original value so we can restore it.
if (taskEntry.action instanceof EntityAIFindEntityNearestPlayer)
{
taskEntry.action.setMutexBits(taskEntry.action.getMutexBits() & 0x7F);
}
}
if (task != null)
{
tasks.removeTask(task);
}
}
示例6: cancelCurrentTasks
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
public static void cancelCurrentTasks(EntityLiving ent) {
Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
while (iterator.hasNext()) {
EntityAITaskEntry entityaitaskentry = iterator.next();
if (entityaitaskentry != null) {
currentTasks.add(entityaitaskentry);
}
}
// Only available way to stop current execution is to remove all current
// tasks, then re-add them
for (EntityAITaskEntry task : currentTasks) {
ent.tasks.removeTask(task.action);
ent.tasks.addTask(task.priority, task.action);
}
ent.getNavigator().clearPathEntity();
}
示例7: cancelCurrentTasks
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
private void cancelCurrentTasks(EntityLiving ent) {
Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
while (iterator.hasNext()) {
EntityAITaskEntry entityaitaskentry = iterator.next();
if (entityaitaskentry != null) {
currentTasks.add(entityaitaskentry);
}
}
// Only available way to stop current execution is to remove all current
// tasks, then re-add them
for (EntityAITaskEntry task : currentTasks) {
ent.tasks.removeTask(task.action);
ent.tasks.addTask(task.priority, task.action);
}
}
示例8: isEntityAITaskActive
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
public static boolean isEntityAITaskActive(EntityLiving entity, String AIName) {
for(Object obj : entity.tasks.taskEntries) {
EntityAITaskEntry taskEntry = (EntityAITaskEntry) obj;
EntityAIBase task = taskEntry.action;
if(task instanceof IEntityAIAnimation) {
IEntityAIAnimation animatedTask = (IEntityAIAnimation) task;
if(animatedTask.getAIName().equals(AIName) && animatedTask.isExecuting())
return true;
}
}
return false;
}
示例9: eval
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@Nonnull
private static ActionState eval(@Nonnull final Set<EntityAITaskEntry> entries) {
ActionState state = ActionState.NONE;
for (final EntityAITaskEntry task : entries) {
final ActionState candidate = actions.get(task.action.getClass());
if (candidate != null) {
if (state.getPriority() < candidate.getPriority())
state = candidate;
}
}
return state;
}
示例10: removeTargetTasks
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
private void removeTargetTasks() {
// remove target tasks
Set<EntityAITaskEntry> entries = this.targetTasks.taskEntries;
Iterator<EntityAITaskEntry> iter = entries.iterator();
while(iter.hasNext()){
EntityAITaskEntry e = iter.next();
iter.remove();
}
}
示例11: encodeInto
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer)
{
EntityAITaskEntry[] tasksEntries = tasks.toArray(new EntityAITaskEntry[0]);
EntityAITaskEntry[] targetTasksEntries = targetTasks.toArray(new EntityAITaskEntry[0]);
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream outputStream = new DataOutputStream(baos);
outputStream.writeInt(entityID);
outputStream.writeInt(tasksEntries.length);
for(int i = 0;i<tasksEntries.length;i++)
outputStream.writeUTF(CustomAIHelper.generateJSONFromAI(null, tasksEntries[i]).toString());
outputStream.writeInt(targetTasksEntries.length);
for(int i = 0;i<targetTasksEntries.length;i++)
outputStream.writeUTF(CustomAIHelper.generateJSONFromAI(null, targetTasksEntries[i]).toString());
outputStream.flush();
baos.flush();
outputStream.close();
baos.close();
byte[] data = baos.toByteArray();
buffer.writeBytes(data);
}
catch(Exception e)
{
e.printStackTrace();
}
}
示例12: GuiIAListSlot
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
public GuiIAListSlot(int par1, EntityAITaskEntry taskEntry)
{
super(par1);
if(taskEntry == null || taskEntry.action == null)
this.displayString = "[ERROR] AI Task empty";
else
this.displayString = CustomAIHelper.getNameForTask(taskEntry.action);
this.task = taskEntry;
}
示例13: areTasksEqual
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
/**
* Check if two tasks are basically equal. Doesn't care about priority of each task
* @param e : Entity used to process the instances of JSONObject
* @param task : First task of the couple to check
* @param task2 : Second task of the couple to check
* @return true if tasks are equal
*/
@SuppressWarnings("unchecked")
private boolean areTasksEqual(Entity e, EntityAITaskEntry task, EntityAITaskEntry task2)
{
if(task == null || task2 == null || task.action == null || task2.action == null)
return false;
JSONObject firstTask = CustomAIHelper.generateJSONFromAI((EntityLiving) e, task);
JSONObject secondTask = CustomAIHelper.generateJSONFromAI((EntityLiving) e, task2);
if(firstTask.keySet().size() != secondTask.keySet().size())
return false;
else
{
if(!firstTask.getString("type").equals(secondTask.getString("type")))
return false;
Iterator<String> keys = firstTask.keys();
while(keys.hasNext())
{
String key = keys.next();
if(!key.equals("priority"))
{
try
{
if(!firstTask.get(key).equals(secondTask.get(key)))
{
return false;
}
}
catch(Exception exception)
{
return false;
}
}
}
return true;
}
}
示例14: getTasksList
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<EntityAITaskEntry> getTasksList(Entity entity)
{
if(hasEntityAI(entity))
{
EntityLiving living = (EntityLiving)entity;
return living.tasks.taskEntries;
}
return null;
}
示例15: getTargetTasksList
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<EntityAITaskEntry> getTargetTasksList(Entity entity)
{
if(hasEntityAI(entity))
{
EntityLiving living = (EntityLiving)entity;
return living.targetTasks.taskEntries;
}
return null;
}