mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Change book clone ID to be dynamic, rename boolean
This commit is contained in:
parent
2e3416025b
commit
9ff6c7da5d
5 changed files with 15 additions and 10 deletions
|
@ -62,17 +62,17 @@ public final class ClickPlan {
|
|||
/**
|
||||
* The recipe for cloning books requires special handling, this dictates whether that handling should be performed
|
||||
*/
|
||||
private final boolean cloneBookRecipe;
|
||||
private final boolean handleBookCloneRecipe;
|
||||
|
||||
public ClickPlan(GeyserSession session, InventoryTranslator translator, Inventory inventory) {
|
||||
this(session, translator, inventory, false);
|
||||
}
|
||||
|
||||
public ClickPlan(GeyserSession session, InventoryTranslator translator, Inventory inventory, boolean cloneBookRecipe) {
|
||||
public ClickPlan(GeyserSession session, InventoryTranslator translator, Inventory inventory, boolean handleBookCloneRecipe) {
|
||||
this.session = session;
|
||||
this.translator = translator;
|
||||
this.inventory = inventory;
|
||||
this.cloneBookRecipe = cloneBookRecipe;
|
||||
this.handleBookCloneRecipe = handleBookCloneRecipe;
|
||||
|
||||
this.simulatedItems = new Int2ObjectOpenHashMap<>(inventory.getSize());
|
||||
this.changedItems = null;
|
||||
|
@ -386,7 +386,7 @@ public final class ClickPlan {
|
|||
for (int i = 0; i < gridSize; i++) {
|
||||
final int slot = i + 1;
|
||||
GeyserItemStack item = getItem(slot);
|
||||
if (!item.isEmpty() && item.asItem() == Items.WRITTEN_BOOK) {
|
||||
if (!item.isEmpty() && (!handleBookCloneRecipe || item.asItem() == Items.WRITTEN_BOOK)) {
|
||||
// These changes should be broadcasted to the server
|
||||
sub(slot, item, crafted);
|
||||
}
|
||||
|
|
|
@ -370,6 +370,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
@Setter
|
||||
private Int2ObjectMap<GeyserStonecutterData> stonecutterRecipes;
|
||||
|
||||
/**
|
||||
* Saves the ID for cloning books through the crafting table, as these need different handling
|
||||
*/
|
||||
@Setter
|
||||
private int bookCloningID;
|
||||
|
||||
|
||||
/**
|
||||
* Whether to work around 1.13's different behavior in villager trading menus.
|
||||
*/
|
||||
|
|
|
@ -463,7 +463,7 @@ public abstract class InventoryTranslator {
|
|||
}
|
||||
craftState = CraftState.RECIPE_ID;
|
||||
|
||||
if (((RecipeItemStackRequestAction) action).getRecipeNetworkId() == InventoryUtils.BOOK_CLONING_RECIPE_ID) {
|
||||
if (((RecipeItemStackRequestAction) action).getRecipeNetworkId() == session.getBookCloningID()) {
|
||||
// Book copying needs to be handled differently
|
||||
// The original written book is leftover in the crafting grid
|
||||
return translateBookCopyCraftingRequest(session, inventory, request);
|
||||
|
|
|
@ -180,7 +180,9 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
|
|||
craftingDataPacket.getCraftingData().add(MultiRecipeData.of(UUID.fromString("685a742a-c42e-4a4e-88ea-5eb83fc98e5b"), context.getAndIncrementNetId()));
|
||||
}
|
||||
case CRAFTING_SPECIAL_BOOKCLONING -> {
|
||||
craftingDataPacket.getCraftingData().add(MultiRecipeData.of(UUID.fromString("d1ca6b84-338e-4f2f-9c6b-76cc8b4bd98d"), context.getAndIncrementNetId()));
|
||||
int bookCloningID = context.getAndIncrementNetId();
|
||||
session.setBookCloningID(bookCloningID);
|
||||
craftingDataPacket.getCraftingData().add(MultiRecipeData.of(UUID.fromString("d1ca6b84-338e-4f2f-9c6b-76cc8b4bd98d"), bookCloningID));
|
||||
}
|
||||
case CRAFTING_SPECIAL_REPAIRITEM -> {
|
||||
craftingDataPacket.getCraftingData().add(MultiRecipeData.of(UUID.fromString("00000000-0000-0000-0000-000000000001"), context.getAndIncrementNetId()));
|
||||
|
|
|
@ -74,10 +74,6 @@ public class InventoryUtils {
|
|||
* each recipe needs a unique network ID (or else in .200 the client crashes).
|
||||
*/
|
||||
public static int LAST_RECIPE_NET_ID;
|
||||
/**
|
||||
* Book cloning recipe ID; stored separately as its recipe works differently from others.
|
||||
*/
|
||||
public static final int BOOK_CLONING_RECIPE_ID = 278;
|
||||
|
||||
public static final ItemStack REFRESH_ITEM = new ItemStack(1, 127, new DataComponents(new HashMap<>()));
|
||||
|
||||
|
|
Loading…
Reference in a new issue