Browse Source

Fixed a Fluid Pipe Bug and improved Bedrock Ore Generation Code

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

+ 2
- 2
src/main/java/gregapi/tileentity/connectors/MultiTileEntityPipeFluid.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
  *
@@ -360,7 +360,7 @@ public class MultiTileEntityPipeFluid extends TileEntityBase10ConnectorRendered
360 360
 		// Check if we are empty.
361 361
 		if (aTank.isEmpty()) return;
362 362
 		// Distribute to Tanks afterwards.
363
-		for (DelegatorTileEntity tTank : tTanks) mTransferredAmount += aTank.remove(FL.fill_(tTank, aTank.get(tAmount), T));
363
+		for (DelegatorTileEntity tTank : tTanks) mTransferredAmount += aTank.remove(FL.fill(tTank, aTank.get(tAmount), T));
364 364
 		// Check if we are empty.
365 365
 		if (aTank.isEmpty()) return;
366 366
 		// No Targets? Nothing to do then.

+ 1
- 1
src/main/java/gregapi/util/WD.java View File

@@ -628,7 +628,7 @@ public class WD {
628 628
 		Block tBlock = aWorld.getBlock(aX, aY, aZ), tStone = (aWorld.provider.dimensionId == DIM_NETHER ? Blocks.netherrack : Blocks.stone);
629 629
 		
630 630
 		if (tBlock == NB || bedrock(tBlock)) {
631
-			for (int i = 1; i < 7; i++) for (byte tSide : ALL_SIDES_BUT_BOTTOM) {
631
+			for (byte tSide : ALL_SIDES_BUT_BOTTOM) for (int i = 1; i < 7; i++) {
632 632
 				tBlock = aWorld.getBlock(aX+OFFSETS_X[tSide]*i, aY+OFFSETS_Y[tSide]*i, aZ+OFFSETS_Z[tSide]*i);
633 633
 				if (tBlock != NB && tBlock != tStone && !bedrock(tBlock)) {
634 634
 					int tMetaData = aWorld.getBlockMetadata(aX+OFFSETS_X[tSide]*i, aY+OFFSETS_Y[tSide]*i, aZ+OFFSETS_Z[tSide]*i);

+ 50
- 37
src/main/java/gregapi/worldgen/WorldgenOresBedrock.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
  *
@@ -141,48 +141,61 @@ public class WorldgenOresBedrock extends WorldgenObject {
141 141
 		
142 142
 		if (WD.bedrock(aWorld, aMinX+8, 0, aMinZ+8)) {
143 143
 			CAN_GENERATE_BEDROCK_ORE = F;
144
-			if ((mIndicatorRocks || mIndicatorFlowers) && (!(GENERATE_STREETS && aWorld.provider.dimensionId == 0) || (Math.abs(aMinX) >= 64 && Math.abs(aMaxX) >= 64 && Math.abs(aMinZ) >= 64 && Math.abs(aMaxZ) >= 64))) {
145
-				ItemStack tRock = OP.rockGt.mat(mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial, 1);
146
-				if (ST.valid(tRock)) {
147
-					MultiTileEntityRegistry tRegistry = MultiTileEntityRegistry.getRegistry("gt.multitileentity");
148
-					if (tRegistry != null) {
149
-						int tMinHeight = Math.min(aWorld.getHeight()-2, WD.waterLevel(aWorld)-1)
150
-						,   tMaxHeight = Math.min(aWorld.getHeight()-1, tMinHeight * 2 + 16);
151
-						for (int i = 0; i < 32; i++) {
152
-							int tX = aMinX+aRandom.nextInt(32)-8, tZ = aMinZ+aRandom.nextInt(32)-8;
153
-							for (int tY = tMaxHeight; tY > tMinHeight; tY--) {
154
-								Block tContact = aWorld.getBlock(tX, tY, tZ);
155
-								if (tContact.getMaterial().isLiquid() || tContact == Blocks.farmland) break;
156
-								if (!tContact.isOpaqueCube() || tContact.isWood(aWorld, tX, tY, tZ) || tContact.isLeaves(aWorld, tX, tY, tZ)) continue;
157
-								if (!WD.easyRep(aWorld, tX, tY+1, tZ)) break;
158
-								if (mIndicatorFlowers && (tContact != Blocks.dirt || !BIOMES_WASTELANDS.contains(aBiomes[8][8].biomeName)) && (!mIndicatorRocks || aRandom.nextInt(4) > 0)) {
159
-									WD.set(aWorld, tX, tY+1, tZ, mFlower, mFlowerMeta, 0);
160
-									if (mFlower.canBlockStay(aWorld, tX, tY+1, tZ)) break;
161
-									WD.set(aWorld, tX, tY+1, tZ, NB, 0, 0);
162
-								}
163
-								if (mIndicatorRocks && (tContact.getMaterial() == Material.grass || tContact.getMaterial() == Material.ground || tContact.getMaterial() == Material.sand || tContact.getMaterial() == Material.rock)) {
164
-									tRegistry.mBlock.placeBlock(aWorld, tX, tY+1, tZ, SIDE_UNKNOWN, (short)32757, ST.save(NBT_VALUE, tRock), F, T);
165
-									break;
166
-								}
167
-								break;
168
-							}
169
-						}
144
+			
145
+			try {
146
+				for (int tX = -2; tX <= 2; tX++) for (int tZ = -2; tZ <= 2; tZ++) {
147
+					switch(aRandom.nextInt(6)) {
148
+					case 0:         BlocksGT.oreBedrock         .placeBlock(aWorld, aMinX+8+tX, 0, aMinZ+8+tZ, SIDE_UNKNOWN, (mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial).mID, null, F, T); break;
149
+					case 1: case 2: BlocksGT.oreSmallBedrock    .placeBlock(aWorld, aMinX+8+tX, 0, aMinZ+8+tZ, SIDE_UNKNOWN, (mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial).mID, null, F, T); break;
170 150
 					}
171 151
 				}
152
+			} catch(Throwable e) {
153
+				e.printStackTrace(ERR);
172 154
 			}
173 155
 			
174
-			int[] tDistances = new int[] {0, 3, 6, 8, 9, 7, 4};
175
-			for (int tY = 1; tY < 7; tY++) for (int tX = -tDistances[tY]; tX <= tDistances[tY]; tX++) for (int tZ = -tDistances[tY]; tZ <= tDistances[tY]; tZ++) {
176
-				WD.removeBedrock(aWorld, aMinX+8+tX, tY, aMinZ+8+tZ);
177
-				switch(aRandom.nextInt(6)) {
178
-				case 0:         WD.setOre     (aWorld, aMinX+8+tX, tY, aMinZ+8+tZ, mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial); break;
179
-				case 1: case 2: WD.setSmallOre(aWorld, aMinX+8+tX, tY, aMinZ+8+tZ, mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial); break;
156
+			try {
157
+				// Keep Distances within the Chunk for this important step.
158
+				int[] tD = new int[] {0, 3, 5, 6, 7, 6, 4};
159
+				for (int tY = 1; tY < tD.length; tY++) for (int tX = -tD[tY]; tX <= tD[tY]; tX++) for (int tZ = -tD[tY]; tZ <= tD[tY]; tZ++) {
160
+					WD.removeBedrock(aWorld, aMinX+8+tX, tY, aMinZ+8+tZ);
161
+					switch(aRandom.nextInt(6)) {
162
+					case 0:         WD.setOre     (aWorld, aMinX+8+tX, tY, aMinZ+8+tZ, mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial); break;
163
+					case 1: case 2: WD.setSmallOre(aWorld, aMinX+8+tX, tY, aMinZ+8+tZ, mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial); break;
164
+					}
180 165
 				}
166
+			} catch(Throwable e) {
167
+				e.printStackTrace(ERR);
181 168
 			}
182
-			for (int tX = -2; tX <= 2; tX++) for (int tZ = -2; tZ <= 2; tZ++) {
183
-				switch(aRandom.nextInt(6)) {
184
-				case 0:         BlocksGT.oreBedrock         .placeBlock(aWorld, aMinX+8+tX, 0, aMinZ+8+tZ, SIDE_UNKNOWN, (mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial).mID, null, F, T); break;
185
-				case 1: case 2: BlocksGT.oreSmallBedrock    .placeBlock(aWorld, aMinX+8+tX, 0, aMinZ+8+tZ, SIDE_UNKNOWN, (mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial).mID, null, F, T); break;
169
+			
170
+			if ((mIndicatorRocks || mIndicatorFlowers) && (!GENERATE_STREETS || aWorld.provider.dimensionId != 0 || (Math.abs(aMinX) >= 64 && Math.abs(aMaxX) >= 64 && Math.abs(aMinZ) >= 64 && Math.abs(aMaxZ) >= 64))) { 
171
+				MultiTileEntityRegistry tRegistry = (mIndicatorRocks ? MultiTileEntityRegistry.getRegistry("gt.multitileentity") : null);
172
+				ItemStack tRock = (tRegistry == null ? null : OP.rockGt.mat(mMaterial == ANY.Hexorium ? UT.Code.select(MT.HexoriumBlack, ANY.Hexorium.mToThis.toArray(ZL_MATERIAL)) : mMaterial, 1));
173
+				boolean tFlowers = (mIndicatorFlowers && !BIOMES_WASTELANDS.contains(aBiomes[8][8].biomeName)), tRocks = ST.valid(tRock);
174
+				
175
+				int tMinHeight = Math.min(aWorld.getHeight()-2, WD.waterLevel(aWorld)-1)
176
+				,   tMaxHeight = Math.min(aWorld.getHeight()-1, tMinHeight * 2 + 16);
177
+				// Generate first an 8x8 of 4, then a 16x16 of 8, and at the end a 32x32 of 16 Rocks/Flowers. That way the Pattern gets denser in the middle, and Chunk Boundary Issues of GalactiCraft wont be as terrible.
178
+				for (int tD = 4; tD <= 16; tD *= 2) try {for (int i = 0; i < tD; i++) {
179
+					int tX = aMinX+aRandom.nextInt(tD*2)+8-tD, tZ = aMinZ+aRandom.nextInt(tD*2)+8-tD;
180
+					for (int tY = tMaxHeight; tY > tMinHeight; tY--) {
181
+						Block tContact = aWorld.getBlock(tX, tY, tZ);
182
+						if (tContact.getMaterial().isLiquid() || tContact == Blocks.farmland) break;
183
+						if (!tContact.isOpaqueCube() || tContact.isWood(aWorld, tX, tY, tZ) || tContact.isLeaves(aWorld, tX, tY, tZ)) continue;
184
+						if (!WD.easyRep(aWorld, tX, tY+1, tZ)) break;
185
+						if (tFlowers && tContact != Blocks.dirt && (!tRocks || aRandom.nextInt(4) > 0)) {
186
+							WD.set(aWorld, tX, tY+1, tZ, mFlower, mFlowerMeta, 0);
187
+							if (mFlower.canBlockStay(aWorld, tX, tY+1, tZ)) break;
188
+							WD.set(aWorld, tX, tY+1, tZ, NB, 0, 0);
189
+						}
190
+						if (tRocks && (tContact.getMaterial() == Material.grass || tContact.getMaterial() == Material.ground || tContact.getMaterial() == Material.sand || tContact.getMaterial() == Material.rock)) {
191
+							tRegistry.mBlock.placeBlock(aWorld, tX, tY+1, tZ, SIDE_UNKNOWN, (short)32757, ST.save(NBT_VALUE, tRock), F, T);
192
+							break;
193
+						}
194
+						break;
195
+					}
196
+				}} catch(Throwable e) {
197
+					ERR.println(tD);
198
+					e.printStackTrace(ERR);
186 199
 				}
187 200
 			}
188 201
 			// At least one Ore Block must be there. So place a large one in the Center.

Loading…
Cancel
Save