Ported FMP Support to 1.7.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package appeng.integration.modules.dead;
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.Blocks;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.core.AELog;
|
||||
import appeng.fmp.CableBusPart;
|
||||
@@ -12,6 +16,7 @@ import appeng.fmp.FMPEvent;
|
||||
import appeng.fmp.PartRegistry;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.integration.modules.helpers.FMPPacketEvent;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
@@ -22,6 +27,7 @@ import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IFMP
|
||||
{
|
||||
@@ -39,20 +45,14 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConvert(int blockID)
|
||||
{
|
||||
return PartRegistry.isPart( Block.blocksList[blockID] );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TMultiPart convert(World world, BlockCoord pos)
|
||||
{
|
||||
int blockID = world.getBlockId( pos.x, pos.y, pos.z );
|
||||
Block blk = world.getBlock( pos.x, pos.y, pos.z );
|
||||
int meta = world.getBlockMetadata( pos.x, pos.y, pos.z );
|
||||
|
||||
TMultiPart part = PartRegistry.getPartByBlock( Block.blocksList[blockID], meta );
|
||||
TMultiPart part = PartRegistry.getPartByBlock( blk, meta );
|
||||
if ( part instanceof CableBusPart )
|
||||
{
|
||||
CableBusPart cbp = (CableBusPart) part;
|
||||
@@ -64,10 +64,14 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartz.block() );
|
||||
BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzPiller.block() );
|
||||
BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block() );
|
||||
{
|
||||
createAndRegister( AEApi.instance().blocks().blockQuartz.block(),0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockQuartzPiller.block(),0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block(),0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(),0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(),1 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(),2 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(),3 );
|
||||
|
||||
PartRegistry reg[] = PartRegistry.values();
|
||||
|
||||
@@ -81,6 +85,11 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" );
|
||||
}
|
||||
|
||||
private void createAndRegister(Block block, int i) {
|
||||
if ( block != null )
|
||||
BlockMicroMaterial.createAndRegister(block, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
@@ -94,7 +103,7 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
{
|
||||
BlockCoord loc = new BlockCoord( tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
|
||||
TileMultipart mp = TileMultipart.getOrConvertTile( tile.worldObj, loc );
|
||||
TileMultipart mp = TileMultipart.getOrConvertTile( tile.getWorldObj(), loc );
|
||||
if ( mp != null )
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
|
||||
@@ -107,7 +116,7 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
|
||||
TMultiPart part = PartRegistry.CableBusPart.construct( 0 );
|
||||
if ( mp.canAddPart( part ) && Platform.isServer() )
|
||||
TileMultipart.addPart( tile.worldObj, loc, part );
|
||||
TileMultipart.addPart( tile.getWorldObj(), loc, part );
|
||||
return (CableBusPart) part;
|
||||
}
|
||||
}
|
||||
@@ -149,4 +158,15 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event newFMPPacketEvent(EntityPlayerMP sender) {
|
||||
return new FMPPacketEvent(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Block> blockTypes() {
|
||||
Blocks def= AEApi.instance().blocks();
|
||||
return Arrays.asList( def.blockMultiPart.block(), def.blockQuartzTorch.block() );
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package appeng.integration.modules.helpers.dead;
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.event.Event;
|
||||
|
||||
public class FMPPacketEvent extends Event
|
||||
{
|
||||
Reference in New Issue
Block a user