2121import net .minecraft .world .World ;
2222import net .minecraftforge .fml .relauncher .Side ;
2323import net .minecraftforge .fml .relauncher .SideOnly ;
24- import org .apache .commons .lang3 .tuple .ImmutablePair ;
25- import org .apache .commons .lang3 .tuple .Pair ;
24+ import org .dimdev .utils .LeftIdentityPair ;
2625
2726import javax .annotation .Nullable ;
2827import java .util .*;
3635 */
3736@ SuppressWarnings ("deprecation" )
3837public class NumericalBlockState extends BlockStateBase {
39- private static final Map <Pair <BlockStateContainer , Integer >, NumericalBlockState > blockStates = new HashMap <>(); // TODO: WeakHashMap?
40- private static final Map <Pair <IProperty <?>, Comparable <?>>, Integer > valueToNumber = new HashMap <>();
41- private static final Map <Pair <IProperty <?>, Integer >, Comparable <?>> numberToValue = new HashMap <>();
42- private static final Map <IProperty <?>, Integer > propertyWidths = new HashMap <>();
38+ private static final Map <LeftIdentityPair <BlockStateContainer , Integer >, NumericalBlockState > blockStates = new HashMap <>(); // TODO: WeakHashMap?
39+ private static final Map <LeftIdentityPair <IProperty <?>, Comparable <?>>, Integer > valueToNumber = new HashMap <>();
40+ private static final Map <LeftIdentityPair <IProperty <?>, Integer >, Comparable <?>> numberToValue = new HashMap <>();
41+ private static final Map <IProperty <?>, Integer > propertyWidths = new IdentityHashMap <>();
4342
4443 protected final BlockStateContainer container ;
4544 protected final Block block ;
@@ -55,7 +54,7 @@ public static NumericalBlockState get(BlockStateContainer container, int data) {
5554 // Getting it from a cache is necessary to make sure == between two NumericalBlockStates
5655 // with the same container and data will work. The cache is shared for all containers
5756 // to avoid the overhead of many small HashMaps.
58- ImmutablePair <BlockStateContainer , Integer > key = new ImmutablePair <>(container , data );
57+ LeftIdentityPair <BlockStateContainer , Integer > key = new LeftIdentityPair <>(container , data );
5958 NumericalBlockState blockState = blockStates .get (key );
6059
6160 if (blockState == null ) {
@@ -72,8 +71,7 @@ public static NumericalBlockState fromPropertyValueMap(BlockStateContainer conta
7271 int data = 0 ;
7372 for (Map .Entry <IProperty <?>, Comparable <?>> entry : map .entrySet ()) {
7473 IProperty <?> property = entry .getKey ();
75- //noinspection SuspiciousMethodCalls
76- data |= valueToNumber .get (new ImmutablePair <>(property , entry .getValue ())) << offsets .get (property );
74+ data |= valueToNumber .get (new LeftIdentityPair <>(property , entry .getValue ())) << offsets .get (property );
7775 }
7876
7977 return get (container , data );
@@ -90,8 +88,8 @@ public static <T extends Comparable<T>> void makePropertyInfo(IProperty<T> prope
9088 // Fill the 'number -> value' and 'value -> number' maps
9189 int i = 0 ;
9290 for (T value : allowedValues ) {
93- numberToValue .put (new ImmutablePair <>(property , i ), value );
94- valueToNumber .put (new ImmutablePair <>(property , value ), i );
91+ numberToValue .put (new LeftIdentityPair <>(property , i ), value );
92+ valueToNumber .put (new LeftIdentityPair <>(property , value ), i );
9593 i ++;
9694 }
9795 }
@@ -111,7 +109,7 @@ public <T extends Comparable<T>> T getValue(IProperty<T> property) {
111109
112110 int width = propertyWidths .get (property );
113111 int number = data >>> offset & 0xFFFFFFFF >>> 32 - width ;
114- @ SuppressWarnings ( "SuspiciousMethodCalls" ) Comparable <?> value = numberToValue .get (new ImmutablePair <>(property , number ));
112+ Comparable <?> value = numberToValue .get (new LeftIdentityPair <>(property , number ));
115113
116114 return property .getValueClass ().cast (value );
117115 }
@@ -124,7 +122,7 @@ public <T extends Comparable<T>, V extends T> IBlockState withProperty(IProperty
124122 throw new IllegalArgumentException ("Cannot set property " + property + " as it does not exist in " + container );
125123 }
126124
127- @ SuppressWarnings ( "SuspiciousMethodCalls" ) int number = valueToNumber .get (new ImmutablePair <>(property , value ));
125+ int number = valueToNumber .get (new LeftIdentityPair <>(property , value ));
128126 int width = propertyWidths .get (property );
129127 int mask = (0xFFFFFFFF >>> offset & 0xFFFFFFFF >>> 32 - width ) << offset ;
130128 int newData = data & ~mask | number << offset ;
0 commit comments