Ported FMP Support to 1.7.
This commit is contained in:
+24
-17
@@ -1,9 +1,8 @@
|
||||
package appeng.fmp;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -42,7 +41,6 @@ import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.lighting.LazyLightMatrix;
|
||||
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||
import codechicken.lib.vec.Cuboid6;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
@@ -107,14 +105,14 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream stream = new DataOutputStream( bytes );
|
||||
ByteBuf stream = Unpooled.buffer();
|
||||
|
||||
try
|
||||
{
|
||||
cb.writeToStream( stream );
|
||||
packet.writeInt( bytes.size() );
|
||||
packet.writeByteArray( bytes.toByteArray() );
|
||||
packet.writeInt( stream.readableBytes() );
|
||||
stream.capacity( stream.readableBytes() );
|
||||
packet.writeByteArray( stream.array() );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -129,11 +127,13 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
int len = packet.readInt();
|
||||
byte data[] = packet.readByteArray( len );
|
||||
|
||||
DataInputStream stream = new DataInputStream( new ByteArrayInputStream( data ) );
|
||||
|
||||
try
|
||||
{
|
||||
cb.readFromStream( stream );
|
||||
if ( len > 0 )
|
||||
{
|
||||
ByteBuf bybuff= Unpooled.wrappedBuffer(data);
|
||||
cb.readFromStream( bybuff );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -262,12 +262,14 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(Vector3 pos, LazyLightMatrix olm, int pass)
|
||||
public boolean renderStatic(Vector3 pos, int pass)
|
||||
{
|
||||
if ( pass == 0 )
|
||||
{
|
||||
cb.renderStatic( pos.x, pos.y, pos.z );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -425,8 +427,8 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if ( worldObj != null )
|
||||
worldObj.notifyBlocksOfNeighborChange( xCoord, yCoord, zCoord, Platform.air );
|
||||
if ( world() != null )
|
||||
world().notifyBlocksOfNeighborChange( x(), y(), z(), Platform.air );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -438,7 +440,8 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
this.getTile().markDirty();
|
||||
// mark the chunk for save...
|
||||
this.getTile().getWorldObj().getChunkFromBlockCoords( x(), z() ).isModified = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,7 +479,11 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
{
|
||||
cb.onInputsChanged( world, x, y, z, side, inputValues );
|
||||
}
|
||||
|
||||
|
||||
public void markDirty() {
|
||||
markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputChanged(World world, int x, int y, int z, ForgeDirection side, int inputValue)
|
||||
{
|
||||
|
||||
+10
-10
@@ -6,16 +6,16 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet15Place;
|
||||
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMultiPart;
|
||||
import appeng.integration.modules.helpers.FMPPacketEvent;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
@@ -24,7 +24,7 @@ import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
/**
|
||||
* Basically a total rip of of the FMP version for vanilla, seemed to work well enough...
|
||||
@@ -34,13 +34,13 @@ public class FMPEvent
|
||||
|
||||
private ThreadLocal<Object> placing = new ThreadLocal<Object>();
|
||||
|
||||
@ForgeSubscribe
|
||||
@SubscribeEvent
|
||||
public void ServerFMPEvent(FMPPacketEvent event)
|
||||
{
|
||||
FMPEvent.place( event.sender, event.sender.worldObj );
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
@SubscribeEvent
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
|
||||
@@ -72,7 +72,7 @@ public class FMPEvent
|
||||
if ( held.getItem() instanceof AEBaseItemBlock )
|
||||
{
|
||||
AEBaseItemBlock ib = (AEBaseItemBlock) held.getItem();
|
||||
blk = Block.blocksList[ib.getBlockID()];
|
||||
blk = Block.getBlockFromItem(ib);
|
||||
part = PartRegistry.getPartByBlock( blk, hit.sideHit );
|
||||
}
|
||||
|
||||
@@ -83,12 +83,12 @@ public class FMPEvent
|
||||
// the right stuff
|
||||
{
|
||||
Vector3 f = new Vector3( hit.hitVec ).add( -hit.blockX, -hit.blockY, -hit.blockZ );
|
||||
Block block = Block.blocksList[world.getBlockId( hit.blockX, hit.blockY, hit.blockZ )];
|
||||
Block block = world.getBlock( hit.blockX, hit.blockY, hit.blockZ );
|
||||
if ( block != null && !ignoreActivate( block )
|
||||
&& block.onBlockActivated( world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float) f.x, (float) f.y, (float) f.z ) )
|
||||
{
|
||||
player.swingItem();
|
||||
PacketCustom.sendToServer( new Packet15Place( hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float) f.x,
|
||||
PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement( hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float) f.x,
|
||||
(float) f.y, (float) f.z ) );
|
||||
return false;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class FMPEvent
|
||||
if ( !world.isRemote )
|
||||
{
|
||||
TileMultipart.addPart( world, pos, part );
|
||||
world.playSoundEffect( pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, blk.stepSound.getPlaceSound(), (blk.stepSound.getVolume() + 1.0F) / 2.0F,
|
||||
world.playSoundEffect( pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, blk.stepSound.func_150496_b(), (blk.stepSound.getVolume() + 1.0F) / 2.0F,
|
||||
blk.stepSound.getPitch() * 0.8F );
|
||||
if ( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
@@ -118,7 +118,7 @@ public class FMPEvent
|
||||
player.swingItem();
|
||||
try
|
||||
{
|
||||
PacketDispatcher.sendPacketToServer( (new PacketMultiPart()).getPacket() );
|
||||
NetworkHandler.instance.sendToServer( new PacketMultiPart() );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTi
|
||||
public static McBlockPart placement(World world, BlockCoord pos, int side)
|
||||
{
|
||||
pos = pos.copy().offset( side );
|
||||
if ( !world.isBlockSolidOnSide( pos.x, pos.y, pos.z, ForgeDirection.getOrientation( side ) ) )
|
||||
if ( !world.isSideSolid( pos.x, pos.y, pos.z, ForgeDirection.getOrientation( side ) ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user