net.minecraft.world.ModifiableWorld Java Examples

The following examples show how to use net.minecraft.world.ModifiableWorld. 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: StoneCircleFeature.java    From the-hallow with MIT License 6 votes vote down vote up
private void generateStone(ModifiableWorld world, Random rand, final BlockPos centre, BlockPos.Mutable mutable, int height, int lowY) {
	final int posX = centre.getX();
	final int posZ = centre.getZ();
	
	for (int xOffset = -3; xOffset < 4; ++xOffset) {
		mutable.setX(posX + xOffset);
		for (int zOffset = -3; zOffset < 4; ++zOffset) {
			mutable.setZ(posZ + zOffset);
			mutable.setY(0);
			
			double squaredDistanceTo = centre.getSquaredDistance(mutable) / 9D;
			
			int localHeight = (int) offsetNoise.sample(mutable.getX(), mutable.getZ()) + (int) MathHelper.lerp(squaredDistanceTo, height, 0D) + lowY;
			
			for (int y = lowY - 5; y < localHeight + 1; ++y) {
				mutable.setY(y);
				world.setBlockState(mutable, rand.nextInt(3) == 0 ? COBBLESTONE : STONE, 19);
			}
		}
	}
}
 
Example #2
Source File: IForgeBlock.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called when a user either starts or stops sleeping in the bed.
 *
 * @param state    The current state
 * @param world    The current world
 * @param pos      Block position in world
 * @param sleeper  The sleeper or camera entity, null in some cases.
 * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed
 */
default void setBedOccupied(BlockState state, CollisionView world, BlockPos pos, LivingEntity sleeper, boolean occupied) {
	if (world instanceof ModifiableWorld) {
		((ModifiableWorld) world).setBlockState(pos, state.with(BedBlock.OCCUPIED, occupied), 4);
	}
}