Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e79d39
commit 87af63c
Showing
4 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/mod/chiselsandbits/integration/mods/LittleTiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/mod/chiselsandbits/integration/mods/LittleTilesOccusionState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package mod.chiselsandbits.integration.mods; | ||
|
||
import mod.chiselsandbits.chiseledblock.TileEntityBlockChiseled; | ||
import mod.chiselsandbits.chiseledblock.data.VoxelBlob; | ||
import mod.chiselsandbits.helpers.ModUtil; | ||
import mod.chiselsandbits.interfaces.IChiseledTileContainer; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
public class LittleTilesOccusionState implements IChiseledTileContainer | ||
{ | ||
|
||
final TileEntityBlockChiseled container; | ||
final World world; | ||
final BlockPos pos; | ||
|
||
public LittleTilesOccusionState( | ||
final World w, | ||
final BlockPos position, | ||
final TileEntityBlockChiseled chisledBlockPart ) | ||
{ | ||
world = w; | ||
pos = position; | ||
container = chisledBlockPart; | ||
} | ||
|
||
@Override | ||
public void sendUpdate() | ||
{ | ||
ModUtil.sendUpdate( world, pos ); | ||
} | ||
|
||
@Override | ||
public void saveData() | ||
{ | ||
world.setBlockState( pos, container.getPreferedBlock() ); | ||
TileEntity te = world.getTileEntity( pos ); | ||
|
||
if ( te instanceof TileEntityBlockChiseled ) | ||
( (TileEntityBlockChiseled) te ).copyFrom( container ); | ||
} | ||
|
||
@Override | ||
public boolean isBlobOccluded( | ||
final VoxelBlob blob ) | ||
{ | ||
return false; | ||
} | ||
|
||
} |