private void SearchAndSpawnBlocks() { SpawnMap = new HashMap<String, Boolean>(); DataMap = new HashMap<String, String>(); WideSearchQueue = new LinkedList<Position>(); WideSearchCount = 0; WideSearchQueue.offer(new Position(X, Y, Z)); while (WideSearchCount++ < AnimalCrossing.WideSearchMax && !WideSearchQueue.isEmpty()) { SearchNext(world, WideSearchQueue.poll()); } Set<String> Keys = SpawnMap.keySet(); int SpawnedCount = 0; for (String key : Keys) { if (!SpawnMap.get(key)) continue; Position pos = Position.from(key); int wx = (int) pos.getX(); int wy = (int) pos.getY(); int wz = (int) pos.getZ(); world.setBlockToAir(wx, wy, wz); String[] vals = DataMap.get(key).split(":"); int eID = UtilNumber.getParsedInt(vals[0]); int eMeta = UtilNumber.getParsedInt(vals[1]); EntityFallingTreePart entity = new EntityFallingTreePart( world, pos.getX() + .5D, pos.getY() + .5D, pos.getZ() + .5D, eID, eMeta, new Position(X, Y, Z), Block.blocksList[eID].getBlockDropped( world, wx, wy, wz, eMeta, EnchantmentHelper.getFortuneModifier(player))); entity.setPosition(wx + .5D, wy + .5D, wz + .5D); world.spawnEntityInWorld(entity); ModLoader.getMinecraftInstance().theWorld.spawnEntityInWorld(entity); SpawnedCount++; } player.getCurrentEquippedItem().damageItem(SpawnedCount, player); Achievements.triggerAchievement(player, Achievements.cutATree); }
private void SearchNext(World world, Position now) { if (SpawnMap.containsKey(now.getVisualityValue())) return; Block cb = Block.blocksList[UtilWorld.getBlockID(world, now)]; String cz = cb == null ? "!@#@!" : cb.getClass().getSimpleName(); if (UtilBlock.isEqualWoodBlocks(world, now, new Position(X, Y, Z)) || AnimalCrossing.isLeaf( UtilWorld.getBlockID(world, now), UtilWorld.getBlockMetadata(world, now), cz)) { SpawnMap.put(now.getVisualityValue(), Boolean.valueOf(true)); DataMap.put( now.getVisualityValue(), String.format( "%d:%d", UtilWorld.getBlockID(world, now), UtilWorld.getBlockMetadata(world, now))); UtilPosition.putAroundNextPositions(now, WideSearchQueue); } else { SpawnMap.put(now.getVisualityValue(), Boolean.valueOf(false)); } }