Browse Source

Fixed a Threading Issue and made Volcanish Ash usable for IC2 Fertilizer

Gregorius Techneticies 3 months ago
parent
commit
ea03e4aae6
Signed by: Gregorius Techneticies <gregoriustech@gmail.com> GPG Key ID: 1B693EA14F2FD70F

+ 2
- 0
src/main/java/gregapi/GT_API_Proxy.java View File

@@ -239,6 +239,7 @@ public abstract class GT_API_Proxy extends Abstract_Proxy implements IGuiHandler
239 239
 	@SuppressWarnings("unchecked")
240 240
 	public void onServerTick(ServerTickEvent aEvent) {
241 241
 		if (aEvent.side.isServer()) {
242
+			TICK_LOCK = T;
242 243
 			
243 244
 			// Making sure it is being free'd up in order to prevent exploits or Garbage Collection mishaps.
244 245
 			LAST_BROKEN_TILEENTITY.set(null);
@@ -437,6 +438,7 @@ public abstract class GT_API_Proxy extends Abstract_Proxy implements IGuiHandler
437 438
 					}
438 439
 				}
439 440
 				EntityFoodTracker.tick();
441
+				TICK_LOCK = F;
440 442
 			}
441 443
 		}
442 444
 	}

+ 3
- 3
src/main/java/gregapi/block/misc/BlockBaseMachineUpdate.java View File

@@ -1,5 +1,5 @@
1 1
 /**
2
- * Copyright (c) 2020 GregTech-6 Team
2
+ * Copyright (c) 2021 GregTech-6 Team
3 3
  *
4 4
  * This file is part of GregTech.
5 5
  *
@@ -41,7 +41,7 @@ public abstract class BlockBaseMachineUpdate extends BlockBaseMeta {
41 41
 		setCreativeTab(CreativeTabs.tabRedstone);
42 42
 	}
43 43
 	
44
-	@Override public void onBlockAdded2(World aWorld, int aX, int aY, int aZ)                           {if (ITileEntityMachineBlockUpdateable.Util.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ)    )) ITileEntityMachineBlockUpdateable.Util.causeMachineUpdate(aWorld, aX, aY, aZ, this, UT.Code.bind4(aWorld.getBlockMetadata(aX, aY, aZ)), F);}
45
-	@Override public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {if (ITileEntityMachineBlockUpdateable.Util.isMachineBlock(this, aMetaData                              )) ITileEntityMachineBlockUpdateable.Util.causeMachineUpdate(aWorld, aX, aY, aZ, this, UT.Code.bind4(aMetaData), T);}
44
+	@Override public void onBlockAdded2(World aWorld, int aX, int aY, int aZ)                           {if (ITileEntityMachineBlockUpdateable.Util.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) ITileEntityMachineBlockUpdateable.Util.causeMachineUpdate(aWorld, aX, aY, aZ, this, UT.Code.bind4(aWorld.getBlockMetadata(aX, aY, aZ)), F);}
45
+	@Override public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {if (ITileEntityMachineBlockUpdateable.Util.isMachineBlock(this, aMetaData                          )) ITileEntityMachineBlockUpdateable.Util.causeMachineUpdate(aWorld, aX, aY, aZ, this, UT.Code.bind4(aMetaData), T);}
46 46
 	@Override public int getMobilityFlag() {return 2;}
47 47
 }

+ 2
- 0
src/main/java/gregapi/data/CS.java View File

@@ -301,6 +301,8 @@ public class CS {
301 301
 	public static long SERVER_TIME = 0;
302 302
 	/** Current Time on the Client. Used for Animations. */
303 303
 	public static long CLIENT_TIME = 0;
304
+	/** Is true whenever updateEntities and similar are running on the tick. */
305
+	public static volatile boolean TICK_LOCK = F;
304 306
 	
305 307
 	/** If I ever need to talk in Chat. XD */
306 308
 	public static final String CHAT_GREG = LH.Chat.WHITE+"<"+LH.Chat.BLUE+"GregoriusT"+LH.Chat.WHITE+"> ";

+ 11
- 9
src/main/java/gregapi/tileentity/ITileEntityMachineBlockUpdateable.java View File

