@Override public Block getFromString(String representation) { return blockManager.getBlock(representation); }
@Override public BlockFamily getFromString(String representation) { return blockManager.getBlockFamily(representation); }
@Override public void begin() { BlockManager blockManager = context.get(BlockManager.class); blockFamilyIterator = blockManager.listRegisteredBlockFamilies().iterator(); setTotalSteps(blockManager.getBlockFamilyCount()); }
Optional<BlockFamilyDefinition> def = Assets.get(matchingUris.iterator().next(), BlockFamilyDefinition.class); if (def.isPresent()) { BlockFamily blockFamily = blockManager.getBlockFamily(uri); Block block = blockManager.getBlock(blockFamily.getURI()); world.setBlock(targetLocation.position, block); } else if (matchingUris.size() > 1) {
for (BlockFamily family : blockManager.listRegisteredBlockFamilies()) { registeredBlockFamilies.add(family.getURI().toString()); gameManifest.setBlockIdMap(blockManager.getBlockIdMap()); List<Biome> biomes = biomeManager.getBiomes(); Map<String, Short> biomeIdMap = new HashMap<>(biomes.size());
@Override public boolean step() { BlockManager blockManager = context.get(BlockManager.class); for (BlockFamily blockFamily : blockManager.listRegisteredBlockFamilies()) { InjectionHelper.inject(blockFamily, context); } return true; }
stringBuilder.append("-----------"); stringBuilder.append(Console.NEW_LINE); List<BlockUri> registeredBlocks = sortItems(blockManager.listRegisteredBlockUris()); for (BlockUri blockUri : registeredBlocks) { if (!uriStartsWithAnyString(blockUri.toString(), startsWith)) {
for (Map.Entry<String, Short> blockMapping : blockManager.getBlockIdMap().entrySet()) { serverInfoMessageBuilder.addBlockId(blockMapping.getValue()); serverInfoMessageBuilder.addBlockName(blockMapping.getKey()); serverInfoMessageBuilder.addBiomeShortId(shortId); for (BlockFamily registeredBlockFamily : blockManager.listRegisteredBlockFamilies()) { serverInfoMessageBuilder.addRegisterBlockFamily(registeredBlockFamily.getURI().toString());
private void updateExistingBlocks() { for (BlockFamily blockFamily : blockManager.listRegisteredBlockFamilies()) { for (Block block : blockFamily.getBlocks()) { updateBlock(block); } } }
@Override public void initialize() { BlockManager blockManager = CoreRegistry.get(BlockManager.class); stone = blockManager.getBlock("core:stone"); water = blockManager.getBlock("core:water"); ice = blockManager.getBlock("core:Ice"); sand = blockManager.getBlock("core:Sand"); grass = blockManager.getBlock("core:Grass"); snow = blockManager.getBlock("core:Snow"); dirt = blockManager.getBlock("core:Dirt"); }
@Override public BlockFamily parse(String raw) { Preconditions.checkNotNull(raw, "'raw' must not be null!"); return CoreRegistry.get(BlockManager.class).getBlockFamily(raw); }
private void generateForExistingBlocks() { for (BlockFamily blockFamily : blockManager.listRegisteredBlockFamilies()) { for (Block block : blockFamily.getBlocks()) { if (!block.getEntity().exists()) { generateBlockTypeEntity(block); } } } }
if (def.get().isFreeform()) { if (shapeUriParam == null) { blockFamily = blockManager.getBlockFamily(new BlockUri(def.get().getUrn(), new ResourceUrn("engine:cube"))); } else { Set<ResourceUrn> resolvedShapeUris = Assets.resolveAssetUri(shapeUriParam, BlockShape.class); blockFamily = blockManager.getBlockFamily(new BlockUri(def.get().getUrn(), resolvedShapeUris.iterator().next())); blockFamily = blockManager.getBlockFamily(new BlockUri(def.get().getUrn()));
@Override public void initialize() { BlockManager blockManager = CoreRegistry.get(BlockManager.class); air = blockManager.getBlock(BlockManager.AIR_ID); flora.put(FloraType.GRASS, ImmutableList.<Block>of( blockManager.getBlock("core:TallGrass1"), blockManager.getBlock("core:TallGrass2"), blockManager.getBlock("core:TallGrass3"))); flora.put(FloraType.FLOWER, ImmutableList.<Block>of( blockManager.getBlock("core:Dandelion"), blockManager.getBlock("core:Glowbell"), blockManager.getBlock("core:Iris"), blockManager.getBlock("core:Lavender"), blockManager.getBlock("core:RedClover"), blockManager.getBlock("core:RedFlower"), blockManager.getBlock("core:Tulip"), blockManager.getBlock("core:YellowFlower"))); flora.put(FloraType.MUSHROOM, ImmutableList.<Block>of( blockManager.getBlock("core:BigBrownShroom"), blockManager.getBlock("core:BrownShroom"), blockManager.getBlock("core:RedShroom"))); }
EntityRef chest = blockFactory.newInstance(blockManager.getBlockFamily("core:chest")); chest.addComponent(new InventoryComponent(30)); inventoryManager.giveItem(chest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:companion"), 99)); inventoryManager.giveItem(chest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:brick:engine:stair"), 99)); inventoryManager.giveItem(chest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Tnt"), 99)); inventoryManager.giveItem(chest, EntityRef.NULL, entityManager.create("core:fuseShort")); inventoryManager.giveItem(chest, EntityRef.NULL, entityManager.create("core:fuseLong")); inventoryManager.giveItem(chest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Brick"), 99)); inventoryManager.giveItem(chest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Ice"), 99)); inventoryManager.giveItem(chest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Plank"), 99)); EntityRef innerChest = blockFactory.newInstance(blockManager.getBlockFamily("core:Chest")); innerChest.addComponent(new InventoryComponent(30)); inventoryManager.giveItem(innerChest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:lava"), 99)); inventoryManager.giveItem(innerChest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:water"), 99)); inventoryManager.giveItem(innerChest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Iris"), 99)); inventoryManager.giveItem(innerChest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Dandelion"), 99)); inventoryManager.giveItem(innerChest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Tulip"), 99)); inventoryManager.giveItem(innerChest, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:YellowFlower"), 99)); inventoryManager.giveItem(player, EntityRef.NULL, entityManager.create("core:axe")); inventoryManager.giveItem(player, EntityRef.NULL, entityManager.create("core:shovel")); inventoryManager.giveItem(player, EntityRef.NULL, blockFactory.newInstance(blockManager.getBlockFamily("core:Torch"), 99)); inventoryManager.giveItem(player, EntityRef.NULL, entityManager.create("core:explodeTool")); inventoryManager.giveItem(player, EntityRef.NULL, entityManager.create("core:railgunTool"));
@Override public void initialize() { blockManager = CoreRegistry.get(BlockManager.class); block = blockManager.getBlock(blockUri); }
EntityRef dropItem = blockItemFactory.newInstance(blockManager.getBlockFamily(dropParser.getDrop()), dropParser.getCount()); if (shouldDropToWorld(event, blockDamageModifierComponent, dropItem)) { createDrop(dropItem, locationComp.getWorldPosition(), true);
/** * Spawns a block in front of the player * * @param sender Sender of command * @param blockName String containing name of block to spawn * @return String containg final message */ @Command(shortDescription = "Spawns a block in front of the player", helpText = "Spawns the specified block as a " + "item in front of the player. You can simply pick it up.", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION) public String spawnBlock(@Sender EntityRef sender, @CommandParam("blockName") String blockName) { ClientComponent clientComponent = sender.getComponent(ClientComponent.class); LocationComponent characterLocation = clientComponent.character.getComponent(LocationComponent.class); Vector3f spawnPos = characterLocation.getWorldPosition(); Vector3f offset = characterLocation.getWorldDirection(); offset.scale(3); spawnPos.add(offset); BlockFamily block = blockManager.getBlockFamily(blockName); if (block == null) { return ""; } BlockItemFactory blockItemFactory = new BlockItemFactory(entityManager); EntityRef blockItem = blockItemFactory.newInstance(block); blockItem.send(new DropItemEvent(spawnPos)); return "Spawned block."; }