#i wanna show my code to u but

1 messages · Page 1 of 1 (latest)

fleet sorrel
dusk pebble
#

You need 3 for loops

fleet sorrel
#

u mean getX getY

#

?

dusk pebble
#

no

fleet sorrel
#

first i need loop snapshot blocsk after... ?

dusk pebble
#
for (int x = 0; x <= 15; x++) {
  for (int z = 0; z <= 15; z++) {
    for (int y = chunk.getHighestBlockYAt(x,z); y > world.getMinHeight(); y--) {```
fleet sorrel
#

;-;

#

ty

fleet sorrel
dusk pebble
#

thats from teh chunkSnapshot

fleet sorrel
#

yes but which one i need do and why ?

dusk pebble
#

your current code is currently all in the chunk load event so you are not using the snapshot

#

you need it in an async task so you can loop over the snapshot without causing lag

fleet sorrel
#
    @EventHandler
    public void loadChunk(ChunkLoadEvent e) {
        ChunkSnapshot chunk = e.getChunk().getChunkSnapshot();
        World world = e.getChunk().getWorld();
        for (int x = 0; x <= 15; x++) {
            for (int z = 0; z <= 15; z++) {
                for (int y = chunk.getHighestBlockYAt(x,z); y > world.getMinHeight(); y--) {
                    Block block = e.getChunk().getBlock(x,y,z);
                    if (block.getType() == Material.WHEAT) {
                        block.setType(Material.DIAMOND_BLOCK);
                    }
                }
            }
        }
    }``` i did this
dusk pebble
#

that will work

fleet sorrel
#

but u say i need do async

mental copper
#

pretty sure I have a util class for this

dusk pebble
#

yes

#

run it and walk around to a few wheat fields and you will see lag

fleet sorrel
#

so i need getblocktype and locations set blocks from locations

mental copper
fleet sorrel
#

or if i only setBlockType that will work ?

fleet sorrel
dusk pebble
fleet sorrel
#

yes 😄

fleet sorrel
dusk pebble
#

a few months of coding plugins, IF you learn

mental copper
#

I made that like

#

a year ago

fleet sorrel
dusk pebble
#

you'd best not

#

your current level is understanding for loops

mental copper
#

yeah p much

dusk pebble
#

You are about to start on sync/async

mental copper
#

well

#

I'd recommend lambdas first

#

You understand interfaces?

dusk pebble
#

nah, lambdas will confuse him as he'll miss the underlying code

fleet sorrel
mental copper
fleet sorrel
#

this help me how to convert async blocks to sync ?

mental copper
#

lambdas are used to like

#

specify a task that's passed around between the threads

#

concurrency is a bit finnicky to learn

#

but think of it like this

dusk pebble
#

its simple with spigot

mental copper
#
  • You have a really good developer that has a ton of work to do
  • That developer then decides to hire other developers to do the work for him
  • Those other developers talk between each other and finish the task
dusk pebble
#

that task system allows you to easily jump between sync and async

mental copper
#

But there are some complications

#

Like making sure that all the developers are aware of what each other are doing, what stage everyone is at

#

Because you don't want 2 people to focus on the same tasks

#

Now replace developers with threads

#

So you have 2 lines of work crunching tasks

#

if you put them both crunching the same task, each one will just do it by themselves not really working together

#

So you want to split a big task into tons of tiny ones and hand them individually to make sure 2 threads aren't working on the same thing

fleet sorrel
#

i will learn and understand lambdas

#

this day

dusk pebble
#

I suggest you go slower

mental copper
#

yeah that's a good move

#

it took me multiple years to get to this stage, don't expect to be at my level tomorrow

fleet sorrel
#

can i do this code
shorter?

mental copper
#

do you notice something?

fleet sorrel
#

i mean i do too thing at this code if i use lambdas

mental copper
#

These are the same

#

You don't need lambdsa here

fleet sorrel
#

i will add those things here
and i will combine

mental copper
#

also your moisture level

#

is the number on your switch statement

#

+2

#

and your offhand logic is the same exact thing but you swing the offhand instead

fleet sorrel
#

idu can i delete features in next case ?

mental copper
#

elaborate

fleet sorrel
#

can u explain me more detailed?

mental copper
#

basically

#

look at your code

#

find duplicates

#

and change your code

#

so you don't have duplicate statements