public static Vec3d toVec3(BlockVector3 vector) { return new Vec3d(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); }
public static BlockPos toBlockPos(BlockVector3 vector) { return new BlockPos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); }
public Square(BlockPos subtileCoords, int expand) { super(subtileCoords, new AxisAlignedBB(subtileCoords.add(-expand, 0, -expand), subtileCoords.add(expand + 1, 0, expand + 1))); }
public boolean equalPos(RayTraceResult pos) { return pos.getBlockPos().equals(this.pos.getBlockPos()); } }
@Override public boolean equals(Object other) { if(!(other instanceof SwapCandidate)) return false; SwapCandidate cand = (SwapCandidate) other; return coordinates.equals(cand.coordinates) && range == cand.range; }
private static RayTraceResult rayTrace2(BlockPos pos, Vec3d start, Vec3d end, AxisAlignedBB boundingBox) { Vec3d vec3d = start.subtract((double) pos.getX(), (double) pos.getY(), (double) pos.getZ()); Vec3d vec3d1 = end.subtract((double) pos.getX(), (double) pos.getY(), (double) pos.getZ()); RayTraceResult raytraceresult = boundingBox.calculateIntercept(vec3d, vec3d1); return raytraceresult == null ? null : new RayTraceResult(raytraceresult.hitVec.addVector((double) pos.getX(), (double) pos.getY(), (double) pos.getZ()), raytraceresult.sideHit, pos); }
@Override public BaseBiome getBiome(BlockVector2 position) { checkNotNull(position); return new BaseBiome(Biome.getIdForBiome(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())))); }
@Override public Vec3d getFogColor( final float par1, final float par2 ) { return new Vec3d( 0.07, 0.07, 0.07 ); }
@Override public boolean equals(Object o) { return o instanceof DimWithPos && dim == ((DimWithPos) o).dim && blockPos.equals(((DimWithPos) o).blockPos); }
/** * 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 equals(Object o) { return o instanceof PositionProperties && ((PositionProperties) o).state == state && ((PositionProperties) o).coords.equals(coords); } }
/** * 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 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; }
@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());