@@ -1,5 +1,5 @@
1 1
 /**
2
- * Copyright (c) 2019 Gregorius Techneticies
2
+ * Copyright (c) 2021 GregTech-6 Team
3 3
  *
4 4
  * This file is part of GregTech.
5 5
  *
@@ -124,16 +124,18 @@ public interface ITileEntityMachineBlockUpdateable {
124 124
 			}
125 125
 			
126 126
 			private void stepToUpdateMachine(World aWorld, ChunkCoordinates aCoords, HashSetNoNulls<ChunkCoordinates> aSet) {
127
+				// Wait for the updateEntities Thread to be done because fucking Mojang and race conditions in loading Chunks.
128
+				while (TICK_LOCK) try {Thread.sleep(1);} catch (InterruptedException e) {/**/}
127 129
 				TileEntity tTileEntity = WD.te(aWorld, aCoords, T);
128
-				if (tTileEntity != null && tTileEntity instanceof ITileEntityMachineBlockUpdateable) ((ITileEntityMachineBlockUpdateable)tTileEntity).onMachineBlockUpdate(mCoords, mBlock, mMeta, mRemoved);
129
-				if (aSet.size() < 5 || (tTileEntity != null && tTileEntity instanceof ITileEntityMachineBlockUpdateable) || isMachineBlock(aWorld.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ), aWorld.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ))) {
130
+				if (tTileEntity instanceof ITileEntityMachineBlockUpdateable) ((ITileEntityMachineBlockUpdateable)tTileEntity).onMachineBlockUpdate(mCoords, mBlock, mMeta, mRemoved);
131
+				if (aSet.size() < 5 || tTileEntity instanceof ITileEntityMachineBlockUpdateable || isMachineBlock(aWorld.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ), aWorld.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ))) {
130 132
 					ChunkCoordinates tCoords;
131
-					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ))) stepToUpdateMachine(aWorld, tCoords, aSet);
132
-					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ))) stepToUpdateMachine(aWorld, tCoords, aSet);
133
-					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ))) stepToUpdateMachine(aWorld, tCoords, aSet);
134
-					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ))) stepToUpdateMachine(aWorld, tCoords, aSet);
135
-					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1))) stepToUpdateMachine(aWorld, tCoords, aSet);
136
-					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1))) stepToUpdateMachine(aWorld, tCoords, aSet);
133
+					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX+1, aCoords.posY  , aCoords.posZ  ))) stepToUpdateMachine(aWorld, tCoords, aSet);
134
+					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX-1, aCoords.posY  , aCoords.posZ  ))) stepToUpdateMachine(aWorld, tCoords, aSet);
135
+					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX  , aCoords.posY+1, aCoords.posZ  ))) stepToUpdateMachine(aWorld, tCoords, aSet);
136
+					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX  , aCoords.posY-1, aCoords.posZ  ))) stepToUpdateMachine(aWorld, tCoords, aSet);
137
+					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX  , aCoords.posY  , aCoords.posZ+1))) stepToUpdateMachine(aWorld, tCoords, aSet);
138
+					if (aSet.add(tCoords = new ChunkCoordinates(aCoords.posX  , aCoords.posY  , aCoords.posZ-1))) stepToUpdateMachine(aWorld, tCoords, aSet);
137 139
 				}
138 140
 			}
139 141
 		}

+ 3
- 3
src/main/java/gregtech/compat/Compat_Recipes_Forestry.java View File

