mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-29 15:49:09 +01:00
Fix grindstones and looms on 1.17.40
This commit is contained in:
parent
9de26f2ba1
commit
483a336b8a
4 changed files with 22 additions and 7 deletions
|
@ -115,7 +115,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.CloudburstMC.Protocol</groupId>
|
||||
<artifactId>bedrock-v471</artifactId>
|
||||
<version>b71f1c9</version>
|
||||
<version>0bc10c8e</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -64,7 +64,7 @@ import java.util.*;
|
|||
public abstract class InventoryTranslator {
|
||||
|
||||
public static final InventoryTranslator PLAYER_INVENTORY_TRANSLATOR = new PlayerInventoryTranslator();
|
||||
public static final Map<WindowType, InventoryTranslator> INVENTORY_TRANSLATORS = new HashMap<WindowType, InventoryTranslator>() {
|
||||
public static final Map<WindowType, InventoryTranslator> INVENTORY_TRANSLATORS = new HashMap<>() {
|
||||
{
|
||||
/* Player Inventory */
|
||||
put(null, PLAYER_INVENTORY_TRANSLATOR);
|
||||
|
@ -395,7 +395,9 @@ public abstract class InventoryTranslator {
|
|||
case CRAFT_RECIPE_AUTO: // Called by villagers
|
||||
case CRAFT_NON_IMPLEMENTED_DEPRECATED: // Tends to be called for UI inventories
|
||||
case CRAFT_RESULTS_DEPRECATED: // Tends to be called for UI inventories
|
||||
case CRAFT_RECIPE_OPTIONAL: { // Anvils and cartography tables will handle this
|
||||
case CRAFT_RECIPE_OPTIONAL: // Anvils and cartography tables will handle this
|
||||
case CRAFT_LOOM: // Looms 1.17.40+
|
||||
case CRAFT_REPAIR_AND_DISENCHANT: { // Grindstones 1.17.40+
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType;
|
|||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.CraftLoomStackRequestActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.CraftResultsDeprecatedStackRequestActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.StackRequestActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.StackRequestActionType;
|
||||
|
@ -118,12 +119,14 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
|
|||
@Override
|
||||
public boolean shouldHandleRequestFirst(StackRequestActionData action, Inventory inventory) {
|
||||
// If the LOOM_MATERIAL slot is not empty, we are crafting a pattern that does not come from an item
|
||||
return action.getType() == StackRequestActionType.CRAFT_NON_IMPLEMENTED_DEPRECATED && inventory.getItem(2).isEmpty();
|
||||
// Remove the CRAFT_NON_IMPLEMENTED_DEPRECATED when 1.17.30 is dropped
|
||||
return (action.getType() == StackRequestActionType.CRAFT_NON_IMPLEMENTED_DEPRECATED || action.getType() == StackRequestActionType.CRAFT_LOOM)
|
||||
&& inventory.getItem(2).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStackResponsePacket.Response translateSpecialRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) {
|
||||
// TODO: I anticipate this will be changed in the future to use something non-deprecated. Keep an eye out.
|
||||
StackRequestActionData headerData = request.getActions()[0];
|
||||
StackRequestActionData data = request.getActions()[1];
|
||||
if (!(data instanceof CraftResultsDeprecatedStackRequestActionData craftData)) {
|
||||
return rejectRequest(request);
|
||||
|
@ -133,8 +136,18 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
|
|||
List<NbtMap> newBlockEntityTag = craftData.getResultItems()[0].getTag().getList("Patterns", NbtType.COMPOUND);
|
||||
// Get the pattern that the Bedrock client requests - the last pattern in the Patterns list
|
||||
NbtMap pattern = newBlockEntityTag.get(newBlockEntityTag.size() - 1);
|
||||
String bedrockPattern;
|
||||
|
||||
if (headerData instanceof CraftLoomStackRequestActionData loomData) {
|
||||
// Prioritize this if on 1.17.40
|
||||
// Remove the below if statement when 1.17.30 is dropped
|
||||
bedrockPattern = loomData.getPatternId();
|
||||
} else {
|
||||
bedrockPattern = pattern.getString("Pattern");
|
||||
}
|
||||
|
||||
// Get the Java index of this pattern
|
||||
int index = PATTERN_TO_INDEX.getOrDefault(pattern.getString("Pattern"), -1);
|
||||
int index = PATTERN_TO_INDEX.getOrDefault(bedrockPattern, -1);
|
||||
if (index == -1) {
|
||||
return rejectRequest(request);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class BannerTranslator extends ItemTranslator {
|
|||
/**
|
||||
* Convert the Bedrock edition banner pattern nbt to Java edition
|
||||
*
|
||||
* @param pattern Bedorck edition pattern nbt
|
||||
* @param pattern Bedrock edition pattern nbt
|
||||
* @return The Java edition format pattern nbt
|
||||
*/
|
||||
public static CompoundTag getJavaBannerPattern(NbtMap pattern) {
|
||||
|
|
Loading…
Reference in a new issue