当前位置: 首页>>代码示例>>Java>>正文


Java TileEntityMobSpawner.getPos方法代码示例

本文整理汇总了Java中net.minecraft.tileentity.TileEntityMobSpawner.getPos方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityMobSpawner.getPos方法的具体用法?Java TileEntityMobSpawner.getPos怎么用?Java TileEntityMobSpawner.getPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.tileentity.TileEntityMobSpawner的用法示例。


在下文中一共展示了TileEntityMobSpawner.getPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findSpawners

import net.minecraft.tileentity.TileEntityMobSpawner; //导入方法依赖的package包/类
/**
 * search in all loaded TileEntities for MobSpawners,
 * when a new MobSpawner gets found, display its type and coordinates in chat.
 * @param showKnown show already found spawners
 */
public static void findSpawners(boolean showKnown) {
    final Minecraft mc = Minecraft.getMinecraft();
    if (mc == null || mc.theWorld == null || mc.theWorld.loadedTileEntityList == null)
        return;
    for (Object o : mc.theWorld.loadedTileEntityList) {
        if (o.getClass() == TileEntityMobSpawner.class) {
            final TileEntityMobSpawner spawnerTileEntity = (TileEntityMobSpawner) o;
            final BlockPos spawnerPos = spawnerTileEntity.getPos();
            if (showKnown || !foundSpawners.contains(spawnerPos)) {
                if (!showKnown) foundSpawners.add(spawnerPos);

                // tell player about newly found spawner
                NBTTagCompound nbt = new NBTTagCompound();
                spawnerTileEntity.writeToNBT(nbt);
                final String entityId = nbt.getString("EntityId");
                mc.thePlayer.addChatMessage(getSpawnerFoundChatMessage(spawnerPos, entityId));
            }
        }
    }
}
 
开发者ID:Gjum,项目名称:MobSpawnerFinder,代码行数:26,代码来源:MobSpawnerFinder.java

示例2: onHarvestDropsEvent

import net.minecraft.tileentity.TileEntityMobSpawner; //导入方法依赖的package包/类
@SubscribeEvent
public static void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent evt) {
  if (!evt.isCanceled() && evt.getState().getBlock() instanceof BlockMobSpawner) {
    if (dropCache.containsKey(evt.getPos())) {
      ItemStack stack = dropCache.get(evt.getPos());
      if (Prep.isValid(stack)) {
        evt.getDrops().add(stack);
        dropCache.put(evt.getPos().toImmutable(), Prep.getEmpty());
      }
    } else {
      // A spawner was broken---but not by a player. The TE has been
      // invalidated already, but we might be able to recover it.
      try {
        for (Object object : evt.getWorld().loadedTileEntityList) {
          if (object instanceof TileEntityMobSpawner) {
            TileEntityMobSpawner spawner = (TileEntityMobSpawner) object;
            BlockPos p = spawner.getPos();
            if (spawner.getWorld() == evt.getWorld() && p.equals(evt.getPos())) {
              // Bingo!
              MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
              ResourceLocation entityName = getEntityName(logic);
              if (entityName != null && !isBlackListed(entityName)) {
                final CapturedMob capturedMob = CapturedMob.create(entityName);
                if (capturedMob != null) {
                  evt.getDrops().add(capturedMob.toStack(ModObject.itemBrokenSpawner.getItemNN(), 0, 1));
                }
              }
            }
          }
        }
      } catch (Exception e) {
        // Risky recovery failed. Happens.
      }
    }
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:37,代码来源:BrokenSpawnerHandler.java


注:本文中的net.minecraft.tileentity.TileEntityMobSpawner.getPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。