Yeah, that's still my problem. And because I haven't actually tested it on a server yet, does it still sync perfectly server-side?
Also, thanks for posting your code. I've briefly looked through it and the inventory looks so much neater than mine. Unlike you, I didn't actually assign an inventory for my entity but rather just extended IInventory. Would you mind if I did something similar?
Thanks.
Hey Bro, I just update my code again, see it again because it has a solution for updating the itemstack.
Your entity has a large inventory (more than 1 slot lol), you will need to change the packet class to send all data instead of just one!
Maybe using sendBytes
And of course, you can copy all my code, I don't matter with this.
I sent you a PM, can you read and answer please?
Hey Bro, I just update my code again, see it again because it has a solution for updating the itemstack.
Your entity has a large inventory (more than 1 slot lol), you will need to change the packet class to send all data instead of just one!
Maybe using sendBytes
And of course, you can copy all my code, I don't matter with this.
I sent you a PM, can you read and answer please?
What do you mean send all data? If you mean send all itemstacks over, I think that's what I got already. I just used the merchant code to convert the itemstacks to byte arrays (I think).
Also, I'm going away on vacation today so I won't be around for a few days. So please excuse me if I don't reply instantly.
What do you mean send all data? If you mean send all itemstacks over, I think that's what I got already. I just used the merchant code to convert the itemstacks to byte arrays (I think).
Also, I'm going away on vacation today so I won't be around for a few days. So please excuse me if I don't reply instantly.
Yes, convert to bytes and send all.
Have a nice vacation!!!
Thanks!
Is there a way to make more slots?
Like copy and paste the 1 slot and change the position?
Robbi Blechdose
Yes of course. This is a sample of adding player inventory to the gui container:
protected void bindPlayerInventory(IInventory inventoryPlayer) {
// adds second group of slots (player's inventory)
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, firstPlayerInvSlotX + x * slotSquareSize, firstPlayerInvSlotY + y * slotSquareSize));
}
}
// adds first group of slots (Player Hands)
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, firstPlayerSlotX + i * slotSquareSize, firstPlayerSlotY));
}
}
Yes, you can change the code to fill the inventory with what you want.
Just fill the entity inventory first and after the player inventory.
Change the part of the class that uses slot 0 as reference because this is for my mod. If your mob has a 32 slots, your slot count will start in 0 and finish in 31, and player inventory starts in 32.
I don't know if I understood you right,
but I wanted to add more slots to my entity.
You've got 1 slot in your entity, I want more.
So can you give me an example on your code for 2 slots?
Then I can use it for more.
I don't know if I understood you right,
but I wanted to add more slots to my entity.
You've got 1 slot in your entity, I want more.
So can you give me an example on your code for 2 slots?
Then I can use it for more.
Robbi Blechdose
Robbi, there are a lot of gui tutorials on the net, just search about them and you will find good samples.
Compare this two functions:
protected void layoutContainer() {
addSlotToContainer(new SlotSpiderMother(invSpider,0,firstGuiSlotX, firstGuiSlotY));
bindPlayerInventory();
}
protected void bindPlayerInventory() {
// adds second group of slots (player's inventory)
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, firstPlayerInvSlotX + x * slotSquareSize, firstPlayerInvSlotY + y * slotSquareSize));
}
As you can see, in layoutContainer function, I am adding only one slot, and in BindPlayerInventory I am binding a lot of slots!
Just follow the idea!
This line take the mob inventory (invSpider in this case), and adds one slot:
addSlotToContainer(new Slot(invSpider,0,firstGuiSlotX, firstGuiSlotY));
So, if you put this inside a loop, you can add more slots. First, modify the inventory class of your mob and put more space in inventory. Next, do a loop like this:
for (int y = 0; y < invSpider.getSizeInventory() / 9; y++) {
for (int x = 0; x < 9; x++) {
if (x + y * 9 < invSpider.getSizeInventory())
addSlotToContainer(new SlotSpiderMother(invSpider, x + y * 9, firstGuiSlotX + x * slotSquareSize, firstGuiSlotY + y * slotSquareSize));
else
return;
}
}
Sorry,
but I've got a problem.
I've got a LOT of errors in the code.
I haven't got a BasePacket.class, I've got an error on makePacket():
@Override
public void onLivingUpdate() {
if (worldObj.isRemote) {
if (firstSpawn && !this.worldObj.playerEntities.isEmpty()) {
PacketDispatcher.sendPacketToServer(new getEntityInvServer(this.entityId, null).makePacket());
firstSpawn = false;
}
}
super.onLivingUpdate();
}
I've got no Methods.class and
there's no References.class.
Please help!
Robbi Blechdose
I think you will need a lot of help, please read the basic tutorials about packets, base class and so on before trying to create an entity with an inventory.
Guys, I have some news... interesting and very strange news...
I am creating another entity from scratch and this entity will have 3 inventories:
1) Armor inventory (1 slot)
2) Utilities inventory (3 slots)
3) Main inventory (52 slots)
So, I created new classes for it since the last classes that I used in this topic for my spider entity was for just 1 slot.
Now I have my entity working and syncing all inventories without using any custom packets!!
I don't know why or how but it is working!!!
Next step: I'll delete all older classes and use this class for my spider entity to see if it will work too.
This is amazing.
******************edited******************
Everithing is not working. I discover that client side does not have the inventory. So, if you need to check if the entity is wearing an armor for rendering purposes, you need to use datawatcher or custom packets.
that is it!
I am only having one issue.. The Egg for this new entity does not appear at minecraft distributed zip file but it is working in debug mode inside the IDE.... grrrrrrrrrrr
Hey Bro, I just update my code again, see it again because it has a solution for updating the itemstack.
Your entity has a large inventory (more than 1 slot lol), you will need to change the packet class to send all data instead of just one!
Maybe using sendBytes
And of course, you can copy all my code, I don't matter with this.
I sent you a PM, can you read and answer please?
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
Also, I'm going away on vacation today so I won't be around for a few days. So please excuse me if I don't reply instantly.
Yes, convert to bytes and send all.
Have a nice vacation!!!
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
You've got 1 slot WORKING?
Can you please post the code?
I need it.
Robbi Blechdose
the code was posted, search posts at page 1
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
Is there a way to make more slots?
Like copy and paste the 1 slot and change the position?
Robbi Blechdose
Yes of course. This is a sample of adding player inventory to the gui container:
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
Robbi Blechdose
Yes, you can change the code to fill the inventory with what you want.
Just fill the entity inventory first and after the player inventory.
Change the part of the class that uses slot 0 as reference because this is for my mod. If your mob has a 32 slots, your slot count will start in 0 and finish in 31, and player inventory starts in 32.
Where are you from?
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
but I wanted to add more slots to my entity.
You've got 1 slot in your entity, I want more.
So can you give me an example on your code for 2 slots?
Then I can use it for more.
Robbi Blechdose
Robbi, there are a lot of gui tutorials on the net, just search about them and you will find good samples.
Compare this two functions:
As you can see, in layoutContainer function, I am adding only one slot, and in BindPlayerInventory I am binding a lot of slots!
Just follow the idea!
This line take the mob inventory (invSpider in this case), and adds one slot:
addSlotToContainer(new Slot(invSpider,0,firstGuiSlotX, firstGuiSlotY));
So, if you put this inside a loop, you can add more slots. First, modify the inventory class of your mob and put more space in inventory. Next, do a loop like this:
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
Robbi Blechdose
but I've got a problem.
I've got a LOT of errors in the code.
I haven't got a BasePacket.class, I've got an error on makePacket():
I've got no Methods.class and
there's no References.class.
Please help!
Robbi Blechdose
I think you will need a lot of help, please read the basic tutorials about packets, base class and so on before trying to create an entity with an inventory.
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
If not, I can search google. =)
Robbi Blechdose
I used google and found this tutorial. I didn't follow, so it is your chance to follow and test.
http://www.minecraftforum.net/topic/1931778-162-advanced-minecraft-forge-modding-tutorial-1-interfaces-part-3/
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?
Robbi Blechdose
I am creating another entity from scratch and this entity will have 3 inventories:
1) Armor inventory (1 slot)
2) Utilities inventory (3 slots)
3) Main inventory (52 slots)
So, I created new classes for it since the last classes that I used in this topic for my spider entity was for just 1 slot.
Now I have my entity working and syncing all inventories without using any custom packets!!
I don't know why or how but it is working!!!
Next step: I'll delete all older classes and use this class for my spider entity to see if it will work too.
This is amazing.
******************edited******************
Everithing is not working. I discover that client side does not have the inventory. So, if you need to check if the entity is wearing an armor for rendering purposes, you need to use datawatcher or custom packets.
that is it!
I am only having one issue.. The Egg for this new entity does not appear at minecraft distributed zip file but it is working in debug mode inside the IDE.... grrrrrrrrrrr
Want real chalenge and cool mods? My mods:
Amazing Minecraft Mods
†GnR† Slash - Can one man truly make a difference?