mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-28 16:06:17 +00:00
feat: add named Java tile conversion result
This commit is contained in:
1 parent
7396f2d814
commit
fbef5d4653
11 files changed
+243
-23
No files matched your search
@@ -776,18 +776,46 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile {
|
||||
renderID = value;
|
||||
}
|
||||
|
||||
/** Gets a multipart tile instance at pos, converting if necessary. */
|
||||
/**
|
||||
* Gets an existing tile or converted placeholder, or null. Conversion does not install the tile in the world. Use
|
||||
* {@link #getOrConvertTileResult(World, BlockCoord)} when the conversion flag is also needed.
|
||||
*/
|
||||
public static TileMultipart getOrConvertTile(World world, BlockCoord pos) {
|
||||
return getOrConvertTile2(world, pos)._1();
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up an existing tile, otherwise asks registered block converters for a multipart representation. An existing
|
||||
* tile is returned by identity with {@link TileConversionResult#isConverted()} false. A successful conversion
|
||||
* returns a fresh, uninstalled placeholder with the flag true; no match returns a null tile and false.
|
||||
*
|
||||
* <p>
|
||||
* A placeholder uses the world's client/server side and has its coordinates, world and converted part bound. This
|
||||
* lookup does not replace the block, install the tile or invoke the part's placement/conversion callbacks. Repeated
|
||||
* lookups can construct different placeholders. Converter callbacks run normally and their exceptions propagate;
|
||||
* this is not a side-effect-free query. Use on the appropriate world thread after FMP initialization.
|
||||
*
|
||||
* <p>
|
||||
* For ordinary placement, use {@link #canPlacePart(World, BlockCoord, TMultiPart)} followed by
|
||||
* {@link #addPart(World, BlockCoord, TMultiPart)} and retain the tile returned by the addition. Do not install this
|
||||
* placeholder directly. Use {@link #getTile(World, BlockCoord)} if conversion should not be attempted.
|
||||
*
|
||||
* @return a non-null result recording this lookup; its tile reference may be null
|
||||
*/
|
||||
public static TileConversionResult getOrConvertTileResult(World world, BlockCoord pos) {
|
||||
Tuple2<TileMultipart, Object> result = getOrConvertTile2(world, pos);
|
||||
return new TileConversionResult(result._1(), (Boolean) result._2());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a multipart tile instance at pos, converting if necessary. Note converted tiles are merely a structure
|
||||
* formality, they do not actually exist in world until they are required to by the addition of another multipart to
|
||||
* their space.
|
||||
*
|
||||
* @return the tile or null if there was none, and true if the tile is a result of a conversion
|
||||
* @deprecated Use {@link #getOrConvertTileResult(World, BlockCoord)} for a Java result with named accessors.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Tuple2<TileMultipart, Object> getOrConvertTile2(World world, BlockCoord pos) {
|
||||
TileEntity t = world.getTileEntity(pos.x, pos.y, pos.z);
|
||||
if (t instanceof TileMultipart) {
|
||||
|
||||
Reference in new issue
Block a user