Java Code Examples for net.minecraft.block.Material#AIR
The following examples show how to use
net.minecraft.block.Material#AIR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NukerLegitHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void onLeftClick(LeftClickEvent event) { // check hitResult if(MC.crosshairTarget == null || !(MC.crosshairTarget instanceof BlockHitResult)) return; // check pos BlockPos pos = ((BlockHitResult)MC.crosshairTarget).getBlockPos(); if(pos == null || BlockUtils.getState(pos).getMaterial() == Material.AIR) return; // check mode if(mode.getSelected() != Mode.ID) return; // set id WURST.getHax().nukerHack.setId(BlockUtils.getName(pos)); }
Example 2
Source File: SpeedNukerHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void onLeftClick(LeftClickEvent event) { // check hitResult if(MC.crosshairTarget == null || !(MC.crosshairTarget instanceof BlockHitResult)) return; // check pos BlockPos pos = ((BlockHitResult)MC.crosshairTarget).getBlockPos(); if(pos == null || BlockUtils.getState(pos).getMaterial() == Material.AIR) return; // check mode if(mode.getSelected() != Mode.ID) return; // set id WURST.getHax().nukerHack.setId(BlockUtils.getName(pos)); }
Example 3
Source File: JesusHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
public boolean isOverLiquid() { boolean foundLiquid = false; boolean foundSolid = false; // check collision boxes below player ArrayList<Box> blockCollisions = MC.world .getBlockCollisions(MC.player, MC.player.getBoundingBox().offset(0, -0.5, 0)) .map(VoxelShape::getBoundingBox) .collect(Collectors.toCollection(() -> new ArrayList<>())); for(Box bb : blockCollisions) { BlockPos pos = new BlockPos(bb.getCenter()); Material material = BlockUtils.getState(pos).getMaterial(); if(material == Material.WATER || material == Material.LAVA) foundLiquid = true; else if(material != Material.AIR) foundSolid = true; } return foundLiquid && !foundSolid; }
Example 4
Source File: OptimizedExplosion.java From fabric-carpet with MIT License | 4 votes |
private static void rayCalcs(Explosion e) { ExplosionAccessor eAccess = (ExplosionAccessor) e; boolean first = true; for (int j = 0; j < 16; ++j) { for (int k = 0; k < 16; ++k) { for (int l = 0; l < 16; ++l) { if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) { double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F); double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F); double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F); double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d0 = d0 / d3; d1 = d1 / d3; d2 = d2 / d3; float rand = eAccess.getWorld().random.nextFloat(); if (CarpetSettings.tntRandomRange >= 0) { rand = (float) CarpetSettings.tntRandomRange; } float f = eAccess.getPower() * (0.7F + rand * 0.6F); double d4 = eAccess.getX(); double d6 = eAccess.getY(); double d8 = eAccess.getZ(); for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) { BlockPos blockpos = new BlockPos(d4, d6, d8); BlockState state = eAccess.getWorld().getBlockState(blockpos); FluidState fluidState = eAccess.getWorld().getFluidState(blockpos); if (state.getMaterial() != Material.AIR) { float f2 = Math.max(state.getBlock().getBlastResistance(), fluidState.getBlastResistance()); if (eAccess.getEntity() != null) f2 = eAccess.getEntity().getEffectiveExplosionResistance(e, eAccess.getWorld(), blockpos, state, fluidState, f2); f -= (f2 + 0.3F) * 0.3F; } if (f > 0.0F && (eAccess.getEntity() == null || eAccess.getEntity().canExplosionDestroyBlock(e, eAccess.getWorld(), blockpos, state, f))) { affectedBlockPositionsSet.add(blockpos); } else if (first) { return; } first = false; d4 += d0 * 0.30000001192092896D; d6 += d1 * 0.30000001192092896D; d8 += d2 * 0.30000001192092896D; } } } } } }
Example 5
Source File: OptimizedExplosion.java From fabric-carpet with MIT License | 4 votes |
private static boolean checkAffectedPosition(Explosion e, double xRel, double yRel, double zRel) { ExplosionAccessor eAccess = (ExplosionAccessor) e; double len = Math.sqrt(xRel * xRel + yRel * yRel + zRel * zRel); double xInc = (xRel / len) * 0.3; double yInc = (yRel / len) * 0.3; double zInc = (zRel / len) * 0.3; float rand = eAccess.getWorld().random.nextFloat(); float sizeRand = (CarpetSettings.tntRandomRange >= 0 ? (float) CarpetSettings.tntRandomRange : rand); float size = eAccess.getPower() * (0.7F + sizeRand * 0.6F); double posX = eAccess.getX(); double posY = eAccess.getY(); double posZ = eAccess.getZ(); for (float f1 = 0.3F; size > 0.0F; size -= 0.22500001F) { posMutable.set(posX, posY, posZ); // Don't query already cached positions again from the world BlockState state = stateCache.get(posMutable); FluidState fluid = fluidCache.get(posMutable); BlockPos posImmutable = null; if (state == null) { posImmutable = posMutable.toImmutable(); state = eAccess.getWorld().getBlockState(posImmutable); stateCache.put(posImmutable, state); fluid = eAccess.getWorld().getFluidState(posImmutable); fluidCache.put(posImmutable, fluid); } if (state.getMaterial() != Material.AIR) { float resistance = Math.max(state.getBlock().getBlastResistance(), fluid.getBlastResistance()); if (eAccess.getEntity() != null) { resistance = eAccess.getEntity().getEffectiveExplosionResistance(e, eAccess.getWorld(), posMutable, state, fluid, resistance); } size -= (resistance + 0.3F) * 0.3F; } if (size > 0.0F && (eAccess.getEntity() == null || eAccess.getEntity().canExplosionDestroyBlock(e, eAccess.getWorld(), posMutable, state, size))) { affectedBlockPositionsSet.add(posImmutable != null ? posImmutable : posMutable.toImmutable()); } else if (firstRay) { rayCalcDone = true; return true; } firstRay = false; posX += xInc; posY += yInc; posZ += zInc; } return false; }
Example 6
Source File: OptimizedExplosion.java From fabric-carpet with MIT License | 4 votes |
private static void blastCalc(Explosion e){ ExplosionAccessor eAccess = (ExplosionAccessor) e; if(blastChanceLocation == null || blastChanceLocation.getSquaredDistance(eAccess.getX(), eAccess.getY(), eAccess.getZ(), false) > 200) return; chances.clear(); for (int j = 0; j < 16; ++j) { for (int k = 0; k < 16; ++k) { for (int l = 0; l < 16; ++l) { if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) { double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F); double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F); double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F); double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d0 = d0 / d3; d1 = d1 / d3; d2 = d2 / d3; float f = eAccess.getPower() * (0.7F + 0.6F); double d4 = eAccess.getX(); double d6 = eAccess.getY(); double d8 = eAccess.getZ(); boolean found = false; for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) { BlockPos blockpos = new BlockPos(d4, d6, d8); BlockState state = eAccess.getWorld().getBlockState(blockpos); FluidState fluidState = eAccess.getWorld().getFluidState(blockpos); if (state.getMaterial() != Material.AIR) { float f2 = Math.max(state.getBlock().getBlastResistance(), fluidState.getBlastResistance()); if (eAccess.getEntity() != null) f2 = eAccess.getEntity().getEffectiveExplosionResistance(e, eAccess.getWorld(), blockpos, state, fluidState, f2); f -= (f2 + 0.3F) * 0.3F; } if (f > 0.0F && (eAccess.getEntity() == null || eAccess.getEntity().canExplosionDestroyBlock(e, eAccess.getWorld(), blockpos, state, f))) { if(!found && blockpos.equals(blastChanceLocation)){ chances.add(f); found = true; } } d4 += d0 * 0.30000001192092896D; d6 += d1 * 0.30000001192092896D; d8 += d2 * 0.30000001192092896D; } } } } } showTNTblastChance(e); }
Example 7
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 2 votes |
/** * Determines this block should be treated as an air block * by the rest of the code. This method is primarily * useful for creating pure logic-blocks that will be invisible * to the player and otherwise interact as air would. * * @param state The current state * @param world The current world * @param pos Block position in world * @return True if the block considered air */ default boolean isAir(BlockState state, BlockView world, BlockPos pos) { return state.getMaterial() == Material.AIR; }