本文整理了Java中net.minecraft.world.World.getEntitiesWithinAABB()
方法的一些代码示例,展示了World.getEntitiesWithinAABB()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getEntitiesWithinAABB()
方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getEntitiesWithinAABB
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private int countEntitesAround( World world, BlockPos pos )
{
final AxisAlignedBB t = new AxisAlignedBB( pos ).grow( 8 );
final List<Entity> list = world.getEntitiesWithinAABB( Entity.class, t );
return list.size();
}
}
代码示例来源:origin: Vazkii/Botania
public static <T> List<T> getEntitiesAround(Class<? extends T> clazz, World world, double x, double y, double z) {
int r = SPARK_SCAN_RANGE;
List entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x - r, y - r, z - r, x + r, y + r, z + r), Predicates.instanceOf(clazz));
return entities;
}
代码示例来源:origin: Vazkii/Botania
List<EntityItem> getItems() {
return world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
}
代码示例来源:origin: Vazkii/Botania
private List<ICorporeaSpark> getNearbySparks() {
return (List) world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE), Predicates.instanceOf(ICorporeaSpark.class));
}
代码示例来源:origin: Vazkii/Botania
/**
* Gets the spark attached to the block in the coords passed in. Note that the coords passed
* in are for the block that the spark will be on, not the coords of the spark itself.
*/
public static ICorporeaSpark getSparkForBlock(World world, BlockPos pos) {
List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.add(1, 2, 1)), Predicates.instanceOf(ICorporeaSpark.class));
return sparks.isEmpty() ? null : (ICorporeaSpark) sparks.get(0);
}
代码示例来源:origin: Vazkii/Botania
public List<ItemStack> getFilter() {
List<ItemStack> filter = new ArrayList<>();
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
for(EntityItemFrame frame : frames) {
EnumFacing orientation = frame.facingDirection;
if(orientation == dir)
filter.add(frame.getDisplayedItem());
}
}
return filter;
}
代码示例来源:origin: Vazkii/Botania
@Override
public ISparkEntity getAttachedSpark() {
List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
if(sparks.size() == 1) {
Entity e = (Entity) sparks.get(0);
return (ISparkEntity) e;
}
return null;
}
代码示例来源:origin: Vazkii/Botania
@Override
public ISparkEntity getAttachedSpark() {
List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
if(sparks.size() == 1) {
Entity e = sparks.get(0);
return (ISparkEntity) e;
}
return null;
}
代码示例来源:origin: Vazkii/Botania
@Override
public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
if(burst.isFake()) {
if(entity.world.isRemote)
return;
AxisAlignedBB axis = new AxisAlignedBB(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).grow(0.25);
List<EntityLivingBase> entities = entity.world.getEntitiesWithinAABB(EntityLivingBase.class, axis);
if(!entities.isEmpty()) {
Entity e = (Entity) burst;
e.getEntityData().setBoolean(TAG_TRIPPED, true);
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void update() {
if (world.isRemote)
return;
int range = 6;
int entityCount = world.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))).size();
if(entityCount != entities) {
entities = entityCount;
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public ISparkEntity getAttachedSpark() {
List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, pos.getY() + 2, pos.getZ() + 1), Predicates.instanceOf(ISparkEntity.class));
if(sparks.size() == 1) {
Entity e = sparks.get(0);
return (ISparkEntity) e;
}
return null;
}
代码示例来源:origin: Vazkii/Botania
@Override
public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) {
World world = source.getTile().getWorld();
int x = source.getTile().getPos().getX(), y = source.getTile().getPos().getY(), z = source.getTile().getPos().getZ();
boolean output = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1), Predicates.instanceOf(IManaBurst.class)).size() != 0;
if(output)
for(int i = 0; i < 4; i++)
Botania.proxy.sparkleFX(x + Math.random(), y + Math.random(), z + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
return output;
}
代码示例来源:origin: Vazkii/Botania
private static int getGaiaGuardiansAround(World world, BlockPos source) {
float range = 15F;
List l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
return l.size();
}
代码示例来源:origin: Vazkii/Botania
@Override
public void update() {
boolean state = world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
boolean expectedState = world.getEntitiesWithinAABB(EntityThrowable.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)), Predicates.instanceOf(IManaBurst.class)).size() != 0;
if(state != expectedState && !world.isRemote)
world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, expectedState), 1 | 2);
if(expectedState)
for(int i = 0; i < 4; i++)
Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
if(!(player instanceof EntityPlayer))
return;
EntityPlayer eplayer = (EntityPlayer) player;
double range = 24;
AxisAlignedBB aabb = new AxisAlignedBB(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ).grow(range);
List<EntityLivingBase> mobs = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob);
if(!mobs.isEmpty())
for(EntityLivingBase e : mobs) {
PotionEffect potion = e.getActivePotionEffect(MobEffects.GLOWING);
if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true))
e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 12, 0));
}
}
代码示例来源:origin: Vazkii/Botania
private List<EntityPlayer> getPlayersAround() {
float range = 15F;
return world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
}
代码示例来源:origin: Vazkii/Botania
@SubscribeEvent
public static void onExplosion(ExplosionEvent.Detonate event) {
Explosion e = event.getExplosion();
Vec3d vec = e.getPosition();
List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(vec.x, vec.y, vec.z, vec.x, vec.y, vec.z).grow(8));
for(EntityPlayer player : players) {
ItemStack charm = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
if(!charm.isEmpty() && charm.getItem() instanceof ItemGoddessCharm && ManaItemHandler.requestManaExact(charm, player, COST, true)) {
event.getAffectedBlocks().clear();
return;
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(!supertile.getWorld().isRemote && mana > 0) {
List<EntityLivingBase> entities = supertile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(EntityLivingBase entity : entities)
if(!(entity instanceof EntityPlayer)) {
entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 2, 100));
mana--;
if(mana == 0)
return;
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(supertile.getWorld().isRemote || redstoneSignal > 0)
return;
final int cost = 20;
List<EntityLivingBase> entities = supertile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(EntityLivingBase entity : entities) {
if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(MobEffects.POISON) == null && mana >= cost && !entity.world.isRemote && entity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) {
entity.addPotionEffect(new PotionEffect(MobEffects.POISON, 60, 0));
mana -= cost;
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(!supertile.getWorld().isRemote && supertile.getWorld().provider.getDimension() != 1) {
boolean did = false;
List<EntityPlayer> players = supertile.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
for(EntityPlayer player : players) {
if(player.getActivePotionEffect(MobEffects.REGENERATION) == null && mana >= COST) {
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 59, 2, true, true));
mana -= COST;
did = true;
}
}
if(did)
sync();
}
}
内容来源于网络,如有侵权,请联系作者删除!