net.minecraft.entity.Entity.getPassengers()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中net.minecraft.entity.Entity.getPassengers()方法的一些代码示例,展示了Entity.getPassengers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getPassengers()方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getPassengers

Entity.getPassengers介绍

暂无

代码示例

代码示例来源:origin: vadis365/TheErebus

public Entity getParasite(Entity entityIn) {
  for (Entity entity : entityIn.getPassengers())
    if (entity instanceof EntityBotFlyLarva)
      return entity;
  return null;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

final List<Entity> passangers = entity.getPassengers();
final List<Entity> passangersOnOtherSide = new ArrayList<>();
if( !passangers.isEmpty() )

代码示例来源:origin: SleepyTrousers/EnderIO

private void cleanupUnspawnedEntity(Entity entity) {
 if (entity != null) {
  final Entity ridingEntity = entity.getRidingEntity();
  if (ridingEntity != null) {
   ridingEntity.setDead();
  }
  for (Entity passenger : entity.getPassengers()) {
   passenger.setDead();
  }
 }
}

代码示例来源:origin: FTBTeam/FTB-Utilities

private static boolean isEntityAllowed(Entity entity)
{
  if (entity instanceof EntityPlayer)
  {
    return true;
  }
  if (FTBUtilitiesConfig.world.safe_spawn && FTBUtilitiesUniverseData.isInSpawn(entity.getServer(), new ChunkDimPos(entity)))
  {
    if (entity instanceof IMob)
    {
      return false;
    }
    else
    {
      return !(entity instanceof EntityChicken) || entity.getPassengers().isEmpty();
    }
  }
  return true;
}

代码示例来源:origin: Vazkii/Quark

@Override
public IMessage handleMessage(MessageContext context) {
  EntityPlayer player = context.getServerHandler().player;
  if(player.isRiding() && player.openContainer == player.inventoryContainer) {
    Entity riding = player.getRidingEntity();
    if(riding instanceof EntityBoat) {
      List<Entity> passengers = riding.getPassengers();
      for(Entity passenger : passengers)
        if(passenger instanceof EntityChestPassenger)
          player.displayGUIChest((EntityChestPassenger) passenger);
    }
  }
  
  return null;
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

float degree_idle = myrmex.isHiding() ?  0.1F : 0.25F;
if(entity.getPassengers().isEmpty()) {
  this.faceTarget(f3, f4, 2, NECK);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

float speed_fly = 1.1F;
float degree_fly = 1F;
if(entity.getPassengers().isEmpty()) {
  this.faceTarget(f3, f4, 2, NECK);

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

private void updateRiding(Entity riding) {
  if (riding.isPassenger(this) && riding instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer) riding;
    int ridingIndex = riding.getPassengers().indexOf(this);
    float radius = (ridingIndex == 2 ? 0.0F : 0.35F) + (player.isElytraFlying() ? 2 : 0);
    float renderYawOffset = player.renderYawOffset;
    float angle = (float) Math.toRadians(renderYawOffset + (ridingIndex == 1 ? -90 : ridingIndex == 0 ? 90 : 0));
    double offsetX = (double) (radius * MathHelper.sin((float) (Math.PI + angle)));
    double offsetZ = (double) (radius * MathHelper.cos(angle));
    double offsetY = (riding.isSneaking() ? 1.2 : 1.38) + (ridingIndex == 2 ? 0.4 : 0.0);
    this.rotationYaw = player.rotationYawHead;
    this.rotationYawHead = player.rotationYawHead;
    this.prevRotationYaw = player.rotationYawHead;
    this.setPosition(riding.posX + offsetX, riding.posY + offsetY, riding.posZ + offsetZ);
    this.setAnimation(EntityAnimation.IDLE.get());
    if (player.isElytraFlying()) {
      this.dismountRidingEntity();
    }
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public void updateRiding(Entity riding) {
  if (riding != null && riding.isPassenger(this) && riding instanceof EntityPlayer) {
    int i = riding.getPassengers().indexOf(this);
    float radius = (i == 2 ? 0F : 0.4F) + (((EntityPlayer) riding).isElytraFlying() ? 2 : 0);
    float angle = (0.01745329251F * ((EntityPlayer) riding).renderYawOffset) + (i == 1 ? -90 : i == 0 ? 90 : 0);
    double extraX = (double) (radius * MathHelper.sin((float) (Math.PI + angle)));
    double extraZ = (double) (radius * MathHelper.cos(angle));
    double extraY = (riding.isSneaking() ? 1.2D : 1.4D) + (i == 2 ? 0.4D : 0D);
    this.rotationYaw = ((EntityPlayer) riding).rotationYawHead;
    this.rotationYawHead = ((EntityPlayer) riding).rotationYawHead;
    this.prevRotationYaw = ((EntityPlayer) riding).rotationYawHead;
    this.setPosition(riding.posX + extraX, riding.posY + extraY, riding.posZ + extraZ);
    if (this.getControlState() == 1 << 4 || ((EntityPlayer) riding).isElytraFlying()) {
      this.dismountRidingEntity();
    }
  }
}

代码示例来源:origin: CoFH/ThermalDynamics

if (entity.getPassengers().get(0) instanceof EntityPlayer) {
  player = (EntityPlayer) entity.getPassengers().get(0);

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent
public void onEntityInteract(EntityInteract event) {
  Entity target = event.getTarget();
  if(target instanceof EntityMinecartEmpty && target.getPassengers().isEmpty()) {
    EntityPlayer player = event.getEntityPlayer();
    EnumHand hand = EnumHand.MAIN_HAND;

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent(priority = EventPriority.HIGH)
@SideOnly(Side.CLIENT)
public void onOpenGUI(GuiOpenEvent event) {
  EntityPlayer player = Minecraft.getMinecraft().player;
  if(player != null && event.getGui() instanceof GuiInventory && player.isRiding()) {
    Entity riding = player.getRidingEntity();
    if(riding instanceof EntityBoat) {
      List<Entity> passengers = riding.getPassengers();
      for(Entity passenger : passengers)
        if(passenger instanceof EntityChestPassenger) {
          NetworkHandler.INSTANCE.sendToServer(new MessageRequestPassengerChest());
          event.setCanceled(true);
          return;
        }
    }
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

ridingEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, 0.0F);
for (Entity passenger : entity.getPassengers()) {
 passenger.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, 0.0F);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

@Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
  AdvancedModelRenderer[] GASTER = new AdvancedModelRenderer[]{Body4, Body5, Tail1, Tail2, Stinger};
  AdvancedModelRenderer[] NECK = new AdvancedModelRenderer[]{Neck1, HeadBase};
  AdvancedModelRenderer[] LEGR1 = new AdvancedModelRenderer[]{legTopR1, legMidR1, legBottomR1};
  AdvancedModelRenderer[] LEGR2 = new AdvancedModelRenderer[]{legTopR2, legMidR2, legBottomR2};
  AdvancedModelRenderer[] LEGR3 = new AdvancedModelRenderer[]{legTopR3, legMidR3, legBottomR3};
  AdvancedModelRenderer[] LEGL1 = new AdvancedModelRenderer[]{legTopR1_1, legMidR1_1, legBottomR1_1};
  AdvancedModelRenderer[] LEGL2 = new AdvancedModelRenderer[]{legTopR2_1, legMidR2_1, legBottomR2_1};
  AdvancedModelRenderer[] LEGL3 = new AdvancedModelRenderer[]{legTopR3_1, legMidR3_1, legBottomR3_1};
  float speed_walk = 0.9F;
  float speed_idle = 0.05F;
  float degree_walk = 0.3F;
  float degree_idle = 0.25F;
  if(entity.getPassengers().isEmpty()) {
    this.faceTarget(f3, f4, 2, NECK);
  }
  this.chainWave(GASTER, speed_idle, degree_idle * 0.25F, 0, entity.ticksExisted, 1);
  this.chainWave(NECK, speed_idle, degree_idle * -0.15F, 2, entity.ticksExisted, 1);
  this.swing(MandibleR, speed_idle * 2F, degree_idle * -0.75F, false, 1, 0.2F, entity.ticksExisted, 1);
  this.swing(MandibleL, speed_idle * 2F, degree_idle * -0.75F, true, 1, 0.2F, entity.ticksExisted, 1);
  this.animateLeg(LEGR1, speed_walk, degree_walk, false, 0, 1, f, f1);
  this.animateLeg(LEGR3, speed_walk, degree_walk, false, 0, 1, f, f1);
  this.animateLeg(LEGR2, speed_walk, degree_walk, true, 0, 1, f, f1);
  this.animateLeg(LEGL1, speed_walk, degree_walk, false, 1, -1, f, f1);
  this.animateLeg(LEGL3, speed_walk, degree_walk, false, 1, -1, f, f1);
  this.animateLeg(LEGL2, speed_walk, degree_walk, true, 1, -1, f, f1);
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

@Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
  AdvancedModelRenderer[] GASTER = new AdvancedModelRenderer[]{Body4, Body5, Tail1, Tail2, Stinger};
  AdvancedModelRenderer[] NECK = new AdvancedModelRenderer[]{Neck1, HeadBase};
  AdvancedModelRenderer[] LEGR1 = new AdvancedModelRenderer[]{legTopR1, legMidR1, legBottomR1};
  AdvancedModelRenderer[] LEGR2 = new AdvancedModelRenderer[]{legTopR2, legMidR2, legBottomR2};
  AdvancedModelRenderer[] LEGR3 = new AdvancedModelRenderer[]{legTopR3, legMidR3, legBottomR3};
  AdvancedModelRenderer[] LEGL1 = new AdvancedModelRenderer[]{legTopR1_1, legMidR1_1, legBottomR1_1};
  AdvancedModelRenderer[] LEGL2 = new AdvancedModelRenderer[]{legTopR2_1, legMidR2_1, legBottomR2_1};
  AdvancedModelRenderer[] LEGL3 = new AdvancedModelRenderer[]{legTopR3_1, legMidR3_1, legBottomR3_1};
  float speed_walk = 0.9F;
  float speed_idle = 0.05F;
  float degree_walk = 0.3F;
  float degree_idle = 0.25F;
  if(entity.getPassengers().isEmpty()) {
    this.faceTarget(f3, f4, 2, NECK);
  }
  this.chainWave(GASTER, speed_idle, degree_idle * 0.15F, 0, entity.ticksExisted, 1);
  this.chainWave(NECK, speed_idle, degree_idle * -0.15F, 2, entity.ticksExisted, 1);
  this.swing(MandibleR, speed_idle, degree_idle * -0.5F, false, 1, 0.2F, entity.ticksExisted, 1);
  this.swing(MandibleL, speed_idle, degree_idle * -0.5F, true, 1, 0.2F, entity.ticksExisted, 1);
  this.animateLeg(LEGR1, speed_walk, degree_walk, false, 0, 1, f, f1);
  this.animateLeg(LEGR3, speed_walk, degree_walk, false, 0, 1, f, f1);
  this.animateLeg(LEGR2, speed_walk, degree_walk, true, 0, 1, f, f1);
  this.animateLeg(LEGL1, speed_walk, degree_walk, false, 1, -1, f, f1);
  this.animateLeg(LEGL3, speed_walk, degree_walk, false, 1, -1, f, f1);
  this.animateLeg(LEGL2, speed_walk, degree_walk, true, 1, -1, f, f1);
}

代码示例来源:origin: Vazkii/Quark

@Override
public void doRender(EntityChestPassenger entity, double x, double y, double z, float entityYaw, float partialTicks) {
  super.doRender(entity, x, y, z, entityYaw, partialTicks);
  if(!entity.isRiding())
    return;
  Entity boat = entity.getRidingEntity();
  float rot = 180F - entityYaw;
  
  ItemStack stack = entity.getChestType();
  
  GlStateManager.pushMatrix();
  GlStateManager.translate(x, y, z);
  GlStateManager.rotate(rot, 0F, 1F, 0F);
  GlStateManager.translate(0F, 0.7F, -0.15F);
  if(boat.getPassengers().size() == 1)
    GlStateManager.translate(0F, 0F, 0.6F);	
  
  GlStateManager.scale(1.75F, 1.75F, 1.75F);
  
  Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);        
  GlStateManager.popMatrix();
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private void handleGuardCommand(Command cmd) {
  Entity e = cmd.getEntityTarget(npc.world);
  if (e == null) {
    npc.setPlayerCommand(null);//clear the command if the target entity cannot be found
    return;
  }
  double sqDist = npc.getDistanceSq(e);
  if (sqDist > MIN_RANGE) {
    moveToEntity(e, sqDist);//move to entity...
  } else {
    npc.getNavigator().clearPath();//clear path to stop moving
    if (e instanceof EntityHorse) {
      if (!npc.isRiding() && e.getPassengers().isEmpty()) {
        npc.startRiding(e);
        e.prevRotationYaw = e.rotationYaw = npc.rotationYaw % 360F;
        npc.setPlayerCommand(null);//clear command if horse was mounted successfully..
      } else if (npc.isRiding() && npc.getRidingEntity() == e) {
        npc.dismountRidingEntity();
        npc.setPlayerCommand(null);
      }
    }
    //do not clear command, guard command is persistent
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

this.animateLeg(LEGL2, speed_walk * 0.5F, degree_walk * 0.5F, true, 1, -1, entity.ticksExisted, 1);
if (entity.getPassengers().isEmpty()) {
  this.faceTarget(f3, f4, 2, NECK);

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent
public void onEntityInteract(EntityInteract event) {
  Entity target = event.getTarget();
  EntityPlayer player = event.getEntityPlayer();
  if(target instanceof EntityBoat && target.getPassengers().isEmpty()) {
    EnumHand hand = EnumHand.MAIN_HAND;
    ItemStack stack = player.getHeldItemMainhand();
    if(!isChest(stack)) {
      stack = player.getHeldItemOffhand();
      hand = EnumHand.OFF_HAND;
    }
    if(isChest(stack)) {
      World world = event.getWorld();
      EntityChestPassenger passenger = new EntityChestPassenger(world, stack);
      passenger.setPosition(target.posX, target.posY, target.posZ);
      passenger.rotationYaw = target.rotationYaw;
      
      if(!player.isCreative())
        stack.shrink(1);
      
      world.spawnEntity(passenger);
      passenger.startRiding(target);
      
      player.swingArm(hand);
      if(!event.getWorld().isRemote)
        event.setCanceled(true);
    }
  }
}

代码示例来源:origin: Vazkii/Quark

EntityPlayer player = event.getEntityPlayer();
if(target instanceof EntityBoat && !target.getPassengers().contains(player)) {
  ItemStack banner = getBanner((EntityBoat) target);
  if(!banner.isEmpty())

相关文章

Entity类方法