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);
}
}
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);
}
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;
}
}
};
}
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();
}
}
}
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();
}
}
Aggregations