Move from ByteBuf to PacketBuffer
This commit is contained in:
@@ -27,11 +27,9 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ClassToInstanceMap;
|
||||
import com.google.common.collect.MutableClassToInstanceMap;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
@@ -162,7 +160,7 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack readFromPacket( ByteBuf input ) throws IOException
|
||||
public IAEItemStack readFromPacket( PacketBuffer input ) throws IOException
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
|
||||
@@ -209,7 +207,7 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ) );
|
||||
return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ).orElse( null ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +215,7 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack readFromPacket( ByteBuf input ) throws IOException
|
||||
public IAEFluidStack readFromPacket( PacketBuffer input ) throws IOException
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
|
||||
|
||||
@@ -19,12 +19,8 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -56,10 +52,10 @@ public abstract class AppEngPacket
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
|
||||
protected void configureWrite( final ByteBuf data )
|
||||
protected void configureWrite( final PacketBuffer data )
|
||||
{
|
||||
data.capacity( data.readableBytes() );
|
||||
this.p = new PacketBuffer( data );
|
||||
this.p = data;
|
||||
}
|
||||
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
@@ -77,27 +73,4 @@ public abstract class AppEngPacket
|
||||
// FIXME return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Figure out why Forge/Minecraft on the server sets the stream data buffer to PooledUnsafeDirectByteBuf
|
||||
|
||||
public ByteArrayInputStream getPacketByteArray( ByteBuf stream, int readerIndex, int readableBytes )
|
||||
{
|
||||
final ByteArrayInputStream bytes;
|
||||
if( stream.hasArray() )
|
||||
{
|
||||
bytes = new ByteArrayInputStream( stream.array(), readerIndex, readableBytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] data = new byte[stream.capacity()];
|
||||
stream.getBytes( readerIndex, data, 0, readableBytes );
|
||||
bytes = new ByteArrayInputStream( data );
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public ByteArrayInputStream getPacketByteArray( ByteBuf stream )
|
||||
{
|
||||
return this.getPacketByteArray( stream, 0, stream.readableBytes() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -47,7 +46,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
public final byte rate;
|
||||
public final IAEItemStack is;
|
||||
|
||||
public PacketAssemblerAnimation( final ByteBuf stream )
|
||||
public PacketAssemblerAnimation( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -82,7 +81,7 @@ public class PacketClick extends AppEngPacket
|
||||
public PacketClick( final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand, boolean leftClick )
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.x = pos.getX() );
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -55,7 +54,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
public PacketCompassRequest( final long attunement, final int cx, final int cz, final int cdy )
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeLong( this.attunement = attunement );
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -55,7 +54,7 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
public PacketCompassResponse( final PacketCompassRequest req, final boolean hasResult, final boolean spin, final double radians )
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new ( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeLong( this.attunement = req.attunement );
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -50,7 +49,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
// input.
|
||||
private final CompoundNBT in;
|
||||
// output...
|
||||
private final ByteBuf data;
|
||||
private final PacketBuffer data;
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
public PacketCompressedNBT( final PacketBuffer stream )
|
||||
@@ -85,7 +84,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
public PacketCompressedNBT( final CompoundNBT din ) throws IOException
|
||||
{
|
||||
|
||||
this.data = Unpooled.buffer( 2048 );
|
||||
this.data = new PacketBuffer( Unpooled.buffer( 2048 ) );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
|
||||
this.in = din;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -51,7 +50,7 @@ public final class PacketConfigButton extends AppEngPacket
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( option.ordinal() );
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -34,6 +33,8 @@ import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -58,7 +59,7 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeBoolean( shift );
|
||||
|
||||
@@ -22,14 +22,12 @@ package appeng.core.sync.packets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -45,11 +43,11 @@ public class PacketFluidSlot extends AppEngPacket
|
||||
public PacketFluidSlot( final PacketBuffer stream )
|
||||
{
|
||||
this.list = new HashMap<>();
|
||||
CompoundNBT tag = ByteBufUtils.readTag( stream );
|
||||
CompoundNBT tag = stream.readCompoundTag();
|
||||
|
||||
for( final String key : tag.getKeySet() )
|
||||
for( final String key : tag.keySet() )
|
||||
{
|
||||
this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompoundTag( key ) ) );
|
||||
this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompound( key ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,12 +63,12 @@ public class PacketFluidSlot extends AppEngPacket
|
||||
{
|
||||
fs.getValue().writeToNBT( tag );
|
||||
}
|
||||
sendTag.setTag( fs.getKey().toString(), tag );
|
||||
sendTag.put( fs.getKey().toString(), tag );
|
||||
}
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt( this.getPacketID() );
|
||||
ByteBufUtils.writeTag( data, sendTag );
|
||||
data.writeCompoundTag( sendTag );
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -81,7 +80,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
this.id = 0;
|
||||
this.slotItem = slotItem;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
@@ -109,7 +108,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
|
||||
@@ -19,19 +19,14 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -48,6 +43,7 @@ import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
@@ -73,13 +69,13 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
this.recipe = new ItemStack[9][];
|
||||
for( int x = 0; x < this.recipe.length; x++ )
|
||||
{
|
||||
final ListNBT list = comp.getTagList( "#" + x, 10 );
|
||||
if( list.tagCount() > 0 )
|
||||
final ListNBT list = comp.getList( "#" + x, 10 );
|
||||
if( list.size() > 0 )
|
||||
{
|
||||
this.recipe[x] = new ItemStack[list.tagCount()];
|
||||
for( int y = 0; y < list.tagCount(); y++ )
|
||||
this.recipe[x] = new ItemStack[list.size()];
|
||||
for( int y = 0; y < list.size(); y++ )
|
||||
{
|
||||
this.recipe[x][y] = new ItemStack( list.getCompoundTagAt( y ) );
|
||||
this.recipe[x][y] = ItemStack.read( list.getCompound( y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -30,7 +29,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
@@ -57,7 +55,7 @@ public class PacketLightning extends AppEngPacket
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
@@ -75,8 +73,7 @@ public class PacketLightning extends AppEngPacket
|
||||
{
|
||||
if( Platform.isClient() && AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
final LightningFX fx = new LightningFX( AppEng.proxy.getWorld(), this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getInstance().effectRenderer.addEffect( fx );
|
||||
Minecraft.getInstance().world.addParticle( LightningFX.TYPE, this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
}
|
||||
catch( final Exception ignored )
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -68,7 +67,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
private final byte ref;
|
||||
|
||||
@Nullable
|
||||
private final ByteBuf data;
|
||||
private final PacketBuffer data;
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
@@ -99,7 +98,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
} ) )
|
||||
{
|
||||
|
||||
final ByteBuf uncompressed = Unpooled.buffer( stream.readableBytes() );
|
||||
final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) );
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
|
||||
while( gzReader.available() != 0 )
|
||||
@@ -135,7 +134,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
public PacketMEFluidInventoryUpdate( final byte ref ) throws IOException
|
||||
{
|
||||
this.ref = ref;
|
||||
this.data = Unpooled.buffer( OPERATION_BYTE_LIMIT );
|
||||
this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
this.data.writeByte( this.ref );
|
||||
|
||||
|
||||
@@ -29,11 +29,10 @@ import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -66,7 +65,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
private final byte ref;
|
||||
|
||||
@Nullable
|
||||
private final ByteBuf data;
|
||||
private final PacketBuffer data;
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
@@ -96,7 +95,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
}
|
||||
} ) )
|
||||
{
|
||||
final ByteBuf uncompressed = Unpooled.buffer( stream.readableBytes() );
|
||||
final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) );
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
|
||||
while( gzReader.available() != 0 )
|
||||
@@ -132,7 +131,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
public PacketMEInventoryUpdate( final byte ref ) throws IOException
|
||||
{
|
||||
this.ref = ref;
|
||||
this.data = Unpooled.buffer( OPERATION_BYTE_LIMIT );
|
||||
this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
this.data.writeByte( this.ref );
|
||||
|
||||
@@ -152,7 +151,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getInstance().currentScreen;
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
if( gs instanceof GuiCraftConfirm )
|
||||
{
|
||||
@@ -196,7 +195,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
|
||||
public void appendItem( final IAEItemStack is ) throws IOException, BufferOverflowException
|
||||
{
|
||||
final ByteBuf tmp = Unpooled.buffer( OPERATION_BYTE_LIMIT );
|
||||
final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
is.writeToPacket( tmp );
|
||||
|
||||
this.compressFrame.flush();
|
||||
|
||||
@@ -19,15 +19,14 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -72,7 +71,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
this.dz = dz / dlz;
|
||||
this.len = len;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
@@ -93,12 +92,12 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
try
|
||||
{
|
||||
|
||||
final World world = FMLClientHandler.instance().getClient().world;
|
||||
final World world = Minecraft.getInstance().world;
|
||||
for( int a = 1; a < this.len; a++ )
|
||||
{
|
||||
final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, Items.DIAMOND );
|
||||
final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, new ItemStack( Items.DIAMOND ) );
|
||||
|
||||
Minecraft.getInstance().effectRenderer.addEffect( fx );
|
||||
Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
}
|
||||
catch( final Exception ignored )
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -55,7 +54,7 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeDouble( x );
|
||||
@@ -70,6 +69,6 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
world.spawnParticle( EnumParticleTypes.EXPLOSION_LARGE, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D, new int[0] );
|
||||
world.addParticle( ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -50,7 +49,7 @@ public class PacketPaintedEntity extends AppEngPacket
|
||||
public PacketPaintedEntity( final int myEntity, final AEColor myColor, final int ticksLeft )
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.entityId = myEntity );
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -58,7 +57,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
// api
|
||||
public PacketPartPlacement( final BlockPos pos, final Direction face, final float eyeHeight, final Hand hand )
|
||||
{
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( pos.getX() );
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -32,6 +31,7 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -59,7 +59,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack readItem( final ByteBuf stream )
|
||||
private IAEItemStack readItem( final PacketBuffer stream )
|
||||
{
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
this.slotItem = slotItem;
|
||||
this.shift = shift;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
@@ -94,7 +94,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
private void writeItem( final IAEItemStack slotItem, final ByteBuf data ) throws IOException
|
||||
private void writeItem( final IAEItemStack slotItem, final PacketBuffer data ) throws IOException
|
||||
{
|
||||
if( slotItem == null )
|
||||
{
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -49,7 +48,7 @@ public class PacketProgressBar extends AppEngPacket
|
||||
this.id = (short) shortID;
|
||||
this.value = value;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeShort( shortID );
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -45,7 +44,7 @@ public class PacketSwapSlots extends AppEngPacket
|
||||
// api
|
||||
public PacketSwapSlots( final int slotA, final int slotB )
|
||||
{
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.slotA = slotA );
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
{
|
||||
this.newGui = newGui;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( newGui.ordinal() );
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -67,7 +66,7 @@ public class PacketTargetFluidStack extends AppEngPacket
|
||||
|
||||
this.stack = stack;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt( this.getPacketID() );
|
||||
if( stack != null )
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -62,7 +61,7 @@ public class PacketTargetItemStack extends AppEngPacket
|
||||
|
||||
this.stack = stack;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt( this.getPacketID() );
|
||||
if( stack != null )
|
||||
{
|
||||
@@ -86,5 +85,4 @@ public class PacketTargetItemStack extends AppEngPacket
|
||||
( (AEBaseContainer) player.openContainer ).setTargetStack( this.stack );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.audio.SimpleSound;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -69,7 +69,7 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
this.d = dir;
|
||||
this.mode = wasBlock;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
@@ -105,18 +105,20 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
fx.setMotionY( -0.1f * this.d.yOffset );
|
||||
fx.setMotionZ( -0.1f * this.d.zOffset );
|
||||
|
||||
Minecraft.getInstance().effectRenderer.addEffect( fx );
|
||||
Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
}
|
||||
|
||||
if( this.mode )
|
||||
{
|
||||
final Block block = world.getBlockState( new BlockPos( (int) this.x, (int) this.y, (int) this.z ) ).getBlock();
|
||||
final BlockPos pos = new BlockPos( (int) this.x, (int) this.y, (int) this.z );
|
||||
final BlockState state = world.getBlockState( pos );
|
||||
final SoundType sound = state.getSoundType( world, pos, null );
|
||||
|
||||
Minecraft.getInstance()
|
||||
.getSoundHandler()
|
||||
.playSound( new PositionedSoundRecord( block.getSoundType()
|
||||
.getBreakSound(), SoundCategory.BLOCKS, ( block.getSoundType().getVolume() + 1.0F ) / 2.0F, block.getSoundType()
|
||||
.play( new SimpleSound( sound
|
||||
.getBreakSound(), SoundCategory.BLOCKS, ( sound.getVolume() + 1.0F ) / 2.0F, sound
|
||||
.getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user