Packets
This commit is contained in:
@@ -34,6 +34,7 @@ import appeng.api.parts.CableRenderMode;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
|
||||
public abstract class CommonHelper
|
||||
@@ -47,7 +48,7 @@ public abstract class CommonHelper
|
||||
|
||||
public abstract List<? extends PlayerEntity> getPlayers();
|
||||
|
||||
// FIXME public abstract void sendToAllNearExcept( PlayerEntity p, double x, double y, double z, double dist, World w, AppEngPacket packet );
|
||||
public abstract void sendToAllNearExcept( PlayerEntity p, double x, double y, double z, double dist, World w, AppEngPacket packet );
|
||||
|
||||
public abstract void spawnEffect( EffectType effect, World world, double posX, double posY, double posZ, Object extra );
|
||||
|
||||
|
||||
@@ -20,14 +20,15 @@ package appeng.core.sync;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
@@ -36,12 +37,11 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
|
||||
|
||||
public abstract class AppEngPacket implements IPacket
|
||||
public abstract class AppEngPacket
|
||||
{
|
||||
private PacketBuffer p;
|
||||
private PacketCallState caller;
|
||||
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public abstract class AppEngPacket implements IPacket
|
||||
return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
|
||||
}
|
||||
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
@@ -62,33 +62,19 @@ public abstract class AppEngPacket implements IPacket
|
||||
this.p = new PacketBuffer( data );
|
||||
}
|
||||
|
||||
public FMLProxyPacket getProxy()
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
{
|
||||
if( this.p.array().length > 2 * 1024 * 1024 ) // 2k walking room :)
|
||||
{
|
||||
throw new IllegalArgumentException( "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!" );
|
||||
}
|
||||
|
||||
final FMLProxyPacket pp = new FMLProxyPacket( this.p, NetworkHandler.instance().getChannel() );
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.PACKET_LOGGING ) )
|
||||
{
|
||||
AELog.info( this.getClass().getName() + " : " + pp.payload().readableBytes() );
|
||||
AELog.info( this.getClass().getName() + " : " + p.readableBytes() );
|
||||
}
|
||||
|
||||
return pp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketData( final PacketBuffer buf ) throws IOException
|
||||
{
|
||||
throw new RuntimeException( "Not Implemented" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketData( final PacketBuffer buf ) throws IOException
|
||||
{
|
||||
throw new RuntimeException( "Not Implemented" );
|
||||
return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
|
||||
}
|
||||
|
||||
// TODO: Figure out why Forge/Minecraft on the server sets the stream data buffer to PooledUnsafeDirectByteBuf
|
||||
@@ -113,16 +99,4 @@ public abstract class AppEngPacket implements IPacket
|
||||
{
|
||||
return this.getPacketByteArray( stream, 0, stream.readableBytes() );
|
||||
}
|
||||
|
||||
public void setCallParam( final PacketCallState call )
|
||||
{
|
||||
this.caller = call;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket( final INetHandler handler )
|
||||
{
|
||||
this.caller.call( this );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
public abstract class PacketCallState
|
||||
{
|
||||
|
||||
public abstract void call( AppEngPacket appEngPacket );
|
||||
|
||||
}
|
||||
@@ -21,60 +21,29 @@ package appeng.core.sync.network;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.PacketThreadUtil;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
import appeng.core.sync.PacketCallState;
|
||||
|
||||
|
||||
public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData( final INetworkInfo manager, final INetHandler handler, final FMLProxyPacket packet, final PlayerEntity player )
|
||||
public void onPacketData( final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, final PlayerEntity player )
|
||||
{
|
||||
final ByteBuf stream = packet.payload();
|
||||
|
||||
try
|
||||
{
|
||||
final int packetType = stream.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
|
||||
|
||||
final PacketCallState callState = new PacketCallState()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void call( final AppEngPacket appEngPacket )
|
||||
{
|
||||
appEngPacket.clientPacketData( manager, appEngPacket, Minecraft.getInstance().player );
|
||||
}
|
||||
};
|
||||
|
||||
pack.setCallParam( callState );
|
||||
PacketThreadUtil.checkThreadAndEnqueue( pack, handler, Minecraft.getInstance() );
|
||||
callState.call( pack );
|
||||
final int packetType = packet.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet );
|
||||
pack.clientPacketData( manager, Minecraft.getInstance().player );
|
||||
}
|
||||
catch( final InstantiationException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
catch( final InstantiationException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
@@ -21,60 +21,28 @@ package appeng.core.sync.network;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.PacketThreadUtil;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
import appeng.core.sync.PacketCallState;
|
||||
|
||||
|
||||
public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData( final INetworkInfo manager, final INetHandler handler, final FMLProxyPacket packet, final PlayerEntity player )
|
||||
public void onPacketData( final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, final PlayerEntity player )
|
||||
{
|
||||
final ByteBuf stream = packet.payload();
|
||||
|
||||
try
|
||||
{
|
||||
final int packetType = stream.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
|
||||
|
||||
final PacketCallState callState = new PacketCallState()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void call( final AppEngPacket appEngPacket )
|
||||
{
|
||||
appEngPacket.serverPacketData( manager, appEngPacket, player );
|
||||
}
|
||||
};
|
||||
|
||||
pack.setCallParam( callState );
|
||||
PacketThreadUtil.checkThreadAndEnqueue( pack, handler, ( (PlayerEntityMP) player ).getServer() );
|
||||
callState.call( pack );
|
||||
final int packetType = packet.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet );
|
||||
pack.serverPacketData( manager, player );
|
||||
}
|
||||
catch( final InstantiationException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
catch( final InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.PacketDispatcher;
|
||||
|
||||
@@ -27,6 +28,6 @@ import net.minecraftforge.fml.network.PacketDispatcher;
|
||||
public interface IPacketHandler
|
||||
{
|
||||
|
||||
void onPacketData(INetworkInfo manager, PacketDispatcher dispatcher, PacketBuffer packet, PlayerEntity player );
|
||||
void onPacketData(INetworkInfo manager, INetHandler handler, PacketBuffer packet, PlayerEntity player );
|
||||
|
||||
}
|
||||
|
||||
@@ -19,15 +19,22 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.ThreadQuickExitException;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLEventChannel;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraft.network.play.ServerPlayNetHandler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.event.EventNetworkChannel;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
@@ -36,23 +43,22 @@ public class NetworkHandler
|
||||
{
|
||||
private static NetworkHandler instance;
|
||||
|
||||
private final FMLEventChannel ec;
|
||||
private final String myChannelName;
|
||||
private final EventNetworkChannel ec;
|
||||
private final ResourceLocation myChannelName;
|
||||
|
||||
private final IPacketHandler clientHandler;
|
||||
private final IPacketHandler serveHandler;
|
||||
|
||||
public NetworkHandler( final String channelName )
|
||||
public NetworkHandler( final ResourceLocation channelName )
|
||||
{
|
||||
FMLCommonHandler.instance().bus().register( this );
|
||||
this.ec = NetworkRegistry.INSTANCE.newEventDrivenChannel( this.myChannelName = channelName );
|
||||
this.ec.register( this );
|
||||
ec = NetworkRegistry.ChannelBuilder.named( myChannelName = channelName ).networkProtocolVersion( () -> "1" ).clientAcceptedVersions( s -> true ).serverAcceptedVersions( s -> true ).eventNetworkChannel();
|
||||
ec.registerObject( this );
|
||||
|
||||
this.clientHandler = this.createClientSide();
|
||||
this.serveHandler = this.createServerSide();
|
||||
}
|
||||
|
||||
public static void init( final String channelName )
|
||||
public static void init( final ResourceLocation channelName )
|
||||
{
|
||||
instance = new NetworkHandler( channelName );
|
||||
}
|
||||
@@ -87,14 +93,17 @@ public class NetworkHandler
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket( final ServerCustomPacketEvent ev )
|
||||
public void serverPacket( final NetworkEvent.ClientCustomPayloadEvent ev )
|
||||
{
|
||||
final NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.getPacket().handler();
|
||||
if( this.serveHandler != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.serveHandler.onPacketData( null, ev.getHandler(), ev.getPacket(), srv.player );
|
||||
NetworkEvent.Context ctx = ev.getSource().get();
|
||||
ServerPlayNetHandler netHandler = (ServerPlayNetHandler) ctx.getNetworkManager().getNetHandler();
|
||||
ctx.setPacketHandled( true );
|
||||
ctx.enqueueWork( () -> this.serveHandler.onPacketData( null, netHandler, ev.getPayload(), netHandler.player ) );
|
||||
|
||||
}
|
||||
catch( final ThreadQuickExitException ignored )
|
||||
{
|
||||
@@ -104,13 +113,20 @@ public class NetworkHandler
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientPacket( final ClientCustomPacketEvent ev )
|
||||
public void clientPacket( final NetworkEvent.ServerCustomPayloadEvent ev )
|
||||
{
|
||||
if( ev instanceof NetworkEvent.ServerCustomPayloadLoginEvent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( this.clientHandler != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.clientHandler.onPacketData( null, ev.getHandler(), ev.getPacket(), null );
|
||||
NetworkEvent.Context ctx = ev.getSource().get();
|
||||
INetHandler netHandler = ctx.getNetworkManager().getNetHandler();
|
||||
ctx.setPacketHandled( true );
|
||||
ctx.enqueueWork( () -> this.clientHandler.onPacketData( null, netHandler, ev.getPayload(), null ) );
|
||||
}
|
||||
catch( final ThreadQuickExitException ignored )
|
||||
{
|
||||
@@ -119,33 +135,39 @@ public class NetworkHandler
|
||||
}
|
||||
}
|
||||
|
||||
public String getChannel()
|
||||
public ResourceLocation getChannel()
|
||||
{
|
||||
return this.myChannelName;
|
||||
}
|
||||
|
||||
public void sendToAll( final AppEngPacket message )
|
||||
{
|
||||
this.ec.sendToAll( message.getProxy() );
|
||||
getServer().getPlayerList().sendPacketToAllPlayers( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ) );
|
||||
}
|
||||
|
||||
public void sendTo( final AppEngPacket message, final PlayerEntityMP player )
|
||||
public void sendTo( final AppEngPacket message, final ServerPlayerEntity player )
|
||||
{
|
||||
this.ec.sendTo( message.getProxy(), player );
|
||||
player.connection.sendPacket( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ) );
|
||||
}
|
||||
|
||||
public void sendToAllAround( final AppEngPacket message, final NetworkRegistry.TargetPoint point )
|
||||
public void sendToAllAround( final AppEngPacket message, final TargetPoint point )
|
||||
{
|
||||
this.ec.sendToAllAround( message.getProxy(), point );
|
||||
IPacket<?> pkt = message.toPacket( NetworkDirection.PLAY_TO_CLIENT );
|
||||
getServer().getPlayerList().sendToAllNearExcept( point.excluded, point.x, point.y, point.z, point.r2, point.dim, pkt);
|
||||
}
|
||||
|
||||
public void sendToDimension( final AppEngPacket message, final int dimensionId )
|
||||
public void sendToDimension( final AppEngPacket message, final DimensionType dim )
|
||||
{
|
||||
this.ec.sendToDimension( message.getProxy(), dimensionId );
|
||||
getServer().getPlayerList().sendPacketToAllPlayersInDimension( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ), dim );
|
||||
}
|
||||
|
||||
public void sendToServer( final AppEngPacket message )
|
||||
{
|
||||
this.ec.sendToServer( message.getProxy() );
|
||||
Minecraft.getInstance().getConnection().sendPacket( message.toPacket( NetworkDirection.PLAY_TO_SERVER ) );
|
||||
}
|
||||
|
||||
private MinecraftServer getServer()
|
||||
{
|
||||
return LogicalSidedProvider.INSTANCE.get( LogicalSide.SERVER );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
|
||||
/**
|
||||
* Created by covers1624 on 1/6/20.
|
||||
*/
|
||||
public class TargetPoint
|
||||
{
|
||||
|
||||
public final ServerPlayerEntity excluded;
|
||||
public final double x;
|
||||
public final double y;
|
||||
public final double z;
|
||||
public final double r2;
|
||||
public final DimensionType dim;
|
||||
|
||||
public TargetPoint( double x, double y, double z, double r2, DimensionType dim )
|
||||
{
|
||||
this( null, x, y, z, r2, dim );
|
||||
}
|
||||
|
||||
public TargetPoint( ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim )
|
||||
{
|
||||
this.excluded = excluded;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.r2 = r2;
|
||||
this.dim = dim;
|
||||
}
|
||||
|
||||
|
||||
public static TargetPoint at(double x, double y, double z, double r2, DimensionType dim) {
|
||||
return new TargetPoint( x, y, z, r2, dim );
|
||||
}
|
||||
|
||||
public static TargetPoint at(ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim) {
|
||||
return new TargetPoint( excluded, x, y, z, r2, dim );
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
final double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
|
||||
@@ -30,12 +30,12 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
@@ -110,7 +110,7 @@ public class PacketClick extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final ItemStack is = player.inventory.getCurrentItem();
|
||||
final IItems items = Api.INSTANCE.definitions().items();
|
||||
@@ -140,7 +140,7 @@ public class PacketClick extends AppEngPacket
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
is.setTag( null );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
this.talkBackTo = player;
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
CompassManager.INSTANCE.postResult( this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class PacketConfigButton extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP sender = (PlayerEntityMP) player;
|
||||
if( sender.openContainer instanceof AEBaseContainer )
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PacketFluidSlot extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof IFluidSyncContainer )
|
||||
@@ -84,7 +84,7 @@ public class PacketFluidSlot extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, PlayerEntity player )
|
||||
public void serverPacketData( INetworkInfo manager, PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof IFluidSyncContainer )
|
||||
|
||||
@@ -121,7 +121,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP sender = (PlayerEntityMP) player;
|
||||
if( sender.openContainer instanceof AEBaseContainer )
|
||||
@@ -158,7 +158,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
if( this.action == InventoryAction.UPDATE_HAND )
|
||||
{
|
||||
|
||||
@@ -36,7 +36,6 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -106,7 +105,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP pmp = (PlayerEntityMP) player;
|
||||
final Container con = pmp.openContainer;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PacketLightning extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -35,10 +35,13 @@ 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.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.AELog;
|
||||
@@ -149,9 +152,9 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getInstance().currentScreen;
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
if( gs instanceof GuiFluidTerminal )
|
||||
{
|
||||
@@ -161,14 +164,14 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FMLProxyPacket getProxy()
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.compressFrame.close();
|
||||
|
||||
this.configureWrite( this.data );
|
||||
return super.getProxy();
|
||||
return super.toPacket( direction );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
|
||||
@@ -36,9 +36,11 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
@@ -147,7 +149,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
@@ -174,14 +176,14 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FMLProxyPacket getProxy()
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.compressFrame.close();
|
||||
|
||||
this.configureWrite( this.data );
|
||||
return super.getProxy();
|
||||
return super.toPacket( direction );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
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] );
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PacketPaintedEntity extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final PlayerColor pc = new PlayerColor( this.entityId, this.myColor, this.ticks );
|
||||
TickHandler.INSTANCE.getPlayerColors().put( this.entityId, pc );
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP sender = (PlayerEntityMP) player;
|
||||
AppEng.proxy.updateRenderMode( sender );
|
||||
|
||||
@@ -28,7 +28,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
@@ -109,7 +108,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP sender = (PlayerEntityMP) player;
|
||||
if( sender.openContainer instanceof ContainerPatternTerm )
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PacketProgressBar extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
@@ -69,7 +69,7 @@ public class PacketProgressBar extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PacketSwapSlots extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player != null && player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
|
||||
@@ -84,7 +84,7 @@ public class PacketTargetFluidStack extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player.openContainer instanceof ContainerFluidTerminal )
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PacketTargetItemStack extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PacketValueConfig extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
|
||||
@@ -270,7 +270,7 @@ public class PacketValueConfig extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final PlayerEntity player )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
|
||||
|
||||
@@ -25,22 +25,23 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
|
||||
public class ServerHelper extends CommonHelper
|
||||
@@ -82,31 +83,28 @@ public class ServerHelper extends CommonHelper
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// FIXME @Override
|
||||
// FIXME public void sendToAllNearExcept(final PlayerEntity p, final double x, final double y, final double z, final double dist, final World w, final AppEngPacket packet )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.isClient() )
|
||||
// FIXME {
|
||||
// FIXME return;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME for( final PlayerEntity o : this.getPlayers() )
|
||||
// FIXME {
|
||||
// FIXME final ServerPlayerEntity entityplayermp = (ServerPlayerEntity) o;
|
||||
// FIXME
|
||||
// FIXME if( entityplayermp != p && entityplayermp.world == w )
|
||||
// FIXME {
|
||||
// FIXME final double dX = x - entityplayermp.getPosX();
|
||||
// FIXME final double dY = y - entityplayermp.getPosY();
|
||||
// FIXME final double dZ = z - entityplayermp.getPosZ();
|
||||
// FIXME
|
||||
// FIXME if( dX * dX + dY * dY + dZ * dZ < dist * dist )
|
||||
// FIXME {
|
||||
// FIXME NetworkHandler.instance().sendTo( packet, entityplayermp );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
@Override
|
||||
public void sendToAllNearExcept( final PlayerEntity p, final double x, final double y, final double z, final double dist, final World w, final AppEngPacket packet )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
for( final PlayerEntity o : this.getPlayers() )
|
||||
{
|
||||
final ServerPlayerEntity entityplayermp = (ServerPlayerEntity) o;
|
||||
if( entityplayermp != p && entityplayermp.world == w )
|
||||
{
|
||||
final double dX = x - entityplayermp.getPosX();
|
||||
final double dY = y - entityplayermp.getPosY();
|
||||
final double dZ = z - entityplayermp.getPosZ();
|
||||
if( dX * dX + dY * dY + dZ * dZ < dist * dist )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( packet, entityplayermp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnEffect( final EffectType type, final World world, final double posX, final double posY, final double posZ, final Object o )
|
||||
|
||||
Reference in New Issue
Block a user