fix leaves

This commit is contained in:
Sen 2025-06-23 12:26:52 +02:00
parent 1d6fef0eee
commit 445c1be8af
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
2 changed files with 28 additions and 26 deletions

View file

@ -101,9 +101,11 @@ public class BlockLeaves extends BlockLeavesBase
{ {
if(Vars.seasonLeaves && this.subType != worldIn.getLeavesGen(pos)) { if(Vars.seasonLeaves && this.subType != worldIn.getLeavesGen(pos)) {
worldIn.setState(pos, getLeavesBlock(this.type, worldIn.getLeavesGen(pos)).getState().withProperty(DECAY, state.getValue(DECAY)), 2); worldIn.setState(pos, getLeavesBlock(this.type, worldIn.getLeavesGen(pos)).getState().withProperty(DECAY, state.getValue(DECAY)), 2);
return;
} }
if(Vars.leafDry && worldIn.getTemperatureC(pos) >= 50.0f) { if(Vars.leafDry && worldIn.getTemperatureC(pos) >= 50.0f) {
worldIn.setState(pos, worldIn.rand.chance(40) ? Blocks.air.getState() : Blocks.dry_leaves.getState()); worldIn.setState(pos, worldIn.rand.chance(40) ? Blocks.air.getState() : Blocks.dry_leaves.getState());
return;
} }
// if (!worldIn.client) // if (!worldIn.client)
// { // {

View file

@ -591,14 +591,14 @@ public final class WorldServer extends AWorldServer {
protected void updateBlocks() { protected void updateBlocks() {
this.setActivePlayerChunksAndCheckLight(SVars.distance); this.setActivePlayerChunksAndCheckLight(SVars.distance);
int i = 0; int dtics = 0;
int j = 0; int rtics = 0;
for(ChunkPos chunkcoordintpair : this.active) { for(ChunkPos pos : this.active) {
int k = chunkcoordintpair.x * 16; int cx = pos.x * 16;
int l = chunkcoordintpair.z * 16; int cz = pos.z * 16;
// this.profiler.start("getChunk"); // this.profiler.start("getChunk");
ChunkServer chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z); ChunkServer chunk = this.getChunk(pos.x, pos.z);
// this.profiler.next("moodSound"); // this.profiler.next("moodSound");
// this.playMoodSound(k, l, chunk); // this.playMoodSound(k, l, chunk);
// this.profiler.next("checkLight"); // this.profiler.next("checkLight");
@ -606,12 +606,12 @@ public final class WorldServer extends AWorldServer {
// this.profiler.next("tickChunk"); // this.profiler.next("tickChunk");
chunk.update(false); chunk.update(false);
// this.profiler.next("thunder"); // this.profiler.next("thunder");
int l2 = SVars.boltChance; int tics = SVars.boltChance;
if(l2 > 0 && this.rand.zrange(l2) == 0 && this.isThundering()) { if(tics > 0 && this.rand.zrange(tics) == 0 && this.isThundering()) {
this.updateLCG = this.updateLCG * 3 + 1013904223; this.updateLCG = this.updateLCG * 3 + 1013904223;
int i1 = this.updateLCG >> 2; int i1 = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(k + (i1 & 15), 0, l + (i1 >> 8 & 15))); BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(cx + (i1 & 15), 0, cz + (i1 >> 8 & 15)));
if(this.canStrikeAt(blockpos)) { if(this.canStrikeAt(blockpos)) {
this.strikeLightning((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 0x737380, 120, true, null); this.strikeLightning((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 0x737380, 120, true, null);
@ -619,13 +619,13 @@ public final class WorldServer extends AWorldServer {
} }
// this.profiler.next("iceandsnow"); // this.profiler.next("iceandsnow");
l2 = SVars.weatherTick; tics = SVars.weatherTick;
for(int z = 0; z < l2; z++) { for(int z = 0; z < tics; z++) {
if(this.rand.zrange(16) == 0) { if(this.rand.zrange(16) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223; this.updateLCG = this.updateLCG * 3 + 1013904223;
int k2 = this.updateLCG >> 2; int k2 = this.updateLCG >> 2;
BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15))); BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(cx + (k2 & 15), 0, cz + (k2 >> 8 & 15)));
BlockPos blockpos1 = blockpos2.down(); BlockPos blockpos1 = blockpos2.down();
if(this.canBlockFreeze(blockpos1, true)) { if(this.canBlockFreeze(blockpos1, true)) {
@ -652,25 +652,25 @@ public final class WorldServer extends AWorldServer {
} }
// this.profiler.next("tickBlocks"); // this.profiler.next("tickBlocks");
l2 = SVars.randomTick; tics = SVars.randomTick;
if(l2 > 0) { if(tics > 0) {
this.toTick.addAll(chunk.getStorage()); this.toTick.addAll(chunk.getStorage());
for(BlockArray extendedblockstorage : this.toTick) { for(BlockArray section : this.toTick) {
if(extendedblockstorage != null && extendedblockstorage.isTicked()) { if(section != null && section.isTicked()) {
for(int j1 = 0; j1 < l2; ++j1) { for(int n = 0; n < tics; n++) {
this.updateLCG = this.updateLCG * 3 + 1013904223; this.updateLCG = this.updateLCG * 3 + 1013904223;
int k1 = this.updateLCG >> 2; int lcg = this.updateLCG >> 2;
int l1 = k1 & 15; int x = lcg & 15;
int i2 = k1 >> 8 & 15; int z = lcg >> 8 & 15;
int j2 = k1 >> 16 & 15; int y = lcg >> 16 & 15;
++j; ++rtics;
State iblockstate = extendedblockstorage.get(l1, j2, i2); State state = section.get(x, y, z);
Block block = iblockstate.getBlock(); Block block = state.getBlock();
if(block.getTickRandomly()) { if(block.getTickRandomly()) {
++i; ++dtics;
block.randomTick(this, new BlockPos(l1 + k, j2 + extendedblockstorage.getY(), i2 + l), iblockstate, block.randomTick(this, new BlockPos(x + cx, y + section.getY(), z + cz), state,
this.rand); this.rand);
} }
} }