2121import net .minecraft .world .World ;
2222import net .minecraftforge .fml .relauncher .Side ;
2323import net .minecraftforge .fml .relauncher .SideOnly ;
24- import org .dimdev .utils .LeftIdentityPair ;
24+ import org .dimdev .utils .Pair ;
2525
2626import javax .annotation .Nullable ;
27- import java .util .*;
27+ import java .util .Collection ;
28+ import java .util .HashMap ;
29+ import java .util .List ;
30+ import java .util .Map ;
2831
2932/**
3033 * An implementation of IBlockState which stores the properties in a bitfield rather
3538 */
3639@ SuppressWarnings ("deprecation" )
3740public class NumericalBlockState extends BlockStateBase {
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 <>();
41+ private static final Map <Pair <BlockStateContainer , Integer >, NumericalBlockState > blockStates = new HashMap <>(); // TODO: WeakHashMap?
42+ private static final Map <Pair <IProperty <?>, Comparable <?>>, Integer > valueToNumber = new HashMap <>();
43+ private static final Map <Pair <IProperty <?>, Integer >, Comparable <?>> numberToValue = new HashMap <>();
44+ private static final Map <IProperty <?>, Integer > propertyWidths = new HashMap <>();
4245
4346 protected final BlockStateContainer container ;
4447 protected final Block block ;
@@ -54,7 +57,7 @@ public static NumericalBlockState get(BlockStateContainer container, int data) {
5457 // Getting it from a cache is necessary to make sure == between two NumericalBlockStates
5558 // with the same container and data will work. The cache is shared for all containers
5659 // to avoid the overhead of many small HashMaps.
57- LeftIdentityPair <BlockStateContainer , Integer > key = new LeftIdentityPair <>(container , data );
60+ Pair <BlockStateContainer , Integer > key = new Pair <>(container , data );
5861 NumericalBlockState blockState = blockStates .get (key );
5962
6063 if (blockState == null ) {
@@ -71,7 +74,7 @@ public static NumericalBlockState fromPropertyValueMap(BlockStateContainer conta
7174 int data = 0 ;
7275 for (Map .Entry <IProperty <?>, Comparable <?>> entry : map .entrySet ()) {
7376 IProperty <?> property = entry .getKey ();
74- data |= valueToNumber .get (new LeftIdentityPair <>(property , entry .getValue ())) << offsets .get (property );
77+ data |= valueToNumber .get (new Pair <>(property , entry .getValue ())) << offsets .get (property );
7578 }
7679
7780 return get (container , data );
@@ -88,8 +91,8 @@ public static <T extends Comparable<T>> void makePropertyInfo(IProperty<T> prope
8891 // Fill the 'number -> value' and 'value -> number' maps
8992 int i = 0 ;
9093 for (T value : allowedValues ) {
91- numberToValue .put (new LeftIdentityPair <>(property , i ), value );
92- valueToNumber .put (new LeftIdentityPair <>(property , value ), i );
94+ numberToValue .put (new Pair <>(property , i ), value );
95+ valueToNumber .put (new Pair <>(property , value ), i );
9396 i ++;
9497 }
9598 }
@@ -109,7 +112,7 @@ public <T extends Comparable<T>> T getValue(IProperty<T> property) {
109112
110113 int width = propertyWidths .get (property );
111114 int number = data >>> offset & 0xFFFFFFFF >>> 32 - width ;
112- Comparable <?> value = numberToValue .get (new LeftIdentityPair <>(property , number ));
115+ Comparable <?> value = numberToValue .get (new Pair <>(property , number ));
113116
114117 return property .getValueClass ().cast (value );
115118 }
@@ -122,7 +125,7 @@ public <T extends Comparable<T>, V extends T> IBlockState withProperty(IProperty
122125 throw new IllegalArgumentException ("Cannot set property " + property + " as it does not exist in " + container );
123126 }
124127
125- int number = valueToNumber .get (new LeftIdentityPair <>(property , value ));
128+ int number = valueToNumber .get (new Pair <>(property , value ));
126129 int width = propertyWidths .get (property );
127130 int mask = (0xFFFFFFFF >>> offset & 0xFFFFFFFF >>> 32 - width ) << offset ;
128131 int newData = data & ~mask | number << offset ;
0 commit comments