mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Update ClientCraftingBookDataPacket
This commit is contained in:
parent
5ced5be32c
commit
c3a1b2b6f9
1 changed files with 30 additions and 13 deletions
|
@ -10,23 +10,26 @@ import java.io.IOException;
|
|||
|
||||
public class ClientCraftingBookDataPacket extends MinecraftPacket {
|
||||
private CraftingBookDataType type;
|
||||
private int recipeId;
|
||||
private String recipeId;
|
||||
private boolean craftingBookOpen;
|
||||
private boolean filterActive;
|
||||
private boolean filterCraftingActive;
|
||||
private boolean smeltingBookOpen;
|
||||
private boolean filterSmeltingActive;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ClientCraftingBookDataPacket() {
|
||||
}
|
||||
|
||||
public ClientCraftingBookDataPacket(int recipeId) {
|
||||
public ClientCraftingBookDataPacket(String recipeId) {
|
||||
this.type = CraftingBookDataType.DISPLAYED_RECIPE;
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
|
||||
public ClientCraftingBookDataPacket(boolean craftingBookOpen, boolean filterActive) {
|
||||
public ClientCraftingBookDataPacket(boolean craftingBookOpen, boolean filterCraftingActive,
|
||||
boolean smeltingBookOpen, boolean filterSmeltingActive) {
|
||||
this.type = CraftingBookDataType.CRAFTING_BOOK_STATUS;
|
||||
this.craftingBookOpen = craftingBookOpen;
|
||||
this.filterActive = filterActive;
|
||||
this.filterCraftingActive = filterCraftingActive;
|
||||
}
|
||||
|
||||
public CraftingBookDataType getType() {
|
||||
|
@ -39,7 +42,7 @@ public class ClientCraftingBookDataPacket extends MinecraftPacket {
|
|||
}
|
||||
}
|
||||
|
||||
public int getRecipeId() {
|
||||
public String getRecipeId() {
|
||||
ensureType(CraftingBookDataType.DISPLAYED_RECIPE, "recipeId");
|
||||
return recipeId;
|
||||
}
|
||||
|
@ -49,20 +52,32 @@ public class ClientCraftingBookDataPacket extends MinecraftPacket {
|
|||
return craftingBookOpen;
|
||||
}
|
||||
|
||||
public boolean isFilterActive() {
|
||||
ensureType(CraftingBookDataType.CRAFTING_BOOK_STATUS, "filterActive");
|
||||
return filterActive;
|
||||
public boolean isFilterCraftingActive() {
|
||||
ensureType(CraftingBookDataType.CRAFTING_BOOK_STATUS, "filterCraftingActive");
|
||||
return filterCraftingActive;
|
||||
}
|
||||
|
||||
public boolean isSmeltingBookOpen() {
|
||||
ensureType(CraftingBookDataType.CRAFTING_BOOK_STATUS, "smeltingBookOpen");
|
||||
return smeltingBookOpen;
|
||||
}
|
||||
|
||||
public boolean isFilterSmeltingActive() {
|
||||
ensureType(CraftingBookDataType.CRAFTING_BOOK_STATUS, "filterSmeltingActive");
|
||||
return filterSmeltingActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
switch(this.type = MagicValues.key(CraftingBookDataType.class, in.readVarInt())) {
|
||||
case DISPLAYED_RECIPE:
|
||||
this.recipeId = in.readInt();
|
||||
this.recipeId = in.readString();
|
||||
break;
|
||||
case CRAFTING_BOOK_STATUS:
|
||||
this.craftingBookOpen = in.readBoolean();
|
||||
this.filterActive = in.readBoolean();
|
||||
this.filterCraftingActive = in.readBoolean();
|
||||
this.smeltingBookOpen = in.readBoolean();
|
||||
this.filterSmeltingActive = in.readBoolean();
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown crafting book data type: " + this.type);
|
||||
|
@ -74,11 +89,13 @@ public class ClientCraftingBookDataPacket extends MinecraftPacket {
|
|||
out.writeVarInt(MagicValues.value(Integer.class, this.type));
|
||||
switch(this.type) {
|
||||
case DISPLAYED_RECIPE:
|
||||
out.writeInt(this.recipeId);
|
||||
out.writeString(this.recipeId);
|
||||
break;
|
||||
case CRAFTING_BOOK_STATUS:
|
||||
out.writeBoolean(this.craftingBookOpen);
|
||||
out.writeBoolean(this.filterActive);
|
||||
out.writeBoolean(this.filterCraftingActive);
|
||||
out.writeBoolean(this.smeltingBookOpen);
|
||||
out.writeBoolean(this.filterSmeltingActive);
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown crafting book data type: " + this.type);
|
||||
|
|
Loading…
Reference in a new issue