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

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

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

Entity.getEntityData介绍

暂无

代码示例

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

public static int getEntityOrbitTime(Entity entity) {
  NBTTagCompound cmp = entity.getEntityData();
  if(cmp.hasKey(TAG_ORBIT))
    return cmp.getInteger(TAG_ORBIT);
  else return 0;
}

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

public static void incrementOrbitTime(Entity entity) {
  NBTTagCompound cmp = entity.getEntityData();
  int time = getEntityOrbitTime(entity);
  cmp.setInteger(TAG_ORBIT, time + 1);
}

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

@Override
public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) {
  IManaBurst burst = spreader.runBurstSimulation();
  Entity e = (Entity) burst;
  return e.getEntityData().getBoolean(TAG_TRIPPED);
}

代码示例来源: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

@SubscribeEvent
public static void onMinecartUpdate(MinecartUpdateEvent event) {
  BlockPos entPos = new BlockPos(event.getEntity());
  IBlockState state = event.getEntity().world.getBlockState(entPos);
  Block block = state.getBlock();
  boolean air = block.isAir(state, event.getEntity().world, entPos);
  int floatTicks = event.getEntity().getEntityData().getInteger(TAG_FLOAT_TICKS);
  if(block == ModBlocks.ghostRail)
    event.getEntity().getEntityData().setInteger(TAG_FLOAT_TICKS, 20);
  else if(block instanceof BlockRailBase || block == ModBlocks.dreamwood) {
    event.getEntity().getEntityData().setInteger(TAG_FLOAT_TICKS, 0);
    if(floatTicks > 0)
      event.getEntity().world.playEvent(2003, entPos, 0);
  }
  floatTicks = event.getEntity().getEntityData().getInteger(TAG_FLOAT_TICKS);
  if(floatTicks > 0) {
    IBlockState stateBelow = event.getEntity().world.getBlockState(entPos.down());
    Block blockBelow = stateBelow.getBlock();
    boolean airBelow = blockBelow.isAir(stateBelow, event.getEntity().world, entPos.down());
    if(air && airBelow || !air && !airBelow)
      event.getEntity().noClip = true;
    event.getEntity().motionY = 0.2;
    event.getEntity().motionX *= 1.4;
    event.getEntity().motionZ *= 1.4;
    event.getEntity().getEntityData().setInteger(TAG_FLOAT_TICKS, floatTicks - 1);
    event.getEntity().world.playEvent(2000, entPos, 0);
  } else event.getEntity().noClip = false;
}

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

public static void release(@Nullable Entity entity) {
 if (entity != null && !entity.isDead) {
  NBTTagCompound data = entity.getEntityData();
  release(data);
 }
}

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

public static void reserve(@Nullable Entity entity, @Nullable BlockPos pullerPos) {
 if (entity != null && !entity.isDead) {
  NBTTagCompound data = entity.getEntityData();
  reserve(data, pullerPos);
 }
}

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

private boolean isEntityPoisoned(Entity e) {
  return e.getEntityData().getBoolean(TAG_POISONED);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

public static void setEntityInt(Entity entityevokerfangs, String string, int bIn) {
 entityevokerfangs.getEntityData().setInteger(string, bIn);
}

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

private void poisonEntity(Entity e) {
  e.getEntityData().setBoolean(TAG_POISONED, true);
}

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

public void enqueueTeleport(Entity entity, boolean sendUpdate) {
 if (entity == null || toTeleport.contains(entity)) {
  return;
 }
 calculateTeleportPower();
 entity.getEntityData().setBoolean(TELEPORTING_KEY, true);
 toTeleport.add(entity);
 if (sendUpdate) {
  if (entity.world.isRemote) {
   // NOP
  } else {
   PacketHandler.INSTANCE.sendToAll(new PacketTeleport(PacketTeleport.Type.BEGIN, this, entity));
  }
 }
}

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

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {
  if (!isEmpowered(stack)) {
    return;
  }
  NBTTagCompound tag = entity.getEntityData();
  tag.setLong(TFProps.EXPERIENCE_TIMER, entity.world.getTotalWorldTime());
}

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

@SubscribeEvent
public static void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone event)
{
  event.getEntity().getEntityData().removeTag(FTBUtilitiesPlayerData.TAG_LAST_CHUNK);
}

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

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {
  if (!isEmpowered(stack)) {
    return;
  }
  NBTTagCompound tag = entity.getEntityData();
  tag.setLong(TFProps.LEXICON_TIMER, entity.world.getTotalWorldTime());
}

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

@SubscribeEvent
public void entityUpdate(LivingUpdateEvent event) {
  Entity e = event.getEntity();
  if(e instanceof EntityParrot) {
    int time = e.getEntityData().getInteger(TAG_EGG_TIMER);
    if(time > 0) {
      if(time == 1) {
        e.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (e.world.rand.nextFloat() - e.world.rand.nextFloat()) * 0.2F + 1.0F);
        e.entityDropItem(new ItemStack(parrot_egg, 1, getResultingEggColor((EntityParrot) e)), 0);
      }
      e.getEntityData().setInteger(TAG_EGG_TIMER, time - 1);
    }
  }
}

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

private void updateQueuedEntities() {
 if (world.isRemote) {
  if (active()) {
   getCurrentTarget().getEntityData().setFloat(PROGRESS_KEY, getProgress());
  }
 }
 List<Entity> toRemove = Lists.newArrayList();
 for (Entity e : toTeleport) {
  if (!isEntityInRange(e) || e.isDead) {
   toRemove.add(e);
  }
 }
 for (Entity e : toRemove) {
  dequeueTeleport(e, true);
 }
}

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

@SubscribeEvent
public static void onDrop(LivingDropsEvent event) {
 Entity entity = event.getEntity();
 if (entity != null && NbtValue.INFINITY.getBoolean(entity.getEntityData()) && entity.world.rand.nextFloat() < InfinityConfig.dropChanceFogCreatures.get()) {
  EntityItem entityitem = new EntityItem(entity.world, entity.posX, entity.posY, entity.posZ, Material.POWDER_INFINITY.getStack());
  entityitem.setDefaultPickupDelay();
  event.getDrops().add(entityitem);
 }
}

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

@SubscribeEvent
public void onEntityDrops(LivingDropsEvent event) {
  if(event.getEntity().getEntityData().getBoolean(TAG_SHEARED))
    event.getDrops().removeIf((EntityItem e) -> e.getItem().getItem() == Items.FEATHER);
}

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

public static BlockPos getPlayerDeathPosition(Entity e) {
  if(e instanceof EntityPlayer) {
    NBTTagCompound cmp = e.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
    if(cmp.hasKey(TAG_LAST_TOTEM)) {
      int x = cmp.getInteger(TAG_DEATH_X);
      int z = cmp.getInteger(TAG_DEATH_Z);
      int dim = cmp.getInteger(TAG_DEATH_DIM);
      return new BlockPos(x, dim, z);
    }
  }
  
  return new BlockPos(0, -1, 0);
}

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

@SubscribeEvent
public static void attackEntityEvent(AttackEntityEvent event) {
 if (event.getEntityPlayer() == null || event.getEntityPlayer().world.isRemote) {
  return;
 }
 ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
 if (INSTANCE.hasAnyUpgradeVariant(stack) && EnergyUpgradeManager.getEnergyStored(stack) > 0) {
  event.getTarget().getEntityData().setUniqueId(HIT_BY_DIRECT, event.getEntityPlayer().getUniqueID());
 }
}

相关文章

Entity类方法