Skip to content

Commit

Permalink
Use fastutil map during state construction
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Jan 1, 2024
1 parent 8051ca1 commit 52ba0bf
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.embeddedt.vintagefix.mixin.blockstates;

import com.google.common.collect.ImmutableSortedMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import org.embeddedt.vintagefix.fastmap.FakeStateMap;
Expand All @@ -18,6 +19,11 @@ public class BlockStateContainerMixin {
@Final
private ImmutableSortedMap<String, IProperty<?>> properties;

@ModifyVariable(method = "<init>(Lnet/minecraft/block/Block;[Lnet/minecraft/block/properties/IProperty;Lcom/google/common/collect/ImmutableMap;)V", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Maps;newHashMap()Ljava/util/HashMap;"), ordinal = 0, index = 4)
private Map<String, IProperty<?>> useFastUtilMap(Map<String, IProperty<?>> map) {
return new Object2ObjectOpenHashMap<>(map);
}

@ModifyVariable(method = "<init>(Lnet/minecraft/block/Block;[Lnet/minecraft/block/properties/IProperty;Lcom/google/common/collect/ImmutableMap;)V", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Maps;newLinkedHashMap()Ljava/util/LinkedHashMap;"), ordinal = 1, index = 5)
private Map<Map<IProperty<?>, Comparable<?>>, BlockStateContainer.StateImplementation> useArrayMap(Map<Map<IProperty<?>, Comparable<?>>, BlockStateContainer.StateImplementation> in) {
int numStates = 1;
Expand Down

0 comments on commit 52ba0bf

Please sign in to comment.