Java Code Examples for net.minecraft.block.Blocks#AIR

The following examples show how to use net.minecraft.block.Blocks#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: FlowerPotBlockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject(method = "onUse", at = @At("HEAD"))
private void onActivate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1, CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetExtraSettings.flowerPotChunkLoading && world_1.getServer() != null && !world_1.isClient)
    {
        ItemStack stack = playerEntity_1.getStackInHand(hand_1);
        Item item = stack.getItem();
        Block block = item instanceof BlockItem ? (Block) CONTENT_TO_POTTED.getOrDefault(((BlockItem) item).getBlock(), Blocks.AIR) : Blocks.AIR;
        boolean boolean_1 = block == Blocks.AIR;
        boolean boolean_2 = this.content == Blocks.AIR;
        ServerWorld serverWorld = world_1.getServer().getWorld(world_1.getDimension().getType());

        if (boolean_1 != boolean_2 && (block == Blocks.POTTED_WITHER_ROSE || this.content == Blocks.WITHER_ROSE))
        {
            // System.out.println("Chunk load status = " + boolean_2);
            serverWorld.setChunkForced(blockPos_1.getX() >> 4, blockPos_1.getZ() >> 4, boolean_2);
        }
    }
}
 
Example 2
Source File: Nofall.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 0) {
		if (mc.player.isFallFlying()) return;
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(true));
	}
	
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 1 &&
			mc.world.getBlockState(mc.player.getBlockPos().add(
					0,-1.5+(mc.player.getVelocity().y*0.1),0)).getBlock() != Blocks.AIR) {
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(false));
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionOnly(
				mc.player.x, mc.player.y - 420.69, mc.player.z, true));
		mc.player.fallDistance = 0;
	}
}
 
Example 3
Source File: Nofall.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public void onUpdate() {
	if (this.isToggled()) {
		if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 0) {
			mc.player.connection.sendPacket(new CPlayerPacket(true));
		}
		
		if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 1 &&
				mc.world.getBlockState(mc.player.getPosition().add(
						0,-1.5+(mc.player.getMotion().y*0.1),0)).getBlock() != Blocks.AIR) {
			mc.player.connection.sendPacket(new CPlayerPacket(false));
			mc.player.connection.sendPacket(new CPlayerPacket.PositionPacket(
					mc.player.posX, mc.player.posY - 420.69, mc.player.posZ, true));
			mc.player.fallDistance = 0;
		}
	}
}
 
Example 4
Source File: PistonBlockEntity_movableTEMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@Inject(method = "finish", at = @At(value = "RETURN"))
private void finishHandleBroken(CallbackInfo cir)
{
    //Handle TNT Explosions or other ways the moving Block is broken
    //Also /setblock will cause this to be called, and drop e.g. a moving chest's contents.
    // This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
    if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
    {
        BlockState blockState_2;
        if (this.source)
            blockState_2 = Blocks.AIR.getDefaultState();
        else
            blockState_2 = Block.getRenderingState(this.pushedBlock, this.world, this.pos);
        ((WorldInterface) (this.world)).setBlockStateWithBlockEntity(this.pos, blockState_2, this.carriedBlockEntity, 3);
        this.world.breakBlock(this.pos, false, null);
    }
}
 
Example 5
Source File: GameBlockStore.java    From XRay-Mod with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method is used to fill the store as we do not intend to update this after
 * it has been populated, it's a singleton by nature but we still need some
 * amount of control over when it is populated.
 */
public void populate()
{
    // Avoid doing the logic again unless repopulate is called
    if( this.store.size() != 0 )
        return;

    for ( Item item : ForgeRegistries.ITEMS ) {
        if( !(item instanceof net.minecraft.item.BlockItem) )
            continue;

        Block block = Block.getBlockFromItem(item);
        if ( item == Items.AIR || block == Blocks.AIR || Controller.blackList.contains(block) )
            continue; // avoids troubles

        store.add(new BlockWithItemStack(block, new ItemStack(item)));
    }
}
 
Example 6
Source File: MixinFlowerPotBlock.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
private void cancelEmptyingFlowerPot(CallbackInfoReturnable<ActionResult> ci) {
    // TODO: this doesn't fully work, WTF?!
    if (ConnectionInfo.protocolVersion <= Protocols.V1_10 && content != Blocks.AIR) {
        ci.setReturnValue(ActionResult.CONSUME);
    }
}
 