@@ -1,5 +1,5 @@
1 1
 /**
2
- * Copyright (c) 2020 GregTech-6 Team
2
+ * Copyright (c) 2021 GregTech-6 Team
3 3
  *
4 4
  * This file is part of GregTech.
5 5
  *
@@ -391,7 +391,7 @@ public class Compat_Recipes_Forestry extends CompatMods {
391 391
 		RM.Mixer        .addRecipe2(T, 16,   16, OP.gem.mat(MT.Apatite, 1), ST.make(Blocks.sand, 2, W), IL.FR_Fertilizer.get(8));
392 392
 		RM.Mixer        .addRecipe2(T, 16,   16, OP.gem.mat(MT.Apatite, 1), OM.dust(MT.Ash, U*8), IL.FR_Fertilizer.get(16));
393 393
 		RM.Mixer        .addRecipe2(T, 16,   16, OP.gem.mat(MT.Apatite, 1), OM.dust(MT.DarkAsh, U*4), IL.FR_Fertilizer.get(16));
394
-		RM.Mixer        .addRecipe2(T, 16,   16, OP.gem.mat(MT.Apatite, 1), OM.dust(MT.VolcanicAsh, U*4), IL.FR_Fertilizer.get(16));
394
+		RM.Mixer        .addRecipe2(T, 16,   16, OP.gem.mat(MT.Apatite, 1), OM.dust(MT.VolcanicAsh, U*2), IL.FR_Fertilizer.get(16));
395 395
 		
396 396
 		RM.Mixer        .addRecipeX(T, 16,   16, ST.array(OM.dust(MT.NaNO3), OM.dust(MT.SoylentGreen  ), ST.make(Blocks.sand, 2, W)), IL.FR_Fertilizer.get(2));
397 397
 		RM.Mixer        .addRecipeX(T, 16,   16, ST.array(OM.dust(MT.KNO3 ), OM.dust(MT.SoylentGreen  ), ST.make(Blocks.sand, 2, W)), IL.FR_Fertilizer.get(2));
@@ -420,7 +420,7 @@ public class Compat_Recipes_Forestry extends CompatMods {
420 420
 		RM.Mixer        .addRecipe2(T, 16,   16, OM.dust(MT.Apatite), ST.make(Blocks.sand, 2, W), IL.FR_Fertilizer.get(8));
421 421
 		RM.Mixer        .addRecipe2(T, 16,   16, OM.dust(MT.Apatite), OM.dust(MT.Ash, U*8), IL.FR_Fertilizer.get(16));
422 422
 		RM.Mixer        .addRecipe2(T, 16,   16, OM.dust(MT.Apatite), OM.dust(MT.DarkAsh, U*4), IL.FR_Fertilizer.get(16));
423
-		RM.Mixer        .addRecipe2(T, 16,   16, OM.dust(MT.Apatite), OM.dust(MT.VolcanicAsh, U*4), IL.FR_Fertilizer.get(16));
423
+		RM.Mixer        .addRecipe2(T, 16,   16, OM.dust(MT.Apatite), OM.dust(MT.VolcanicAsh, U*2), IL.FR_Fertilizer.get(16));
424 424
 		
425 425
 		RM.Mixer        .addRecipeX(T, 16,   64, ST.array(ST.make(Blocks.sand, 4, W), ST.make(Blocks.dirt, 4, W), IL.FR_Mulch.get(1)), ST.make(MD.FR, "soil", 8, 1));
426 426
 		

+ 6
- 0
src/main/java/gregtech/compat/Compat_Recipes_IndustrialCraft.java View File

@@ -527,33 +527,39 @@ public class Compat_Recipes_IndustrialCraft extends CompatMods {
527 527
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.CaCO3                 ), OM.dust(MT.PO4           ), IL.IC2_Fertilizer.get(2));
528 528
 		RM.Mixer            .addRecipe2(T, 16,   16, OM.dust(MT.CaCO3                 ), OM.dust(MT.Ash       ,3*U), IL.IC2_Fertilizer.get(1));
529 529
 		RM.Mixer            .addRecipe2(T, 16,   16, OM.dust(MT.CaCO3                 ), OM.dust(MT.DarkAsh       ), IL.IC2_Fertilizer.get(1));
530
+		RM.Mixer            .addRecipe2(T, 16,   16, OM.dust(MT.CaCO3                 ), OM.dust(MT.VolcanicAsh   ), IL.IC2_Fertilizer.get(2));
530 531
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.Ca                    ), OM.dust(MT.S             ), IL.IC2_Fertilizer.get(3));
531 532
 		RM.Mixer            .addRecipe2(T, 16,   64, OM.dust(MT.Ca                    ), OM.dust(MT.Phosphorus    ), IL.IC2_Fertilizer.get(4));
532 533
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.Ca                    ), OM.dust(MT.PO4           ), IL.IC2_Fertilizer.get(3));
533 534
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.Ca                    ), OM.dust(MT.Ash       ,3*U), IL.IC2_Fertilizer.get(2));
534 535
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.Ca                    ), OM.dust(MT.DarkAsh       ), IL.IC2_Fertilizer.get(2));
536
+		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.Ca                    ), OM.dust(MT.VolcanicAsh   ), IL.IC2_Fertilizer.get(4));
535 537
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.Apatite               ), OM.dust(MT.S             ), IL.IC2_Fertilizer.get(3));
536 538
 		RM.Mixer            .addRecipe2(T, 16,   64, OM.dust(MT.Apatite               ), OM.dust(MT.Phosphorus    ), IL.IC2_Fertilizer.get(4));
537 539
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.Apatite               ), OM.dust(MT.PO4           ), IL.IC2_Fertilizer.get(3));
538 540
 		if (!MD.FR.mLoaded) {
539 541
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.Apatite               ), OM.dust(MT.Ash       ,3*U), IL.IC2_Fertilizer.get(2));
540 542
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.Apatite               ), OM.dust(MT.DarkAsh       ), IL.IC2_Fertilizer.get(2));
543
+		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.Apatite               ), OM.dust(MT.VolcanicAsh   ), IL.IC2_Fertilizer.get(4));
541 544
 		}
542 545
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.OREMATS.Glauconite    ), OM.dust(MT.S             ), IL.IC2_Fertilizer.get(3));
543 546
 		RM.Mixer            .addRecipe2(T, 16,   64, OM.dust(MT.OREMATS.Glauconite    ), OM.dust(MT.Phosphorus    ), IL.IC2_Fertilizer.get(4));
544 547
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.OREMATS.Glauconite    ), OM.dust(MT.PO4           ), IL.IC2_Fertilizer.get(3));
545 548
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.OREMATS.Glauconite    ), OM.dust(MT.Ash       ,3*U), IL.IC2_Fertilizer.get(2));
546 549
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.OREMATS.Glauconite    ), OM.dust(MT.DarkAsh       ), IL.IC2_Fertilizer.get(2));
550
+		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.OREMATS.Glauconite    ), OM.dust(MT.VolcanicAsh   ), IL.IC2_Fertilizer.get(4));
547 551
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.NaHSO4                ), OM.dust(MT.S             ), IL.IC2_Fertilizer.get(3));
548 552
 		RM.Mixer            .addRecipe2(T, 16,   64, OM.dust(MT.NaHSO4                ), OM.dust(MT.Phosphorus    ), IL.IC2_Fertilizer.get(4));
549 553
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.NaHSO4                ), OM.dust(MT.PO4           ), IL.IC2_Fertilizer.get(3));
550 554
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.NaHSO4                ), OM.dust(MT.Ash       ,3*U), IL.IC2_Fertilizer.get(2));
551 555
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.NaHSO4                ), OM.dust(MT.DarkAsh       ), IL.IC2_Fertilizer.get(2));
556
+		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.NaHSO4                ), OM.dust(MT.VolcanicAsh   ), IL.IC2_Fertilizer.get(4));
552 557
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.KHSO4                 ), OM.dust(MT.S             ), IL.IC2_Fertilizer.get(3));
553 558
 		RM.Mixer            .addRecipe2(T, 16,   64, OM.dust(MT.KHSO4                 ), OM.dust(MT.Phosphorus    ), IL.IC2_Fertilizer.get(4));
554 559
 		RM.Mixer            .addRecipe2(T, 16,   48, OM.dust(MT.KHSO4                 ), OM.dust(MT.PO4           ), IL.IC2_Fertilizer.get(3));
555 560
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.KHSO4                 ), OM.dust(MT.Ash       ,3*U), IL.IC2_Fertilizer.get(2));
556 561
 		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.KHSO4                 ), OM.dust(MT.DarkAsh       ), IL.IC2_Fertilizer.get(2));
562
+		RM.Mixer            .addRecipe2(T, 16,   32, OM.dust(MT.KHSO4                 ), OM.dust(MT.VolcanicAsh   ), IL.IC2_Fertilizer.get(4));
557 563
 		
558 564
 		
559 565
 		for (OreDictMaterial tMat : ANY.Iron.mToThis) if (tMat != MT.Enori) {

Loading…
Cancel
Save