Fix NPE in ItemGroup concurrency patch
This commit is contained in:
parent
659091c565
commit
4db208332e
1 changed files with 13 additions and 19 deletions
|
@ -40,7 +40,7 @@
|
||||||
return this.field_78033_n < 6;
|
return this.field_78033_n < 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,4 +225,54 @@
|
@@ -220,4 +225,48 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,26 +72,20 @@
|
||||||
+ return 4210752;
|
+ return 4210752;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static final Object LOCK = new Object();
|
+ public static synchronized int getGroupCountSafe() {
|
||||||
+
|
+ return ItemGroup.field_78032_a.length;
|
||||||
+ public static int getGroupCountSafe() {
|
|
||||||
+ synchronized (LOCK) {
|
|
||||||
+ return ItemGroup.field_78032_a.length;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static int addGroupSafe(int index, ItemGroup newGroup) {
|
+ private static synchronized int addGroupSafe(int index, ItemGroup newGroup) {
|
||||||
+ synchronized (LOCK) {
|
+ if(index == -1) {
|
||||||
+ if(index == -1) {
|
+ index = field_78032_a.length;
|
||||||
+ index = field_78032_a.length;
|
|
||||||
+ }
|
|
||||||
+ if (index >= field_78032_a.length) {
|
|
||||||
+ ItemGroup[] tmp = new ItemGroup[index + 1];
|
|
||||||
+ System.arraycopy(field_78032_a, 0, tmp, 0, field_78032_a.length);
|
|
||||||
+ field_78032_a = tmp;
|
|
||||||
+ }
|
|
||||||
+ field_78032_a[index] = newGroup;
|
|
||||||
+ return index;
|
|
||||||
+ }
|
+ }
|
||||||
|
+ if (index >= field_78032_a.length) {
|
||||||
|
+ ItemGroup[] tmp = new ItemGroup[index + 1];
|
||||||
|
+ System.arraycopy(field_78032_a, 0, tmp, 0, field_78032_a.length);
|
||||||
|
+ field_78032_a = tmp;
|
||||||
|
+ }
|
||||||
|
+ field_78032_a[index] = newGroup;
|
||||||
|
+ return index;
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue