Skip to content

Commit

Permalink
fix: LithiumHashPalette copy implementation causing wrong block rende…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
2No2Name committed Nov 30, 2021
1 parent 884b478 commit cc7e185
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private LithiumConfig() {
this.addMixinRule("chunk.entity_class_groups", true);
this.addMixinRule("chunk.no_locking", true);
this.addMixinRule("chunk.no_validation", true);
this.addMixinRule("chunk.palette", true);
this.addMixinRule("chunk.palette", false); //causes a pretty mess being rendered
this.addMixinRule("chunk.section_update_tracking", true);
this.addMixinRule("chunk.serialization", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.world.chunk.Palette;
import net.minecraft.world.chunk.PaletteResizeListener;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
Expand All @@ -31,6 +30,15 @@ public class LithiumHashPalette<T> implements Palette<T> {
private T[] entries;
private int size = 0;

public LithiumHashPalette(IndexedIterable<T> idList, PaletteResizeListener<T> resizeHandler, int indexBits, T[] entries, Reference2IntMap<T> table, int size) {
this.idList = idList;
this.resizeHandler = resizeHandler;
this.indexBits = indexBits;
this.entries = entries;
this.table = table;
this.size = size;
}

public LithiumHashPalette(IndexedIterable<T> idList, int bits, PaletteResizeListener<T> resizeHandler, List<T> list) {
this(idList, bits, resizeHandler);

Expand Down Expand Up @@ -157,8 +165,7 @@ public int getSize() {

@Override
public Palette<T> copy() {
var clone = new ArrayList<>(this.table.keySet());
return new LithiumHashPalette<>(this.idList, this.indexBits, this.resizeHandler, clone);
return new LithiumHashPalette<>(this.idList, this.resizeHandler, this.indexBits, this.entries.clone(), new Reference2IntOpenHashMap<>(this.table), this.size);
}

private void clear() {
Expand Down

0 comments on commit cc7e185

Please sign in to comment.