initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
105
java/src/game/packet/SPacketTrades.java
Executable file
105
java/src/game/packet/SPacketTrades.java
Executable file
|
@ -0,0 +1,105 @@
|
|||
package game.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import game.item.ItemStack;
|
||||
import game.network.NetHandlerPlayClient;
|
||||
import game.network.Packet;
|
||||
import game.network.PacketBuffer;
|
||||
import game.village.MerchantRecipe;
|
||||
import game.village.MerchantRecipeList;
|
||||
|
||||
public class SPacketTrades implements Packet<NetHandlerPlayClient>
|
||||
{
|
||||
private MerchantRecipeList recipes;
|
||||
private int windowId;
|
||||
|
||||
public SPacketTrades()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketTrades(MerchantRecipeList recipesIn, int windowIdIn)
|
||||
{
|
||||
this.recipes = recipesIn;
|
||||
this.windowId = windowIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readInt();
|
||||
this.recipes = new MerchantRecipeList();
|
||||
int i = buf.readByte() & 255;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
ItemStack itemstack = buf.readItemStackFromBuffer();
|
||||
ItemStack itemstack1 = buf.readItemStackFromBuffer();
|
||||
ItemStack itemstack2 = null;
|
||||
|
||||
if (buf.readBoolean())
|
||||
{
|
||||
itemstack2 = buf.readItemStackFromBuffer();
|
||||
}
|
||||
|
||||
// boolean flag = buf.readBoolean();
|
||||
// int k = buf.readInt();
|
||||
// int l = buf.readInt();
|
||||
MerchantRecipe merchantrecipe = new MerchantRecipe(itemstack, itemstack2, itemstack1); // , k, l);
|
||||
|
||||
// if (flag)
|
||||
// {
|
||||
// merchantrecipe.compensateToolUses();
|
||||
// }
|
||||
|
||||
this.recipes.add(merchantrecipe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeInt(this.windowId);
|
||||
buf.writeByte((byte)(this.recipes.size() & 255));
|
||||
|
||||
for (int i = 0; i < this.recipes.size(); ++i)
|
||||
{
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)this.recipes.get(i);
|
||||
buf.writeItemStackToBuffer(merchantrecipe.getItemToBuy());
|
||||
buf.writeItemStackToBuffer(merchantrecipe.getItemToSell());
|
||||
ItemStack itemstack = merchantrecipe.getSecondItemToBuy();
|
||||
buf.writeBoolean(itemstack != null);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
buf.writeItemStackToBuffer(itemstack);
|
||||
}
|
||||
|
||||
// buf.writeBoolean(merchantrecipe.isRecipeDisabled());
|
||||
// buf.writeInt(merchantrecipe.getToolUses());
|
||||
// buf.writeInt(merchantrecipe.getMaxTradeUses());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleTrades(this);
|
||||
}
|
||||
|
||||
public MerchantRecipeList getTrades()
|
||||
{
|
||||
return this.recipes;
|
||||
}
|
||||
|
||||
public int getWindowId()
|
||||
{
|
||||
return this.windowId;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue