net.minecraft.network.NetworkManager Java Examples

The following examples show how to use net.minecraft.network.NetworkManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileEntityQBlock.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
@Override
public void onDataPacket( NetworkManager net, S35PacketUpdateTileEntity packet )
{
    switch( packet.func_148853_f() ) // actionType
    {
        case 0:
        {
            // Receive sides and frequency
            int oldSide = m_currentDisplayedSide;
            int oldType = getObservedType();
            NBTTagCompound nbttagcompound = packet.func_148857_g(); // data
            readFromNBT( nbttagcompound );
            int newType = getObservedType();

            // Update state
            if( newType != oldType || oldSide < 0 )
            {
                m_timeSinceLastChange = 0;
                blockUpdate();
            }
            break;
        }
    }
}
 
Example #2
Source File: TileEntityGearbox.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    nextRotation = pkt.getNbtCompound().getDouble("rotation");
    inputFacing = EnumFacing.values()[pkt.getNbtCompound()
        .getByte("input_facing")];
    byte validSidesByte = pkt.getNbtCompound().getByte("valid_sides_byte");
    for (int i = 0; i < 6; i++) {
        if ((validSidesByte & (1 << i)) != 0) {
            this.connectedSidesRatios[i] = Optional
                .of((double) pkt.getNbtCompound().getFloat("side_rotation_ratio" + i));
        } else {
            this.connectedSidesRatios[i] = Optional.empty();
        }
    }
}
 
Example #3
Source File: TileEntityProgrammableController.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
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;
            }
        }
    };
}
 
Example #4
Source File: TileEntityTransportRail.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){
    if(pkt.getTileEntityType() == 0) {
        forward = pkt.getNbtCompound().getBoolean("forward");
        world.markBlockRangeForRenderUpdate(pos, pos);
    }
}
 
Example #5
Source File: StandardPaperServerListPingEventImpl.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static void processRequest(MinecraftServer server, NetworkManager networkManager) {
    StandardPaperServerListPingEventImpl event = new StandardPaperServerListPingEventImpl(server, networkManager, server.getServerStatusResponse());
    server.server.getPluginManager().callEvent(event);

    // Close connection immediately if event is cancelled
    if (event.isCancelled()) {
        networkManager.closeChannel(null);
        return;
    }

    // Setup response
    ServerStatusResponse ping = new ServerStatusResponse();

    // Description
    ping.setServerDescription(new TextComponentString(event.getMotd()));

    // Players
    if (!event.shouldHidePlayers()) {
        ping.setPlayers(new ServerStatusResponse.Players(event.getMaxPlayers(), event.getNumPlayers()));
        ping.getPlayers().setPlayers(event.getPlayerSampleHandle());
    }

    // Version
    ping.setVersion(new ServerStatusResponse.Version(event.getVersion(), event.getProtocolVersion()));

    // Favicon
    if (event.getServerIcon() != null) {
        ping.setFavicon(event.getServerIcon().getData());
    }

    // Send response
    networkManager.sendPacket(new SPacketServerInfo(ping));
}
 
Example #6
Source File: SyncedTileEntityBase.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    NBTTagCompound updateTag = pkt.getNbtCompound();
    NBTTagList tagList = updateTag.getTagList("d", NBT.TAG_COMPOUND);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound entryTag = tagList.getCompoundTagAt(i);
        int discriminator = entryTag.getInteger("i");
        byte[] updateData = entryTag.getByteArray("d");
        ByteBuf backedBuffer = Unpooled.copiedBuffer(updateData);
        receiveCustomData(discriminator, new PacketBuffer(backedBuffer));
    }
}
 
Example #7
Source File: CommonInterop.java    From BoundingBoxOutlineReloaded with MIT License 5 votes vote down vote up
public static void playerLoggedIn(ServerPlayerEntity player) {
    ServerPlayNetHandler connection = player.connection;
    if (connection == null) return;

    NetworkManager networkManager = connection.netManager;
    if (networkManager.isLocalChannel()) return;

    EventBus.publish(new PlayerLoggedIn(new ServerPlayer(player)));
}
 
Example #8
Source File: TileMicrowaveReciever.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	NBTTagCompound nbt = pkt.getNbtCompound();

	canRender = nbt.getBoolean("canRender");
	powerMadeLastTick = nbt.getInteger("amtPwr");
	readNetworkData(nbt);
}
 
Example #9
Source File: TileAtmosphereTerraformer.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	NBTTagCompound nbt = pkt.getNbtCompound();
	readFromNBT(nbt);
	setText();
	
}
 
Example #10
Source File: TileEntityBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
	{ readNBT(pkt.getNbtCompound(), true); }
 
Example #11
Source File: TileLandingPad.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	super.onDataPacket(net, pkt);
	readFromNBT(pkt.getNbtCompound());
	moduleNameTextbox.setText(name);
}
 
Example #12
Source File: TilePlanetSelector.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {

	super.onDataPacket(net, pkt);
	readAdditionalNBT(pkt.getNbtCompound());
}
 
Example #13
Source File: ChoppingBlockTileEntity.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt)
{
    handleUpdateTag(getBlockState(), pkt.getNbtCompound());
}
 
Example #14
Source File: DryingRackTileEntity.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet)
{
    handleUpdateTag(getBlockState(), packet.getNbtCompound());
}
 
Example #15
Source File: TileEntityBabyChest.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager pNetMan, S35PacketUpdateTileEntity pPkt) 
{
    readSyncedNBT(pPkt.func_148857_g());
}
 
Example #16
Source File: TileThaumcraft.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
	super.onDataPacket(net, pkt);		
	this.readCustomNBT(pkt.func_148857_g());
}
 
Example #17
Source File: TileFluidTank.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	readFromNBT(pkt.getNbtCompound());
}
 
Example #18
Source File: TileOxygenVent.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	handleUpdateTag(pkt.getNbtCompound());
}
 
Example #19
Source File: TileRocketBuilder.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	readFromNBT(pkt.getNbtCompound());
}
 
Example #20
Source File: TileEntityDisplayPedestal.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
	readFromNBT(packet.func_148857_g());
}
 
Example #21
Source File: TileInfestedLeaves.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager networkManager, SPacketUpdateTileEntity packet)
{
    readFromNBT(packet.getNbtCompound());
}
 
Example #22
Source File: TileBarrel.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
	NBTTagCompound tag = pkt.getNbtCompound();
	readFromNBT(tag);
}
 
Example #23
Source File: TileSieve.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
	NBTTagCompound tag = pkt.getNbtCompound();
	readFromNBT(tag);
}
 
Example #24
Source File: TileCrucible.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
	NBTTagCompound tag = pkt.getNbtCompound();
	readFromNBT(tag);
}
 
Example #25
Source File: TileEntitySword.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
	readFromNBT(packet.func_148857_g());
}
 
Example #26
Source File: TileFrequencyOwner.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
    readFromPacket(PacketCustom.fromTilePacket(pkt));
}
 
Example #27
Source File: TileEntityPhysicsInfuser.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    this.handleUpdateTag(pkt.getNbtCompound());
}
 
Example #28
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
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);
}
 
Example #29
Source File: FakeWorldClient.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
private FakeWorldClient() {

        super(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(0, GameType.NOT_SET,
                false, false, WorldType.DEFAULT), 0, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().theWorld.theProfiler);
    }
 
Example #30
Source File: SynchronizedTileEntity.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity paket) {
    super.onDataPacket(manager, paket);
    readCustomNBT(paket.func_148857_g());
}