Search in sources :

Example 1 with NetworkManager

use of v1_8_9.net.minecraft.network.NetworkManager in project MinecraftForge by MinecraftForge.

the class ChannelRegistrationHandler method channelRead0.

@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception {
    Side side = msg.getTarget();
    NetworkManager manager = msg.getOrigin();
    if (msg.channel().equals("REGISTER") || msg.channel().equals("UNREGISTER")) {
        byte[] data = new byte[msg.payload().readableBytes()];
        msg.payload().readBytes(data);
        String channels = new String(data, Charsets.UTF_8);
        String[] split = channels.split("\0");
        Set<String> channelSet = ImmutableSet.copyOf(split);
        FMLCommonHandler.instance().fireNetRegistrationEvent(manager, channelSet, msg.channel(), side);
    } else {
        ctx.fireChannelRead(msg);
    }
}
Also used : Side(net.minecraftforge.fml.relauncher.Side) NetworkManager(net.minecraft.network.NetworkManager)

Example 2 with NetworkManager

use of v1_8_9.net.minecraft.network.NetworkManager in project PneumaticCraft by MineMaarten.

the class EntityDrone method initializeFakePlayer.

private void initializeFakePlayer() {
    fakePlayer = new DroneFakePlayer((WorldServer) worldObj, new GameProfile(playerUUID != null ? UUID.fromString(playerUUID) : null, playerName), new FakePlayerItemInWorldManager(worldObj, fakePlayer, this), this);
    fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), new NetworkManager(false), fakePlayer);
    fakePlayer.inventory = new InventoryFakePlayer(fakePlayer);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) NetworkManager(net.minecraft.network.NetworkManager) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) FakePlayerItemInWorldManager(pneumaticCraft.common.ai.FakePlayerItemInWorldManager)

Example 3 with NetworkManager

use of v1_8_9.net.minecraft.network.NetworkManager in project PneumaticCraft by MineMaarten.

the class TileEntityProgrammableController method initializeFakePlayer.

private void initializeFakePlayer() {
    String playerUUID = null;
    String playerName = "Drone";
    fakePlayer = new DroneFakePlayer((WorldServer) worldObj, new GameProfile(playerUUID != null ? UUID.fromString(playerUUID) : null, playerName), new FakePlayerItemInWorldManager(worldObj, fakePlayer, this), this);
    fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), new NetworkManager(false), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {

        private ItemStack oldStack;

        @Override
        public int getSizeInventory() {
            return getDroneSlots();
        }

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                if (oldStack != null) {
                    getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers());
                }
                if (stack != null) {
                    getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers());
                }
                oldStack = stack;
            }
        }
    };
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) DroneFakePlayer(pneumaticCraft.common.entity.living.EntityDrone.DroneFakePlayer) NetworkManager(net.minecraft.network.NetworkManager) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) FakePlayerItemInWorldManager(pneumaticCraft.common.ai.FakePlayerItemInWorldManager)

Example 4 with NetworkManager

use of v1_8_9.net.minecraft.network.NetworkManager in project HorsePower by GoryMoon.

the class HPEventHandler method onServerLeave.

@SubscribeEvent
public static void onServerLeave(WorldEvent.Unload event) {
    if (FMLCommonHandler.instance().getSide().isClient()) {
        NetworkManager manager = FMLClientHandler.instance().getClientToServerNetworkManager();
        if (manager != null && !manager.isLocalChannel() && HPRecipes.serverSyncedRecipes) {
            HPRecipes.serverSyncedRecipes = false;
            HPRecipes.instance().reloadRecipes();
        }
    }
}
Also used : NetworkManager(net.minecraft.network.NetworkManager) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with NetworkManager

use of v1_8_9.net.minecraft.network.NetworkManager in project blockbuster by mchorse.

the class Scene method collectActors.

/**
 * Collect actors.
 *
 * This method is responsible for collecting actors the ones that in the
 * world and also the ones that doesn't exist (they will be created and
 * spawned later on).
 */
