Add null cancellation.

This commit is contained in:
Connor Colenso committed 2024-08-15 20:00:25 +01:00
1 parent 1f2314a8a5
commit 7259ad0a54
2 files changed
+8 -2

No files matched your search

+2 -2
View File
@@ -4,7 +4,7 @@ This API provides a suite of tools for transforming blocks and items in the game
## Features
1. **Tile Entity Transformation**: Replace or modify Tile Entities in the game.
1. **Tile Entity Transformation**: Replace or modify tile entities.
2. **Block Replacement**: Replace normal blocks with another normal block.
3. **ItemStack Replacement**: Modify or replace items.
@@ -12,7 +12,7 @@ This API provides a suite of tools for transforming blocks and items in the game
### 1. Tile Entity Transformation
#### a. We provide the registered TE ID "GT_TileEntity_Ores" and a lambda function that takes in the NBTTagCompound for any matching tile entity in world and a World and returns a BlockInfo. This will replace all TE's with the ID "GT_TileEntity_Ores" with the block specified in the BlockInfo. The secondary parameter determines the damage value of the block.
#### a. We provide the registered TE ID "GT_TileEntity_Ores" and a lambda function that takes in the NBTTagCompound for any matching tile entity in world and a World and returns a BlockInfo. This will replace all TE's with the ID "GT_TileEntity_Ores" with the block specified in the BlockInfo. The secondary parameter determines the damage value of the block. Returning null instead of a BlockInfo will leave the existing tile and block totally unchanged.
```java
TileEntityReplacementManager.tileEntityTransformer("GT_TileEntity_Ores", (tag, world) -> {
@@ -199,6 +199,11 @@ public class ChunkFixerUtility {
int z = tileEntity.getInteger("z");
BlockInfo blockInfo = transformationFunction.apply(tileEntity, world);
if (blockInfo == null) {
// Do nothing.
tileEntitiesCopy.appendTag(tileEntity);
continue;
}
if (blockInfo.tileTransformer != null) {
tileEntitiesCopy.appendTag(blockInfo.tileTransformer.apply(tileEntity));
@@ -206,6 +211,7 @@ public class ChunkFixerUtility {
conversionInfo.add(new ConversionInfo(x, y, z, blockInfo));
} else {
// Do nothing.
tileEntitiesCopy.appendTag(tileEntity);
}
}