Skip to content

Commit 9acf5fc

Browse files
committed
Ore Blocks should now cause less scheduled ticks during worldgen
1 parent fd81377 commit 9acf5fc

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/main/java/gregapi/block/prefixblock/PrefixBlock.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,33 @@ public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aT
361361

362362
@Override
363363
public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) {
364+
TileEntity aTileEntity = null;
364365
if (!LOCK) {
365366
LOCK = T;
366-
TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
367+
aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
367368
if (aTileEntity instanceof ITileEntity) ((ITileEntity)aTileEntity).onAdjacentBlockChange(aX, aY, aZ);
368369
LOCK = F;
369370
}
370-
aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 2);
371+
scheduleUpdateIfNeeded(aWorld, aX, aY, aZ, aTileEntity);
372+
}
373+
374+
public boolean scheduleUpdateIfNeeded(World aWorld, int aX, int aY, int aZ, TileEntity aTileEntity) {
375+
if (mGravity && aY > 0 && BlockFalling.func_149831_e(aWorld, aX, aY - 1, aZ)) {
376+
aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 2);
377+
return T;
378+
}
379+
if (aTileEntity == null) return F;
380+
if (!mCanBurn && !mCanExplode) return F;
381+
if (mPrefix.contains(TD.Prefix.DUST_BASED)) {
382+
aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 2);
383+
return T;
384+
}
385+
OreDictMaterial aMaterial = getMetaMaterial(aTileEntity);
386+
if (aMaterial.containsAny(TD.Properties.FLAMMABLE, TD.Properties.EXPLOSIVE, TD.Atomic.ALKALI_METAL)) {
387+
aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 2);
388+
return T;
389+
}
390+
return F;
371391
}
372392

373393
@Override
@@ -417,7 +437,7 @@ public boolean placeBlock(World aWorld, int aX, int aY, int aZ, byte aSide, shor
417437
// This darn TileEntity update is ruining World generation Code (infinite Loops when placing TileEntities on Chunk Borders). I'm glad I finally found a way to disable it.
418438
TileEntity tTileEntity = createTileEntity(aWorld, aX, aY, aZ, aSide, aMetaData, aNBT);
419439
WD.te(aWorld, aX, aY, aZ, tTileEntity, aCauseBlockUpdates);
420-
aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 2);
440+
scheduleUpdateIfNeeded(aWorld, aX, aY, aZ, tTileEntity);
421441
if (!aWorld.isRemote) GT_API_Proxy.SCHEDULED_TILEENTITY_UPDATES.add((PrefixBlockTileEntity)tTileEntity);
422442
return T;
423443
}

0 commit comments

Comments
 (0)