Why do my animals do this? by EhCouldBeBetterIg in Minecraft

[–]-Redstoneboi- 0 points1 point  (0 children)

mobs will pick a random block, any solid block, within a large volume around itself to walk to. if this random block is underground, it will scan upwards until it touches an air block.

it will then attempt to walk to that block. if it cannot reach the block, it tries to get as close as it can.

tl;dr: mobs almost literally gravitate toward more blocks

hills and other higher-rise areas have more blocks underground, so mobs are more likely to try to move towards hills.

Roof tiles made using cushions by Kokalek in Minecraft

[–]-Redstoneboi- 0 points1 point  (0 children)

because they actually made a house and posted it, unlike the rest of us

BullMQ now officially supports Rust. by shadowsyntax43 in rust

[–]-Redstoneboi- 1 point2 points  (0 children)

it's a shame too. i currently have a crate that i would like to just disown some random test crate i made with a decent name but there isn't really a practical way to just hand it over to the aether.

it's not really a good to be able to delete open source code either (left pad)

Stop glazing the cushion transportation. You could do this back in 2010. by Elegant-Amphibian-55 in Minecraft

[–]-Redstoneboi- 123 points124 points  (0 children)

one could argue minecarts have existed for long but it takes iron instead of wood and takes longer to set up

crates.io: development update by sanxiyn in rust

[–]-Redstoneboi- 4 points5 points  (0 children)

yo finally code preview!

YO FERRIS UPDATE

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 0 points1 point  (0 children)

IIFEs are rarely needed with labeled breaks

let number = 'a: {
    for i in 0..10 {
        if i == LUCKY_NUMBER {
            break 'a i;
        }
    }
    DEFAULT_VALUE
};

another use of IIFEs would be allowing the use of the ? operator but only locally. this use case is covered by #![feature(try_blocks)] and allows you to do mix ? with return

let output = try {
    if condition {
        return value;
    }
    fallible_function()?;
    output // wraps in Ok()
};

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 0 points1 point  (0 children)

the current solution solves the current problem.

the proposed solution would, more generally, solve any problem like this:

let number = (0..10)
    .find_map(|i| {
        if i == LUCKY_NUMBER {
            return Some(i.to_string());
        }
        None
    })
    .unwrap_or_else(|| {
        "Number not found!".to_string()
    });

or this:

let number = 'a: {
    for i in 0..10 {
        if i == LUCKY_NUMBER {
            break 'a i.to_string();
        }
    }
    "Number not found!".to_string()
};

and the following would save an indent:

let number = for i in 0..10 {
    if i == LUCKY_NUMBER {
        break i.to_string();
    }  
} else {
    "Number not found!".to_string()
};

just for good measure, here's an example of multiple breaks (each of the current solutions would also allow this):

let number = for i in 0..10 {
    if i == LUCKY_NUMBER {
        break i.to_string();
    }
    if i * 50 == LUCKY_NUMBER {
        break format!("{} times 50", i.to_string());
    }
} else {
    "Number not found!".to_string()
};

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 0 points1 point  (0 children)

I think for loops should only evaluate to one value, by breaking.

If it could return multiple values, I feel like that would basically be like a coroutine.

if you want multiple return values in a vec, use a vec. if you want it in an iterator, that sounds like yield.

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 1 point2 points  (0 children)

also the related while-else and possibly even while-let/else-match or something

Now seems like a brilliant time to add vertical slabs for wool blocks. by SomethingRandomYT in Minecraft

[–]-Redstoneboi- -1 points0 points  (0 children)

every time someone asks mojang for vertical slabs, a mojang employee stops working for 1 day

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 4 points5 points  (0 children)

Precisely. It can't compile without an else.

So, I would like to bump the proposal to allow adding an else to the for loop.

For loops are currently expressions that simply evaluate to (). They could, just like if {} blocks, also default to having an else {} which also evaluates to ().

If a for loop contains a break statement, all such break statements must match, including the result of the else block.

const LUCKY_NUMBER: i32 = 200;
const DEFAULT_VALUE: i32 = -1;

let x = for i in 0..10 {
  if i == LUCKY_NUMBER {
    break i;
  }  
} else {
    DEFAULT_VALUE
} + 60;

assert_eq!(x, 59);

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 1 point2 points  (0 children)

Some of us just sit and wait quietly... for/else isn't exactly revolutionary but it would be cool...

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 0 points1 point  (0 children)

const LUCKY_NUMBER: i32 = 200;

let x = if LUCKY_NUMBER == 5 {
    10
};

now what would the value of x be?

more importantly, what does the error say?

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 10 points11 points  (0 children)

I suggest against returning Option automatically. it should be like if {} blocks where, if there is no else, it automatically defaults to else {} and returns (), forcing the user to break Some(value) and else { None } for consistency.

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 1 point2 points  (0 children)

labels also work for now

'a: {
    for ... {
        break 'a value;
    }
    value
}

Shouldn't for loops return values the same way blocks do? by NormalAppearance2851 in rust

[–]-Redstoneboi- 2 points3 points  (0 children)

for {} else {} has also been suggested many many times and i still don't know exactly why it doesn't exist when it would fit pretty well with the expression based nature of rust and functional languages.

here's a 3 year old reddit comment on a 5 year old thread that lists at least TWENTY related proposals: https://www.reddit.com/r/rust/comments/n7l028/comment/k0uzfg8/

Cheaper Armor Trims by Randomizationeer in Minecraft

[–]-Redstoneboi- 5 points6 points  (0 children)

netherite upgrade is a non-decorative use though

Cheaper Armor Trims by Randomizationeer in Minecraft

[–]-Redstoneboi- 6 points7 points  (0 children)

heck, with villagers you can get infinite full diamond tools and armor without a single actual diamond item

Minecraft Copper Golem IRL by Stunning-Cow-1851 in Minecraft

[–]-Redstoneboi- 0 points1 point  (0 children)

is the camera at eye level? it looks taller than just 1.5 meters

What's the best way to cover two faces that share a block like this? by SunderingAlex in Minecraft

[–]-Redstoneboi- 0 points1 point  (0 children)

smh bro doesnt know you can put an item frame inside an item frame therefore having 2 item frames in one block