@Override public BaseBiome getBiome(BlockVector2 position) { checkNotNull(position); return new BaseBiome(Biome.getIdForBiome(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())))); }
public static BlockPos toBlockPos(BlockVector3 vector) { return new BlockPos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); }
/** * Set a tile entity at the given location. * * @param world the world * @param position the position * @param clazz the tile entity class * @param tag the tag for the tile entity (may be null to not set NBT data) */ static void setTileEntity(World world, BlockVector3 position, Class<? extends TileEntity> clazz, @Nullable NBTTagCompound tag) { checkNotNull(world); checkNotNull(position); checkNotNull(clazz); TileEntity tileEntity = constructTileEntity(world, position, clazz); if (tileEntity == null) { return; } if (tag != null) { // Set X, Y, Z updateForSet(tag, position); tileEntity.readFromNBT(tag); } world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity); }
@Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { checkNotNull(position); checkNotNull(biome); Chunk chunk = getWorld().getChunkFromBlockCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ())); if (chunk.isLoaded()) { chunk.getBiomeArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = (byte) biome.getId(); return true; } return false; }
/** * Set a tile entity at the given location using the tile entity ID from * the tag. * * @param world the world * @param position the position * @param tag the tag for the tile entity (may be null to do nothing) */ static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) { if (tag != null) { updateForSet(tag, position); TileEntity tileEntity = TileEntity.create(world, tag); if (tileEntity != null) { world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity); } } }
@Override public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) { BlockPos loc = ForgeAdapter.toBlockPos(pos); if (block == null) { // TODO // player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); } else { // TODO // player.sendBlockChange(loc, BukkitAdapter.adapt(block)); if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { player.connection.sendPacket(new SPacketUpdateTileEntity( new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), 7, NBTConverter.toNative(((BaseBlock) block).getNbtData())) ); } } }
@Override public BaseBlock getFullBlock(BlockVector3 position) { BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); TileEntity tile = getWorld().getTileEntity(pos); if (tile != null) { return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile))); } else { return getBlock(position).toBaseBlock(); } }
@Override public BlockState getBlock(BlockVector3 position) { World world = getWorld(); BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); IBlockState mcState = world.getBlockState(pos); BlockType blockType = BlockType.REGISTRY.get(Block.REGISTRY.getNameForObject(mcState.getBlock()).toString()); return blockType.getState(adaptProperties(blockType, mcState.getProperties())); }
BlockPos pos = new BlockPos(x, y, z); IBlockState old = chunk.getBlockState(pos); Block mcBlock = Block.getBlockFromName(block.getBlockType().getId());
public TileEntity getTile() { if( this.isItem ) { return null; } return this.w.getTileEntity( new BlockPos( this.x, this.y, this.z ) ); }
public static MultiblockSet makeMultiblockSet() { Multiblock mb = new Multiblock(); for(BlockPos p : PYLON_LOCATIONS) mb.addComponent(p.up(), ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.GAIA)); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) mb.addComponent(new BeaconComponent(new BlockPos(i - 1, 0, j - 1))); mb.addComponent(new BeaconBeamComponent(new BlockPos(0, 1, 0))); mb.setRenderOffset(new BlockPos(0, -1, 0)); return mb.makeSet(); }
@Override public boolean canBlockSeeTheSky( final int x, final int y, final int z ) { if( this.range( x, y, z ) ) { return this.getWorld().canBlockSeeSky( new BlockPos( x, y, z ) ); } return false; }
public static BlockPos getBoundTile(ItemStack stack) { int x = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_X, 0); int y = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Y, -1); int z = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Z, 0); return new BlockPos(x, y, z); }
public BlockPos getPoolCoords(ItemStack stack) { int x = ItemNBTHelper.getInt(stack, TAG_POS_X, 0); int y = ItemNBTHelper.getInt(stack, TAG_POS_Y, -1); int z = ItemNBTHelper.getInt(stack, TAG_POS_Z, 0); return new BlockPos(x, y, z); }
@Override public InvWithLocation getSparkInventory() { int x = MathHelper.floor(posX); int y = MathHelper.floor(posY - 1); int z = MathHelper.floor(posZ); return InventoryHelper.getInventoryWithLocation(world, new BlockPos(x, y, z), EnumFacing.UP); }
@Override public void onUsingTick(ItemStack stack, EntityLivingBase player, int time) { if(!player.world.isRemote) { if(time != getMaxItemUseDuration(stack) && time % 5 == 0) breakGrass(player.world, stack, stack.getItemDamage(), new BlockPos(player)); player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.BLOCKS, 1F, 0.001F); } }
@Override public void setBlock( final int x, final int y, final int z, final Block blk ) { if( this.range( x, y, z ) ) { this.verticalBits |= 1 << ( y >> 4 ); this.getWorld().setBlockState( new BlockPos( x, y, z ), blk.getDefaultState() ); } }
@Override public ISparkAttachable getAttachedTile() { int x = MathHelper.floor(posX); int y = MathHelper.floor(posY) - 1; int z = MathHelper.floor(posZ); TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile != null && tile instanceof ISparkAttachable) return (ISparkAttachable) tile; return null; }
/** * Returns the multiblock component for the coordinates, adjusted based on the anchor */ private MultiblockComponent getComponent(BlockPos pos) { return multiblock.getComponentForLocation(pos.add(new BlockPos(-anchorPos.getX(), -anchorPos.getY(), -anchorPos.getZ()))); } }
@Override public void readFromPacketNBT(NBTTagCompound cmp) { mana = cmp.getInteger(TAG_MANA); passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); int x = cmp.getInteger(TAG_COLLECTOR_X); int y = cmp.getInteger(TAG_COLLECTOR_Y); int z = cmp.getInteger(TAG_COLLECTOR_Z); cachedCollectorCoordinates = y < 0 ? null : new BlockPos(x, y, z); }