use of 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 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 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 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 net.minecraft.network.NetworkManager in project pnc-repressurized by TeamPneumatic.
the class TileEntityProgrammableController method initializeFakePlayer.
private void initializeFakePlayer() {
fakePlayer = new DroneFakePlayer((WorldServer) getWorld(), new GameProfile(getOwnerUUID(), ownerName), this);
fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
fakePlayer.inventory = new InventoryPlayer(fakePlayer) {
private ItemStack oldStack = ItemStack.EMPTY;
@Override
public int getSizeInventory() {
return getDroneSlots();
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
super.setInventorySlotContents(slot, stack);
if (slot == 0) {
for (EntityEquipmentSlot ee : EntityEquipmentSlot.values()) {
if (!oldStack.isEmpty()) {
getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers(ee));
}
if (!stack.isEmpty()) {
getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(ee));
}
}
oldStack = stack;
}
}
};
}
Aggregations