Jump to content

[1.12.2] "The client has sent too many requestes within a certain amount of time"


Recommended Posts

Posted (edited)

Hi everyone!

I'm developing a Mod for Minecraft 1.12.2 and I have a block that needs a GUI, so i created it.

The code is correct, but when i right-click a block to show the GUI, the GUI doesn't appear and in the Eclipse console i got the error "The client has sent too many requests within a certain amount of time".

I have an idea of what cause this error: I think that it's caused by the onBlockActivated event of the block.

Here's the onBlockActivated event code:

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {{
	    if (worldIn.isRemote) {
	        return true;
	    }
	    TileEntity te = worldIn.getTileEntity(pos);
	    if (!(te instanceof CompactorTileEntity)) {
	        return false;
	    }
	    playerIn.openGui(Main.instance, GUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ());
	    return true;
	}
}

 

Thanks to everyone will help me!

Edited by MisterGamer _
Grammar correction
Posted

Try looking into IGuiHandler, I believe you need to register one of those which will return a container on the server side (!world.isRemote) and a GUI on the client side (world.isRemote). Also the "certain amount of requests" error seems to always get posted for me when I load a world up, I've learnt to ignore them.

Posted
21 minutes ago, DoctorLOGiQ said:

Try looking into IGuiHandler, I believe you need to register one of those which will return a container on the server side (!world.isRemote) and a GUI on the client side (world.isRemote). Also the "certain amount of requests" error seems to always get posted for me when I load a world up, I've learnt to ignore them.

You mean this?

public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        BlockPos pos = new BlockPos(x, y, z);
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof CompactorTileEntity) {
            return new CompactorContainer(player.inventory, (CompactorTileEntity) te);
        }
        return null;
    }

    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        BlockPos pos = new BlockPos(x, y, z);
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof CompactorTileEntity) {
            CompactorTileEntity containerTileEntity = (CompactorTileEntity) te;
            return new CompactorGui(containerTileEntity, new CompactorContainer(player.inventory, containerTileEntity));
        }
        return null;
    }

 

Posted
30 minutes ago, MisterGamer _ said:

You mean this?

Yes, I guess you've already implemented that then. Looking at some of my old working code, onBlockActivated () did not cause any problems, and we've done things the same way by the looks of it.

 

Are you using GuiContainer for your Gui class? If so then I don't see a reason why it wouldn't work, unless it's not finding the TileEntity - might be worth doing some logging just to make sure it's not null anywhere it shouldn't be.

Posted
1 hour ago, DoctorLOGiQ said:

Sì, immagino che tu l'abbia già implementato allora. Guardando parte del mio vecchio codice di lavoro, onBlockActivated () non ha causato alcun problema, e abbiamo fatto le cose allo stesso modo con l'aspetto di esso.

 

Stai usando GuiContainer per la tua classe Gui? Se è così allora non vedo una ragione per cui non funzionerebbe, a meno che non trovi il TileEntity - potrebbe valere la pena fare qualche logging solo per assicurarsi che non sia nullo ovunque non dovrebbe essere.

Ok so I did debugging and I discovered that the error occurs at the world loading. I don't know what to do =(

Posted
1 hour ago, MisterGamer _ said:

Ok so I did debugging and I discovered that the error occurs at the world loading. I don't know what to do =(

Yes, that error happens all the time, it is not very likely to be anything on your end, so don't worry about it. I get it too, even with a fresh mod setup. Presumably the world loading just causes a bit of a hang and client requests get buffered up and then come through all at once when the hang ends.

Posted
Proprio ora, DoctorLOGiQ ha detto:

Sì, quell'errore si verifica sempre, non è molto probabile che sia sia qualcosa da parte tua, quindi non preoccuparti. Lo capisco anche con un nuovo setup di mod. Presumibilmente, il caricamento del mondo è solo un po 'di blocco e le richieste dei clienti vengono memorizzate nel buffer e poi vengono tutte in una volta quando il blocco termina.

Ok i did understand this.

I resolved The problem and Now The container works properly eith the GUI.

But there's another problem: i click on a item in The Player inventory but it doesn't move.

How do I resolve that?

Thank you so much!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.