public BlockData getTarget(BlockPos pos) { EnumFacing[] orderedFacingValues = new EnumFacing[] { EnumFacing.UP, EnumFacing.EAST, EnumFacing.NORTH, EnumFacing.WEST, EnumFacing.SOUTH, EnumFacing.DOWN }; for (EnumFacing facing : orderedFacingValues) { BlockPos alteredPos = pos.add(facing.getOpposite().getDirectionVec()); if (!mc.theWorld.getBlockState(alteredPos).getBlock().isReplaceable(mc.theWorld, alteredPos) && !(mc.theWorld.getBlockState(alteredPos).getBlock() instanceof BlockLiquid) && !(mc.theWorld.getBlockState(alteredPos).getBlock() instanceof BlockAir)) { return new BlockData(alteredPos, facing); } } return null; }
public static boolean isTouchingLiquid() { Minecraft mc = Minecraft.getMinecraft(); boolean inLiquid = false; int y = (int) mc.player.boundingBox.minY; for (int x = floor_double(mc.player.boundingBox.minX); x < floor_double(mc.player.boundingBox.maxX) + 1; x++) { for (int z = floor_double(mc.player.boundingBox.minZ); z < floor_double(mc.player.boundingBox.maxZ) + 1; z++) { net.minecraft.block.Block block = mc.world.getBlockState(new BlockPos(x, y, z)).getBlock(); if ((block != null) && (!(block instanceof BlockAir))) { if (!(block instanceof BlockLiquid)) { return false; } inLiquid = true; } } } return inLiquid; }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f, int i) { TileEntity_Railing tile = (TileEntity_Railing) t; if (!tile.isInvalid()) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y-1, z + 0.5); bindTexture(texture); Block right = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(1,-1,0))).getBlock(); Block left = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(-1,0,0))).getBlock(); Block front = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,1))).getBlock(); Block back = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,-1))).getBlock(); if(!(left instanceof BlockAir)&&!(left instanceof Block_Railing)){ model.renderPart("left"); }else if(!(right instanceof BlockAir)&&!(right instanceof Block_Railing)){ model.renderPart("right"); }else model.renderPart("middle"); GL11.glPopMatrix(); } }
@Override public Object parseObject(String input) { Object[] objects = StringUtils.StringToObjects(input); if(objects.length == 4 && objects[0] instanceof String && objects[1] instanceof Integer && objects[2] instanceof Integer && (objects[3] instanceof NBTTagCompound || objects[3] instanceof String)) { ItemStack stack = null; if(Item.itemRegistry.getObject((String)objects[0]) != null) stack = new ItemStack((Item)Item.itemRegistry.getObject((String)objects[0])); else if(!(Block.blockRegistry.getObject((String)objects[0]) instanceof BlockAir)) stack = new ItemStack((Block)Block.blockRegistry.getObject((String)objects[0])); else return null; stack.stackSize = (Integer)objects[1]; stack.setItemDamage((Integer)objects[2]); if(objects[3] instanceof NBTTagCompound) stack.stackTagCompound = (NBTTagCompound)objects[3]; return stack; } return null; }
public ItemInfo(ItemStack stack, boolean needDamage, boolean needNBT) { if(stack == null) this.item = ""; else { if(Block.getBlockFromItem(stack.getItem()) instanceof BlockAir) this.item = Item.itemRegistry.getNameForObject(stack.getItem()); else this.item = Block.blockRegistry.getNameForObject(Block.getBlockFromItem(stack.getItem())); } if(needDamage) this.damage = stack.getItemDamage(); else this.damage = -1; if(needNBT) this.nbt = stack.stackTagCompound; else this.nbt = null; this.ore = ""; }
private static boolean CheckBlock(World world, BlockPos blockPos, boolean forceAir) { IBlockState blockState = world.getBlockState(blockPos); if (blockState == null) return true; // Check to make sure it is an air block, or replaceable... if ((blockState.getBlock() instanceof BlockAir && forceAir) || (blockState.getBlock().isReplaceable(world, blockPos) && forceAir)) return true; else if (forceAir) return false; // Check to make sure it is not an Tile Entity if (blockState.getBlock().hasTileEntity(blockState)) return false; // Make sure the block isn't unbreakable if (blockState.getBlock().getBlockHardness(world.getBlockState(blockPos), world, blockPos) == -1.0F) { return false; } // Make sure the block is on the whitelist //return BreakableWhiteListHelper.checkBlock(blockState); return false; }
/** * Method used to detect if a block is above this block (blocking our sunlight). * * @param world world object. * @param blockPos Block position. */ public boolean canSeeAbove(World world, BlockPos blockPos) { boolean clear = true; if (!world.isRemote) { for (int yy = blockPos.getY() + 1; yy < 255; yy++) { // Block b = world.getBlock(x, yy, z); Block b = BlockUtils.getBlock(world, blockPos.getX(), yy, blockPos.getZ()).getBlock(); if (b != null && !(b instanceof BlockAir)) { clear = false; break; } } } return clear; }
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); for (int i = 0; i < connection.length; i++) { connection[i] = nbt.getBoolean("connect" + i); } String name = nbt.getString("block"); if(!name.equals("")) { block = Block.getBlockFromName(name); if(block instanceof BlockAir) block = null; meta = nbt.getInteger("meta"); } }
@Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); transmitedPower = pkt.func_148857_g().getInteger("transpower"); for (int i = 0; i < connection.length; i++) { connection[i] = pkt.func_148857_g().getBoolean("connect" + i); } String name = pkt.func_148857_g().getString("block"); if(!name.equals("")) { block = Block.getBlockFromName(name); if(block instanceof BlockAir) block = null; meta = pkt.func_148857_g().getInteger("meta"); } worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); }
@Override public void registerBlocks() { SubBlockRF ra = registerBlock(new SubBlockRF("RAtoRF", this, true)); SubBlockRF rf = registerBlock(new SubBlockRF("RFtoRA", this, false)); Block block = (Block) Block.blockRegistry.getObject("ThermalExpansion:Cell"); if(block == null && block instanceof BlockAir) block = Blocks.redstone_block; GameRegistry.addRecipe(new ShapedOreRecipe(rf.getItemStack(), new Object[] { "IBI", "IRI", "IAI", Character.valueOf('I'), "ingotIron", Character.valueOf('R'), Blocks.redstone_block, Character.valueOf('A'), SubSystemBattery.instance.getBattery(2), Character.valueOf('B'), new ItemStack(block, 1, 1) })); GameRegistry.addRecipe(new ShapedOreRecipe(ra.getItemStack(), new Object[] { "IAI", "IRI", "IBI", Character.valueOf('I'), "ingotIron", Character.valueOf('R'), Blocks.redstone_block, Character.valueOf('A'), SubSystemBattery.instance.getBattery(2), Character.valueOf('B'), new ItemStack(block, 1, 1) })); }
public ItemBlockPneumaticCraft(Block block) { super(block); if (block instanceof BlockPneumaticCraft) { this.block = (BlockPneumaticCraft) block; } else { if (!(block instanceof BlockAir) && !(block instanceof BlockFluidBase)) { Log.warning("Block " + block.getUnlocalizedName() + " does not extend BlockPneumaticCraft! No tooltip displayed"); } } }
public static boolean isOnLiquid() { AxisAlignedBB par1AxisAlignedBB = Minecraft.getMinecraft().thePlayer.boundingBox.offset(0.0, -0.01, 0.0).contract(0.001, 0.001, 0.001); int var4 = MathHelper.floor_double((double)par1AxisAlignedBB.minX); int var5 = MathHelper.floor_double((double)(par1AxisAlignedBB.maxX + 1.0)); int var6 = MathHelper.floor_double((double)par1AxisAlignedBB.minY); int var7 = MathHelper.floor_double((double)(par1AxisAlignedBB.maxY + 1.0)); int var8 = MathHelper.floor_double((double)par1AxisAlignedBB.minZ); int var9 = MathHelper.floor_double((double)(par1AxisAlignedBB.maxZ + 1.0)); Vec3 var11 = new Vec3(0.0, 0.0, 0.0); int var12 = var4; while (var12 < var5) { int var13 = var6; while (var13 < var7) { int var14 = var8; while (var14 < var9) { Block var15 = Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(var12, var13, var14)).getBlock(); if (!(var15 instanceof BlockAir) && !(var15 instanceof BlockLiquid)) { return false; } ++var14; } ++var13; } ++var12; } return true; }
/** * Attempts to parse the block type string. * @param s The string to parse. * @return The block type, or null if the string is not recognised. */ public static IBlockState ParseBlockType( String s ) { if( s == null ) return null; Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation( s )); if( block instanceof BlockAir && !s.equals("air") ) // Minecraft returns BlockAir when it doesn't recognise the string return null; // unrecognised string return block.getDefaultState(); }
private void springEffect() { BlockPos pos = this.getPosition(); IBlockState state = this.world.getBlockState(pos.down()); if (!(state.getBlock() instanceof BlockAir)) { try { SoundType soundType = state.getBlock().getSoundType(state, this.world, pos, this); this.playSound(soundType.getStepSound(), soundType.getVolume(), soundType.getPitch()); } catch(Exception ex) { } for (int q = 0; q < 48; q++) { double pft = (this.rand.nextFloat() - 0.5F) * 0.75F; double qft = (this.rand.nextFloat() - 0.5F) * 0.75F; this.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX + pft, this.posY + 0.5D, this.posZ + qft, 0.0D, 0.25D, 0.0D, new int[] { Block.getStateId(state) }); // EntityDiggingFX gordon = new EntityDiggingFX(world, posX + pft, posY + 0.5D, posZ + qft, 0.0D, 0.25D, 0.0D, Block.blocksList[x], 0, y); // gordon.motionY += 0.15D + (rand.nextFloat() * 0.1D); // ModLoader.getMinecraftInstance().effectRenderer.addEffect(gordon); } } }
public Smasher() { super("Smasher", 0xFCC6FF, ModuleCategory.WORLD); NukerEngine nukerEngine = new NukerEngine((pos, block) -> { boolean blockChecks = BlockHelper.canSeeBlock(pos.getX(), pos.getY(), pos.getZ()) && !(block instanceof BlockAir) && !(block instanceof BlockLiquid); return blockChecks && block.getBlockHardness(mc.theWorld, pos) == 0; }); listeners.addAll(nukerEngine.getListeners()); }
private BlockPos[] getFloor() { Set<BlockPos> positions = new HashSet<>(); int highestY = -1; for (double d = 0; d <= mc.thePlayer.posY; d += 0.5) { for (int x = MathHelper.floor_double(mc.thePlayer.getEntityBoundingBox().minX - 0.5); x < MathHelper .floor_double(mc.thePlayer.getEntityBoundingBox().maxX + 0.5) + 1; x++) { for (int z = MathHelper.floor_double(mc.thePlayer.getEntityBoundingBox().minZ - 0.5); z < MathHelper .floor_double(mc.thePlayer.getEntityBoundingBox().maxZ + 0.5) + 1; z++) { BlockPos pos = new BlockPos(x, mc.thePlayer.posY - d, z); IBlockState state = mc.theWorld.getBlockState(pos); Block block = state.getBlock(); List<AxisAlignedBB> boundingBoxes = new ArrayList<>(); state.getBlock().addCollisionBoxesToList(mc.theWorld, pos, state, INFINITY_BB, boundingBoxes, mc.thePlayer); if (!boundingBoxes.isEmpty() && !(block instanceof BlockLiquid) && !(block instanceof BlockAir)) { if (pos.getY() == highestY) { positions.add(pos); } if (pos.getY() > highestY) { positions.clear(); highestY = pos.getY(); } } } } } return positions.toArray(new BlockPos[positions.size()]); }
public int getFindSealChecks() { if (!this.active || this.storedOxygen < this.oxygenPerTick || !this.hasEnoughEnergyToRun) { return 0; } Block blockAbove = this.worldObj.getBlock(this.xCoord, this.yCoord + 1, this.zCoord); if (!(blockAbove instanceof BlockAir) && !OxygenPressureProtocol.canBlockPassAir(this.worldObj, blockAbove, new BlockVec3(this.xCoord, this.yCoord + 1, this.zCoord), 1)) { // The vent is blocked return 0; } return 1250; }
/** * Attempts to parse the block type string. * @param s The string to parse. * @return The block type, or null if the string is not recognised. */ public static IBlockState ParseBlockType( String s ) { if( s == null ) return null; Block block = (Block)Block.REGISTRY.getObject(new ResourceLocation( s )); if( block instanceof BlockAir && !s.equals("air") ) // Minecraft returns BlockAir when it doesn't recognise the string return null; // unrecognised string return block.getDefaultState(); }
@SuppressWarnings("unused") private int getLadderHeight(Entity e, int offset) { int ladders = 0; for(int i = (int) e.posY; i < 256; i++){ Block var1 = mc.theWorld.getBlockState(new BlockPos(e.posX, i + offset, e.posZ)).getBlock(); if(var1 instanceof BlockAir){ break; }else if(var1 instanceof BlockLadder || var1 instanceof BlockVine){ ladders++; } return ladders; } return -1; }
@Override public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { Block block = accessor.getBlock(); if (config.getConfig("general.showcrop")) { if (block instanceof BlockDoubleCrop) { World world = accessor.getWorld(); BlockPos pos = accessor.getPosition(); IBlockState stateUp = world.getBlockState(pos.up()); IBlockState stateDown = world.getBlockState(pos.down()); float growthValue = (accessor.getMetadata() / 14.0F) * 100.0F; if (growthValue < 100.0 && accessor.getMetadata() != 7 && accessor.getMetadata() != 6) { currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue)); } else if (growthValue < 100.0 && accessor.getMetadata() == 6 && stateUp.getBlock() instanceof BlockAir) { currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue)); } else if (accessor.getMetadata() == 7 || accessor.getMetadata() == 14) { currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature"))); } if (stateUp.getBlock() instanceof BlockDoubleCrop && stateDown.getBlock() instanceof BlockFarmland) { float growthValueTop = (block.getMetaFromState(stateUp) / 14.0F) * 100.0F; if (growthValueTop < 100.0 && accessor.getMetadata() == 6) { currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValueTop)); } } } } if (block instanceof BlockModCauldron) { if (accessor.getMetadata() == 12) { currenttip.add("Cheese ripening in progress"); } } return currenttip; }
/** * * @param world * @param x start x * @param y * @param z * @param maxLength how far to look max * @param isAir if true, counts air blocks, if false, counts the NOT airblocks * @return */ protected int getCountInNegXDirection(IChunkProvider world, int x, int y, int z, int maxLength, boolean isAir) { int count = 0; for(int i=0; i<maxLength;i++) { if((worldObj.getBlock(x - i - 1, y, z) instanceof BlockAir) == isAir) { count++; } else { break; } } return count; }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f, int i) { TileEntity_IronFence tile = (TileEntity_IronFence) t; if (!tile.isInvalid()) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y, z + 0.5); bindTexture(texture); Block right = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(1,0,0))).getBlock(); Block left = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(-1,0,0))).getBlock(); Block front = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,1))).getBlock(); Block back = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,-1))).getBlock(); if(front instanceof Block_IronFence||!(front instanceof BlockAir)){ model.renderPart("front"); } if(back instanceof Block_IronFence||!(back instanceof BlockAir)){ model.renderPart("back"); } if(left instanceof Block_IronFence||!(left instanceof BlockAir)){ model.renderPart("left"); } if(right instanceof Block_IronFence||!(right instanceof BlockAir)){ model.renderPart("right"); } model.renderPart("post"); GL11.glPopMatrix(); } }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f, int i) { TileEntity_IronFence tile = (TileEntity_IronFence) t; if (!tile.isInvalid()) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y, z + 0.5); Block right = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(1,0,0))).getBlock(); Block left = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(-1,0,0))).getBlock(); Block front = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,1))).getBlock(); Block back = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,-1))).getBlock(); if(front instanceof Block_IronFence||!(front instanceof BlockAir)){ bindTexture(new ResourceLocation("reallifemod:textures/models/block/texture_Iron.png")); } if(back instanceof Block_IronFence||!(back instanceof BlockAir)){ model.renderPart("back"); } if(left instanceof Block_IronFence||!(left instanceof BlockAir)){ model.renderPart("left"); } if(right instanceof Block_IronFence||!(right instanceof BlockAir)){ model.renderPart("right"); } model.renderPart("post"); GL11.glPopMatrix(); } }
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { RLMPlayerProps props = RLMPlayerProps.get(player); if (world.getTileEntity(pos) instanceof TileEntity_Electric) { TileEntity_Electric toConnectTile = (TileEntity_Electric) world.getTileEntity(pos); if (props.lastTile != null && props.lastTile != toConnectTile) { props.lastTile.connectTo(toConnectTile); world.markBlockForUpdate(toConnectTile.getPos()); props.lastTile = toConnectTile; } else { player.addChatMessage(new ChatComponentText("Now in " + EnumChatFormatting.GREEN + "Connection Mode" + EnumChatFormatting.RESET + "To stop connecting, hold SHIFT+RIGHTCLICK! ")); props.lastTile = toConnectTile; } } else { if (world.getBlockState(pos).getBlock() instanceof BlockAir) { player.addChatMessage(new ChatComponentText("Stopped " + EnumChatFormatting.RED + "Connection Mode")); props.lastTile = null; } else { world.setBlockState(pos, RealLifeMod_Blocks.cable.getDefaultState()); } } return true; }
@Override public String toString(Object object) { ItemStack stack = (ItemStack) object; if(stack == null) return "null"; String item = ""; if(Block.getBlockFromItem(stack.getItem()) instanceof BlockAir) item = Item.itemRegistry.getNameForObject(stack.getItem()); else item = Block.blockRegistry.getNameForObject(Block.getBlockFromItem(stack.getItem())); if(stack.stackTagCompound == null) return StringUtils.ObjectsToString(item, stack.stackSize, stack.getItemDamage(), "null"); else return StringUtils.ObjectsToString(item, stack.stackSize, stack.getItemDamage(), stack.stackTagCompound); }
@Override public void renderTileEntityAt(TileEntityFlagPole tileentity, double d0, double d1, double d2, float f, int damage) { IBlockState banner = tileentity.getWorld().getBlockState(tileentity.getPos()); if (banner.getBlock() instanceof BlockAir) { return; } Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); int type = banner.getBlock().getMetaFromState(banner); int side = tileentity.getOrientation(); GlStateManager.pushMatrix(); GlStateManager.translate(d0, d1, d2); GlStateManager.color(1, 1, 1); float[] dims = new float[5]; for(int i=0; i<5; i++){ dims[i] = tileentity.getTextureDimensions(type, i); } switch (side){ case 0: renderYFlag(tileentity, d0, d1, d2, f, type); break; case 1: renderZFlag(tileentity, d0, d1, d2, f, type); break; case 2: GlStateManager.rotate(90, 0, 1, 0); GlStateManager.translate(-1, 0, 0); renderZFlag(tileentity, d0, d1, d2, f, type); break; } GlStateManager.popMatrix(); }
public ItemBlockPneumaticCraft(Block block){ super(block); if(block instanceof BlockPneumaticCraft) { this.block = (BlockPneumaticCraft)block; } else { if(!(block instanceof BlockPneumaticPlantBase) && !(block instanceof BlockAir) && !(block instanceof BlockFluidBase)) { Log.warning("Block " + block.getUnlocalizedName() + " does not extend BlockPneumaticCraft! No tooltip displayed"); } } }
@SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { IForgeRegistry<Item> registry = event.getRegistry(); registerItem(registry, new ItemGPSTool()); registerItem(registry, new ItemPneumatic("ingot_iron_compressed")); registerItem(registry, new ItemPneumatic("pressure_gauge")); registerItem(registry, new ItemPneumatic("stone_base")); registerItem(registry, new ItemPneumatic("cannon_barrel")); registerItem(registry, new ItemPneumatic("turbine_blade")); registerItem(registry, new ItemPlastic()); registerItem(registry, new ItemPressurizable("air_canister", PneumaticValues.AIR_CANISTER_MAX_AIR, PneumaticValues.AIR_CANISTER_VOLUME)); registerItem(registry, new ItemVortexCannon()); registerItem(registry, new ItemPneumatic("pneumatic_cylinder")); registerItem(registry, new ItemPneumaticArmor(ItemArmor.ArmorMaterial.IRON, PneumaticCraftRepressurized.proxy.getArmorRenderID(Textures.ARMOR_PNEUMATIC), EntityEquipmentSlot.HEAD, PneumaticValues.PNEUMATIC_HELMET_MAX_AIR)); registerItem(registry, new ItemManometer()); registerItem(registry, new ItemPneumatic("turbine_rotor")); registerItem(registry, new ItemAssemblyProgram()); registerItem(registry, new ItemEmptyPCB()); registerItem(registry, new ItemNonDespawning("unassembled_pcb")); registerItem(registry, new ItemPneumatic("pcb_blueprint")); registerItem(registry, new ItemPneumatic("transistor")); registerItem(registry, new ItemPneumatic("capacitor")); registerItem(registry, new ItemPneumatic("printed_circuit_board")); registerItem(registry, new ItemNonDespawning("failed_pcb")); registerItem(registry, new ItemNetworkComponents()); registerItem(registry, new ItemPneumatic("stop_worm")); registerItem(registry, new ItemPneumatic("nuke_virus")); registerItem(registry, new ItemPneumatic("compressed_iron_gear")); registerItem(registry, new ItemPneumaticWrench()); registerItem(registry, new ItemDrone()); registerItem(registry, new ItemProgrammingPuzzle()); registerItem(registry, new ItemPneumatic("advanced_pcb")); registerItem(registry, new ItemRemote()); registerItem(registry, new ItemSeismicSensor()); registerItem(registry, new ItemLogisticsConfigurator()); registerItem(registry, new ItemLogisticsDrone()); registerItem(registry, new ItemGunAmmo()); registerItem(registry, new ItemAmadronTablet()); registerItem(registry, new ItemMinigun()); registerItem(registry, new ItemCamoApplicator()); registerUpgrades(registry); for (Block b : Blockss.blocks) { if(!(b instanceof BlockAir)){ registerItem(registry, new ItemBlock(b).setRegistryName(b.getRegistryName())); } } }
public static boolean isBlockTransparent(World world, BlockPos pos, IBlockState state){ return state.getBlock() instanceof BlockAir || !state.getMaterial().isOpaque() || !state.isBlockNormalCube() || !state.isFullBlock() || !state.isOpaqueCube(); }
private void writeSchematic() { int minX = Math.min(first.getX(), second.getX()); int minY = Math.min(first.getY(), second.getY()); int minZ = Math.min(first.getZ(), second.getZ()); int maxX = Math.max(first.getX(), second.getX()); int maxY = Math.max(first.getY(), second.getY()); int maxZ = Math.max(first.getZ(), second.getZ()); int dx = maxX - minX -1; int dy = maxY - minY -1; int dz = maxZ - minZ -1; first = null; second = null; BlockPos start = new BlockPos(minX+1, minY+1, minZ+1); List<Schematic.BlockPosition> list = new ArrayList<>(); for(int x = 0; x < dx; x++) { for(int y = 0; y < dy ; y++) { for(int z = 0; z < dz ; z++) { BlockPos pos = start.add(x, y, z); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if(block == null || block instanceof BlockAir) { continue; } int worldMeta = block.getMetaFromState(state); int stackMeta = block.damageDropped(state); TileEntity tile = world.getTileEntity(pos); NBTTagCompound tag = null; if(tile != null) { tag = new NBTTagCompound(); tile.writeToNBT(tag); } Schematic.BlockPosition position = new Schematic.BlockPosition(x, y, z, Block.REGISTRY.getNameForObject(block).toString(), worldMeta, stackMeta, tag); if(needsSupportBlock(block)) { position.setNeedsSupportBlock(); } list.add(position.setRotationMetaTransforms(SchematicRotationTransformer.getInstance().getRotationData(block, worldMeta))); } } } try { serialize(list); } catch (IOException e) { e.printStackTrace(); } }
public static boolean isAirBlock(IBlockAccess world, BlockPos pos, EnumFacing facing, RelativeFacing dir) { BlockPos target = getBlockPosRelativeTo(world, pos, facing, dir); return world.getBlockState(target).getBlock() instanceof BlockAir; }
public boolean isBlock() { return !(getBlock() instanceof BlockAir); }
@Override public boolean isTerraformable(World world, int x, int y, int z) { return world.getBlockMetadata(x, y, z) == 0 && world.getBlock(x, y + 1, z) instanceof BlockAir; }