@Override public Block getFromString(String representation) { return blockManager.getBlock(representation); }
@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 void initialize() { blockManager = CoreRegistry.get(BlockManager.class); block = blockManager.getBlock(blockUri); }
@Override public void generate(BlockManager blockManager, CoreChunk view, Random rand, int posX, int posY, int posZ) { for (int y = posY; y < posY + 3; y++) { safelySetBlock(view, posX, y, posZ, blockManager.getBlock(cactusType)); } }
@Override public final Block getBlock(int x, int y, int z) { short id = (short) blockData.get(x, y, z); return blockManager.getBlock(id); }
@ReceiveEvent(priority = EventPriority.PRIORITY_TRIVIAL) public void onDestroyed(DoDestroyEvent event, EntityRef entity, BlockRegionComponent blockRegion) { for (Vector3i blockPosition : blockRegion.region) { worldProvider.setBlock(blockPosition, blockManager.getBlock(BlockManager.AIR_ID)); } } }
BlockPlacementBenchmark(Context context, boolean useSetBlocksInsteadOfSetBlock) { this.worldProvider = context.get(org.terasology.world.WorldProvider.class); LocalPlayer localPlayer = context.get(LocalPlayer.class); this.region3i = BenchmarkScreen.getChunkRegionAbove(localPlayer.getPosition()); BlockManager blockManager = context.get(BlockManager.class); this.stone = blockManager.getBlock("Core:Stone"); this.useSetBlocksInsteadOfSetBlock = useSetBlocksInsteadOfSetBlock; this.air = blockManager.getBlock("engine:air"); blockToPlace = stone; }
private void deactivateBlocks() { List<TShortObjectMap<TIntList>> deactivatedBlockSets = Lists.newArrayListWithExpectedSize(deactivateBlocksQueue.size()); deactivateBlocksQueue.drainTo(deactivatedBlockSets); for (TShortObjectMap<TIntList> deactivatedBlockSet : deactivatedBlockSets) { deactivatedBlockSet.forEachEntry((id, positions) -> { if (positions.size() > 0) { blockManager.getBlock(id).getEntity().send(new BeforeDeactivateBlocks(positions, registry)); } return true; }); } }
@ReceiveEvent(priority = EventPriority.PRIORITY_LOW) public void doDestroy(DoDestroyEvent event, EntityRef entity, BlockComponent blockComponent) { commonDestroyed(event, entity, blockComponent.block); worldProvider.setBlock(blockComponent.position, blockManager.getBlock(BlockManager.AIR_ID)); }
@Override public Block setBlock(int x, int y, int z, Block block) { if (blockData == blockDataSnapshot) { blockData = blockData.copy(); } int oldValue = blockData.set(x, y, z, block.getId()); return blockManager.getBlock((short) oldValue); }
private static void registerBlockWithIdAndEntity(final short blockId, final EntityRef blockEntity, final BlockManager blockManager) { final Block block = new Block(); block.setEntity(blockEntity); when(blockManager.getBlock(eq(blockId))).thenReturn(block); }
@Override public final Block getBlock(BaseVector3i pos) { short id = (short) blockData.get(pos.x(), pos.y(), pos.z()); return blockManager.getBlock(id); }
@Override public void generate(BlockManager blockManager, CoreChunk view, Random rand, int posX, int posY, int posZ) { Vector3f position = new Vector3f(0f, 0f, 0f); Matrix4f rotation = new Matrix4f(new Quat4f(new Vector3f(0f, 0f, 1f), (float) Math.PI / 2f), Vector3f.ZERO, 1.0f); float angleOffset = rand.nextFloat(-MAX_ANGLE_OFFSET, MAX_ANGLE_OFFSET); Block bark = blockManager.getBlock(barkType); Block leaf = blockManager.getBlock(leafType); recursiveGenerator.recurse(view, rand, posX, posY, posZ, angleOffset, new CharSequenceIterator(initialAxiom), position, rotation, bark, leaf, 0, this); }
private ChunkViewCore createWorldView(Region3i region, Vector3i offset) { Chunk[] chunks = new Chunk[region.size().x * region.size().y * region.size().z]; for (Vector3i chunkPos : region) { Chunk chunk = chunkCache.get(chunkPos); if (chunk == null || !chunk.isReady()) { return null; } chunkPos.sub(region.min()); int index = TeraMath.calculate3DArrayIndex(chunkPos, region.size()); chunks[index] = chunk; } return new ChunkViewCoreImpl(chunks, region, offset, blockManager.getBlock(BlockManager.AIR_ID)); }
private void sendOnActivatedBlocks(final ReadyChunkInfo readyChunkInfo) { PerformanceMonitor.startActivity("Sending OnActivateBlocks"); readyChunkInfo.getBlockPositionMapppings().forEachEntry((id, positions) -> { if (positions.size() > 0) { blockManager.getBlock(id).getEntity().send(new OnActivatedBlocks(positions, registry)); } return true; }); PerformanceMonitor.endActivity(); }
private void sendOnAddedBlocks(final ReadyChunkInfo readyChunkInfo) { PerformanceMonitor.startActivity("Sending OnAddedBlocks"); readyChunkInfo.getBlockPositionMapppings().forEachEntry((id, positions) -> { if (positions.size() > 0) { blockManager.getBlock(id).getEntity().send(new OnAddedBlocks(positions, registry)); } return true; }); PerformanceMonitor.endActivity(); }
private Block createBlock(String urn, AssetManager assetManager, BlockManager blockManager) { BlockFamilyDefinitionData data = new BlockFamilyDefinitionData(); data.setBlockFamily(SymmetricFamily.class); assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class); return blockManager.getBlock(urn); }
private Block createBlockWithPrefab(String urn, Prefab prefab, boolean keepActive, AssetManager assetManager, BlockManager blockManager) { BlockFamilyDefinitionData data = new BlockFamilyDefinitionData(); data.setBlockFamily(SymmetricFamily.class); data.getBaseSection().getEntity().setPrefab(prefab); data.getBaseSection().getEntity().setKeepActive(keepActive); assetManager.loadAsset(new ResourceUrn(urn), data, BlockFamilyDefinition.class); return blockManager.getBlock(urn); }