#i wanna show my code to u but
1 messages · Page 1 of 1 (latest)
You need 3 for loops
no
first i need loop snapshot blocsk after... ?
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--) {```
u was said use getBlockType ? why
can i get only with e.chunk.getBlock(x,y,z);
and check block type in if ?
thats from teh chunkSnapshot
yes but which one i need do and why ?
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
@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
that will work
but u say i need do async
pretty sure I have a util class for this
so i need getblocktype and locations set blocks from locations
or if i only setBlockType that will work ?
im chck
thats nice, but too advanced for him
yes 😄
when can i code like this codes?
a few months of coding plugins, IF you learn
alright i try to understand this code
yeah p much
You are about to start on sync/async
nah, lambdas will confuse him as he'll miss the underlying code
litte bit
this help me how to convert async blocks to sync ?
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
its simple with spigot
- 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
that task system allows you to easily jump between sync and async
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
I suggest you go slower
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
can i do this code
shorter?
do you notice something?
no
i mean i do too thing at this code if i use lambdas
i will add those things here
and i will combine
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
idu can i delete features in next case ?
elaborate
can u explain me more detailed?