當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。