Example 7
Source File: Notebot.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public boolean isNoteblock(BlockPos pos) {
	/* Checks if this block is a noteblock and the noteblock can be played */
	if (mc.world.getBlockState(pos).getBlock() instanceof NoteBlock) {
           return mc.world.getBlockState(pos.up()).getBlock() == Blocks.AIR;
	}
	return false;
}
 
Example 8
Source File: Notebot.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public boolean isNoteblock(BlockPos pos) {
	/* Checks if this block is a noteblock and the noteblock can be played */
	if (mc.world.getBlockState(pos).getBlock() instanceof NoteBlock) {
           return mc.world.getBlockState(pos.up()).getBlock() == Blocks.AIR;
	}
	return false;
}
 
Example 9
Source File: Notebot.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public boolean isNoteblock(BlockPos pos) {
	/* Checks if this block is a noteblock and the noteblock can be played */
	if (mc.world.getBlockState(pos).getBlock() instanceof NoteBlock) {
           return mc.world.getBlockState(pos.up()).getBlock() == Blocks.AIR;
	}
	return false;
}
 
Example 10
Source File: BlockParty.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	Item item = mc.player.inventory.getMainHandStack().getItem();
	Block block = Block.getBlockFromItem(item);
	if (block == Blocks.AIR) return;
	
	if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block
			|| mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) {
		mc.player.setVelocity(0, mc.player.getVelocity().y, 0);
		KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false);
		return;
	}
	
	List<BlockPos> poses = new ArrayList<>();
	for (int x = -50; x < 50; x++) {
		for (int y = -2; y < 1; y++) {
			for (int z = -50; z < 50; z++) {
				if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block
						&& mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z));
			}
		}
	}
	
	if (poses.isEmpty()) return;
	
	poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos())));
	
	double diffX = poses.get(0).getX() + 0.5 - mc.player.x;
	double diffZ = poses.get(0).getZ() + 0.5 - mc.player.z;
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	
	KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true);
	
	if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8)
			&& Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15
			&& mc.player.verticalCollision) {
		mc.player.jump();
		mc.player.verticalCollision = false;
		//mc.player.setPosition(mc.player.x, mc.player.y + 0.02, mc.player.z);
	}
	
	if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) {
		if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) {
			mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
			mc.player.y = mc.player.prevY;
			jumping = false;
		}
		
		if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
			if (mc.player.verticalCollision) {
				mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300),
						mc.player.getVelocity().y,
						mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300));
				jumping = true;
				mc.player.jump();
			}
			
			if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) {
				mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
				jumping = false;
			}
		}
	}
}
 
Example 11
Source File: EntitySpeed.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void onUpdate() {
	if (this.isToggled()) {
		if (mc.player.getRidingEntity() == null) return;
		
		Entity e = mc.player.getRidingEntity();
		double speed = getSettings().get(0).toSlider().getValue();
		
		if (e instanceof LlamaEntity) {
			e.rotationYaw = mc.player.rotationYaw;
			((LlamaEntity) e).rotationYawHead = mc.player.rotationYawHead;
		}
		MovementInput movementInput = mc.player.movementInput;
		double forward = movementInput.moveForward;
		double strafe = movementInput.moveStrafe;
		float yaw = mc.player.rotationYaw;
		if ((forward == 0.0D) && (strafe == 0.0D)) {
			e.setMotion(0, e.getMotion().y, 0);
		} else {
			if (forward != 0.0D) {
				if (strafe > 0.0D) { yaw += (forward > 0.0D ? -45 : 45);
				} else if (strafe < 0.0D) yaw += (forward > 0.0D ? 45 : -45);
				strafe = 0.0D;
				if (forward > 0.0D) { forward = 1.0D;
				} else if (forward < 0.0D) forward = -1.0D;
			}
			e.setMotion((forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F))), e.getMotion().y,
					forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F)));
			if (e instanceof MinecartEntity) {
				MinecartEntity em = (MinecartEntity) e;
				em.setVelocity((forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F))), em.getMotion().y, (forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F))));
			}
			
			if (getSettings().get(1).toToggle().state) if (mc.gameSettings.keyBindJump.isKeyDown()) e.setMotion(e.getMotion().x, 0.3, e.getMotion().z);
			
			if (getSettings().get(2).toToggle().state) {
				BlockPos p = e.getPosition().add(0, 0.5, 0);
				if (mc.world.getBlockState(p.down()).getBlock() == Blocks.AIR &&
					mc.world.getBlockState(p.down(2)).getBlock() != Blocks.AIR &&
					!(mc.world.getBlockState(p.down(2)).getMaterial() == Material.WATER) &&
					e.fallDistance > 0.01) e.setMotion(e.getMotion().x, -1, e.getMotion().z);
			}
		}
	}
}
 
