Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of chunk saving #64

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.dimdev.jeid.mixin.core.world;

import com.google.common.collect.*;
import java.util.*;
import net.minecraft.block.properties.*;
import net.minecraft.block.state.BlockStateContainer.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using wildcard imports


@Mixin(StateImplementation.class)
public class MixinStateImplementation {

private int hashCodeValue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @Unique annotation


@Shadow
private ImmutableMap<IProperty<?>, Comparable<?>> properties;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have @Final annotation as properties is a final variable


@Inject(
method = "<init>",
at = @At("RETURN")
)
private void initHashCode(CallbackInfo ci) {
hashCodeValue = Objects.hash(this, properties);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this in the hash is incorrect; this is a mixin so this would just call this mixin's hashCode() -> hashCodeValue -> 0. I think you meant to shadow StateImplementation#block and use that as part of the hash?

}

/**
* @author hohserg
* @reason it should just return value. kinda have no sense to @Inject
*/
@Overwrite
public int hashCode() {
return hashCodeValue;
}

}
1 change: 1 addition & 0 deletions src/main/resources/mixins.jeid.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"world.MixinChunkPrimer",
"world.MixinChunkProviderServer",
"world.MixinGenLayerVoronoiZoom",
"world.MixinStateImplementation",
"world.MixinWorldInfo"
],
"client": [
Expand Down