private void collectActors(Replay exception) {
    this.actors.clear();
    this.actorsCount = 0;
    for (Replay replay : this.replays) {
        if (replay == exception || !replay.enabled) {
            continue;
        }
        World world = this.getWorld();
        EntityLivingBase actor = null;
        boolean real = false;
        /* Locate the target player */
        if (!replay.target.isEmpty()) {
            EntityPlayerMP player = this.getTargetPlayer(replay.target);
            if (player != null) {
                actor = player;
                real = true;
            }
        }
        if (actor == null && replay.fake) {
            GameProfile profile = new GameProfile(new UUID(0, this.actorsCount), replay.name.isEmpty() ? "Player" : replay.name);
            if (replay.morph instanceof PlayerMorph) {
                profile = ((PlayerMorph) replay.morph).profile;
            }
            EntityPlayerMP player = new EntityPlayerMP(world.getMinecraftServer(), (WorldServer) world, profile, new PlayerInteractionManager(world));
            NetworkManager manager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
            try {
                manager.channelActive(new FakeContext());
            } catch (Exception e) {
                e.printStackTrace();
            }
            IRecording recording = Recording.get(player);
            recording.setFakePlayer(true);
            /* There is no way to construct a CPacketClientSettings on the
                 * server side without using this hack, because the other constructor
                 * is available only on the client side...
                 */
            PacketBuffer buffer = new PacketBuffer(Unpooled.buffer(64));
            buffer.writeString("en_US");
            buffer.writeByte((byte) 10);
            buffer.writeEnumValue(EntityPlayer.EnumChatVisibility.FULL);
            buffer.writeBoolean(true);
            buffer.writeByte(127);
            buffer.writeEnumValue(EnumHandSide.RIGHT);
            CPacketClientSettings packet = new CPacketClientSettings();
            try {
                packet.readPacketData(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            /* Skins layers don't show up by default, for some
                 * reason, thus I have to manually set it myself */
            player.handleClientSettings(packet);
            player.connection = new NetHandlerPlayServer(world.getMinecraftServer(), manager, player);
            actor = player;
        } else if (actor == null) {
            EntityActor entity = new EntityActor(this.getWorld());
            entity.wasAttached = true;
            actor = entity;
        }
        RecordPlayer player = CommonProxy.manager.play(replay.id, actor, Mode.BOTH, 0, true);
        if (real) {
            player.realPlayer();
        }
        if (player != null) {
            player.replay = replay;
            this.actorsCount++;
            replay.apply(actor);
            this.actors.put(replay, player);
        }
    }
    if (Blockbuster.modelBlockResetOnPlayback.get()) {
        lastUpdate = System.currentTimeMillis();
    }
}
Also used : FakeContext(mchorse.blockbuster.recording.scene.fake.FakeContext) IOException(java.io.IOException) World(net.minecraft.world.World) IOException(java.io.IOException) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) EntityActor(mchorse.blockbuster.common.entity.EntityActor) IRecording(mchorse.blockbuster.capabilities.recording.IRecording) GameProfile(com.mojang.authlib.GameProfile) EntityLivingBase(net.minecraft.entity.EntityLivingBase) PlayerMorph(mchorse.vanilla_pack.morphs.PlayerMorph) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PlayerInteractionManager(net.minecraft.server.management.PlayerInteractionManager) UUID(java.util.UUID) NetworkManager(net.minecraft.network.NetworkManager) CPacketClientSettings(net.minecraft.network.play.client.CPacketClientSettings) PacketBuffer(net.minecraft.network.PacketBuffer) RecordPlayer(mchorse.blockbuster.recording.RecordPlayer)

Aggregations

NetworkManager (net.minecraft.network.NetworkManager)22 GameProfile (com.mojang.authlib.GameProfile)6 ChatComponentText (net.minecraft.util.ChatComponentText)6 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)5 C00Handshake (net.minecraft.network.handshake.client.C00Handshake)5 C00PacketServerQuery (net.minecraft.network.status.client.C00PacketServerQuery)4 ServerAddress (net.minecraft.client.multiplayer.ServerAddress)3 INetHandlerStatusClient (net.minecraft.network.status.INetHandlerStatusClient)3 C01PacketPing (net.minecraft.network.status.client.C01PacketPing)3 S00PacketServerInfo (net.minecraft.network.status.server.S00PacketServerInfo)3 S01PacketPong (net.minecraft.network.status.server.S01PacketPong)3 IChatComponent (net.minecraft.util.IChatComponent)3 File (java.io.File)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 ItemStack (net.minecraft.item.ItemStack)2 ServerStatusResponse (net.minecraft.network.ServerStatusResponse)2 WorldServer (net.minecraft.world.WorldServer)2 Side (net.minecraftforge.fml.relauncher.Side)2 FakePlayerItemInWorldManager (pneumaticCraft.common.ai.FakePlayerItemInWorldManager)2 ServerPlayer (com.irtimaled.bbor.common.models.ServerPlayer)1