Example 12
Source File: BlockParty.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	Item item = mc.player.inventory.getMainHandStack().getItem();
	Block block = Block.getBlockFromItem(item);
	if (block == Blocks.AIR) return;
	
	if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block
			|| mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) {
		mc.player.setVelocity(0, mc.player.getVelocity().y, 0);
		KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKey(), false);
		return;
	}
	
	List<BlockPos> poses = new ArrayList<>();
	for (int x = -50; x < 50; x++) {
		for (int y = -2; y < 1; y++) {
			for (int z = -50; z < 50; z++) {
				if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block
						&& mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z));
			}
		}
	}
	
	if (poses.isEmpty()) return;
	
	poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos())));
	
	double diffX = poses.get(0).getX() + 0.5 - mc.player.getX();
	double diffZ = poses.get(0).getZ() + 0.5 - mc.player.getZ();
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	
	KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKey(), true);
	
	if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8)
			&& Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15
			&& mc.player.verticalCollision) {
		mc.player.jump();
		mc.player.verticalCollision = false;
		//mc.player.setPosition(mc.player.getX(), mc.player.y + 0.02, mc.player.getZ());
	}
	
	if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) {
		if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
			mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
			mc.player.setPos(mc.player.getX(), mc.player.prevY, mc.player.getZ());
			jumping = false;
		}
		
		if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
			if (mc.player.verticalCollision) {
				mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300),
						mc.player.getVelocity().y,
						mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300));
				jumping = true;
				mc.player.jump();
			}
			
			if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
				mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
				jumping = false;
			}
		}
	}
}
 
Example 13
Source File: BlockParty.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	Item item = mc.player.inventory.getMainHandStack().getItem();
	Block block = Block.getBlockFromItem(item);
	if (block == Blocks.AIR) return;
	
	if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block
			|| mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) {
		mc.player.setVelocity(0, mc.player.getVelocity().y, 0);
		KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false);
		return;
	}
	
	List<BlockPos> poses = new ArrayList<>();
	for (int x = -50; x < 50; x++) {
		for (int y = -2; y < 1; y++) {
			for (int z = -50; z < 50; z++) {
				if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block
						&& mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z));
			}
		}
	}
	
	if (poses.isEmpty()) return;
	
	poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos())));
	
	double diffX = poses.get(0).getX() + 0.5 - mc.player.getX();
	double diffZ = poses.get(0).getZ() + 0.5 - mc.player.getZ();
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	
	KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true);
	
	if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8)
			&& Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15
			&& mc.player.verticalCollision) {
		mc.player.jump();
		mc.player.verticalCollision = false;
		//mc.player.setPosition(mc.player.getX(), mc.player.y + 0.02, mc.player.getZ());
	}
	
	if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) {
		if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
			mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
			mc.player.setPos(mc.player.getX(), mc.player.prevY, mc.player.getZ());
			jumping = false;
		}
		
		if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
			if (mc.player.verticalCollision) {
				mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300),
						mc.player.getVelocity().y,
						mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300));
				jumping = true;
				mc.player.jump();
			}
			
			if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
				mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
				jumping = false;
			}
		}
	}
}
 
Example 14
Source File: Nofall.java    From bleachhack-1.14 with GNU General Public License v3.0 1 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 0) {
		if (mc.player.isFallFlying()) return;
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(true));
	}
	
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 1 &&
			mc.world.getBlockState(mc.player.getBlockPos().add(
					0,-1.5+(mc.player.getVelocity().y*0.1),0)).getBlock() != Blocks.AIR) {
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(false));
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionOnly(
				mc.player.getX(), mc.player.getY() - 420.69, mc.player.getZ(), true));
		mc.player.fallDistance = 0;
	}
}
 
Example 15
Source File: Nofall.java    From bleachhack-1.14 with GNU General Public License v3.0 -2 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 0) {
		if (mc.player.isFallFlying()) return;
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(true));
	}
	
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 1 &&
			mc.world.getBlockState(mc.player.getBlockPos().add(
					0,-1.5+(mc.player.getVelocity().y*0.1),0)).getBlock() != Blocks.AIR) {
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(false));
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionOnly(
				mc.player.getX(), mc.player.getY() - 420.69, mc.player.getZ(), true));
		mc.player.fallDistance = 0;
	}
}