-
Notifications
You must be signed in to change notification settings - Fork 79
/
LittleTiles.java
64 lines (54 loc) · 2.01 KB
/
LittleTiles.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package mod.chiselsandbits.integration.mods;
import java.lang.reflect.Method;
import jline.internal.Log;
import mod.chiselsandbits.chiseledblock.BlockChiseled;
import mod.chiselsandbits.chiseledblock.TileEntityBlockChiseled;
import mod.chiselsandbits.chiseledblock.data.VoxelBlob;
import mod.chiselsandbits.chiseledblock.data.VoxelBlob.BlobStats;
import mod.chiselsandbits.chiseledblock.data.VoxelBlobStateReference;
import mod.chiselsandbits.integration.ChiselsAndBitsIntegration;
import mod.chiselsandbits.integration.IntegrationBase;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
@ChiselsAndBitsIntegration( "littletilescore" )
public class LittleTiles extends IntegrationBase
{
static Class<?> clz = null;
static Method getVoxelBlob = null;
@Override
public void init()
{
try
{
clz = Class.forName( "com.creativemd.littletiles.common.api.te.ILittleTileTE" );
getVoxelBlob = clz.getMethod( "getVoxelBlob", boolean.class );
}
catch ( NoSuchMethodException | SecurityException | ClassNotFoundException e )
{
Log.info( "Little Tiles version is not new enough, or missing API : " + e.getMessage() );
}
}
public static BlockPos forceConvert = BlockPos.ORIGIN;
public static TileEntityBlockChiseled getConvertedTE(
TileEntity te,
boolean force ) throws Exception
{
if ( clz != null && getVoxelBlob != null && clz.isInstance( te ) )
{
VoxelBlob blob = (VoxelBlob) getVoxelBlob.invoke( te, force );
if ( blob != null )
{
TileEntityBlockChiseled cte = new TileEntityBlockChiseled();
// cte.setBlob( blob, false );
BlobStats stats = blob.getVoxelStats();
cte.setState( cte.getBasicState()
.withProperty( BlockChiseled.UProperty_VoxelBlob, new VoxelBlobStateReference( blob, TileEntityBlockChiseled.getPositionRandom( te.getPos() ) ) ) );
cte.setWorldObj( te.getWorld() );
cte.setPos( te.getPos() );
cte.occlusionState = new LittleTilesOccusionState( te.getWorld(), te.getPos(), cte );
return cte;
}
}
return null;
}
}