Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Don't confirm if the inventory is the same type
Dieser Commit ist enthalten in:
Ursprung
ca3f9550dd
Commit
16e8dd0df1
@ -25,11 +25,13 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to determine if rename packets should be sent.
|
* Used to determine if rename packets should be sent.
|
||||||
*/
|
*/
|
||||||
public class AnvilContainer extends Container {
|
public class AnvilContainer extends Container {
|
||||||
public AnvilContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public AnvilContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ public class BeaconContainer extends Container {
|
|||||||
private int primaryId;
|
private int primaryId;
|
||||||
private int secondaryId;
|
private int secondaryId;
|
||||||
|
|
||||||
public BeaconContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public BeaconContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,10 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
|
|
||||||
public class CartographyContainer extends Container {
|
public class CartographyContainer extends Container {
|
||||||
public CartographyContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public CartographyContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -43,8 +44,8 @@ public class Container extends Inventory {
|
|||||||
*/
|
*/
|
||||||
private boolean isUsingRealBlock = false;
|
private boolean isUsingRealBlock = false;
|
||||||
|
|
||||||
public Container(String title, int id, int size, PlayerInventory playerInventory) {
|
public Container(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size);
|
super(title, id, size, windowType);
|
||||||
this.playerInventory = playerInventory;
|
this.playerInventory = playerInventory;
|
||||||
this.containerSize = this.size + InventoryTranslator.PLAYER_INVENTORY_SIZE;
|
this.containerSize = this.size + InventoryTranslator.PLAYER_INVENTORY_SIZE;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.EnchantOptionData;
|
import com.nukkitx.protocol.bedrock.data.inventory.EnchantOptionData;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@ -40,8 +41,8 @@ public class EnchantingContainer extends Container {
|
|||||||
@Getter
|
@Getter
|
||||||
private final GeyserEnchantOption[] geyserEnchantOptions;
|
private final GeyserEnchantOption[] geyserEnchantOptions;
|
||||||
|
|
||||||
public EnchantingContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public EnchantingContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
|
|
||||||
enchantOptions = new EnchantOptionData[3];
|
enchantOptions = new EnchantOptionData[3];
|
||||||
geyserEnchantOptions = new GeyserEnchantOption[3];
|
geyserEnchantOptions = new GeyserEnchantOption[3];
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class Generic3X3Container extends Container {
|
public class Generic3X3Container extends Container {
|
||||||
@ -34,8 +35,8 @@ public class Generic3X3Container extends Container {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean isDropper = false;
|
private boolean isDropper = false;
|
||||||
|
|
||||||
public Generic3X3Container(String title, int id, int size, PlayerInventory playerInventory) {
|
public Generic3X3Container(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -41,6 +42,12 @@ public class Inventory {
|
|||||||
@Getter
|
@Getter
|
||||||
protected final int size;
|
protected final int size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for smooth transitions between two windows of the same type.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
protected final WindowType windowType;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
protected String title;
|
protected String title;
|
||||||
@ -65,14 +72,15 @@ public class Inventory {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean pending = false;
|
private boolean pending = false;
|
||||||
|
|
||||||
protected Inventory(int id, int size) {
|
protected Inventory(int id, int size, WindowType windowType) {
|
||||||
this("Inventory", id, size);
|
this("Inventory", id, size, windowType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Inventory(String title, int id, int size) {
|
protected Inventory(String title, int id, int size, WindowType windowType) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
this.windowType = windowType;
|
||||||
this.items = new GeyserItemStack[size];
|
this.items = new GeyserItemStack[size];
|
||||||
Arrays.fill(items, GeyserItemStack.EMPTY);
|
Arrays.fill(items, GeyserItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import com.nukkitx.nbt.NbtMap;
|
import com.nukkitx.nbt.NbtMap;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -38,7 +39,7 @@ public class LecternContainer extends Container {
|
|||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private Vector3i position;
|
private Vector3i position;
|
||||||
|
|
||||||
public LecternContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public LecternContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.window.VillagerTrade;
|
import com.github.steveice10.mc.protocol.data.game.window.VillagerTrade;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
@ -36,7 +37,7 @@ public class MerchantContainer extends Container {
|
|||||||
private Entity villager;
|
private Entity villager;
|
||||||
private VillagerTrade[] villagerTrades;
|
private VillagerTrade[] villagerTrades;
|
||||||
|
|
||||||
public MerchantContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public MerchantContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class PlayerInventory extends Inventory {
|
|||||||
private GeyserItemStack cursor = GeyserItemStack.EMPTY;
|
private GeyserItemStack cursor = GeyserItemStack.EMPTY;
|
||||||
|
|
||||||
public PlayerInventory() {
|
public PlayerInventory() {
|
||||||
super(0, 46);
|
super(0, 46, null);
|
||||||
heldItemSlot = 0;
|
heldItemSlot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.inventory;
|
package org.geysermc.connector.inventory;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -38,8 +39,8 @@ public class StonecutterContainer extends Container {
|
|||||||
@Setter
|
@Setter
|
||||||
private int stonecutterButton = -1;
|
private int stonecutterButton = -1;
|
||||||
|
|
||||||
public StonecutterContainer(String title, int id, int size, PlayerInventory playerInventory) {
|
public StonecutterContainer(String title, int id, int size, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
super(title, id, size, playerInventory);
|
super(title, id, size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,6 +139,6 @@ public class AnvilInventoryTranslator extends AbstractBlockInventoryTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new AnvilContainer(name, windowId, this.size, playerInventory);
|
return new AnvilContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,6 @@ public abstract class BaseInventoryTranslator extends InventoryTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new Container(name, windowId, this.size, playerInventory);
|
return new Container(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,6 @@ public class BeaconInventoryTranslator extends AbstractBlockInventoryTranslator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new BeaconContainer(name, windowId, this.size, playerInventory);
|
return new BeaconContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,6 @@ public class CartographyInventoryTranslator extends AbstractBlockInventoryTransl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new CartographyContainer(name, windowId, this.size, playerInventory);
|
return new CartographyContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new EnchantingContainer(name, windowId, this.size, playerInventory);
|
return new EnchantingContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ public class Generic3X3InventoryTranslator extends AbstractBlockInventoryTransla
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new Generic3X3Container(name, windowId, this.size, playerInventory);
|
return new Generic3X3Container(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,7 +151,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new LecternContainer(name, windowId, this.size, playerInventory);
|
return new LecternContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NbtMapBuilder getBaseLecternTag(int x, int y, int z, int totalPages) {
|
public static NbtMapBuilder getBaseLecternTag(int x, int y, int z, int totalPages) {
|
||||||
|
@ -157,6 +157,6 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new MerchantContainer(name, windowId, this.size, playerInventory);
|
return new MerchantContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,6 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
public Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory) {
|
||||||
return new StonecutterContainer(name, windowId, this.size, playerInventory);
|
return new StonecutterContainer(name, windowId, this.size, windowType, playerInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,6 @@ public class JavaOpenHorseWindowTranslator extends PacketTranslator<ServerOpenHo
|
|||||||
session.sendUpstreamPacket(updateEquipPacket);
|
session.sendUpstreamPacket(updateEquipPacket);
|
||||||
|
|
||||||
session.setInventoryTranslator(inventoryTranslator);
|
session.setInventoryTranslator(inventoryTranslator);
|
||||||
InventoryUtils.openInventory(session, new Container(entity.getMetadata().getString(EntityData.NAMETAG), packet.getWindowId(), packet.getNumberOfSlots(), session.getPlayerInventory()));
|
InventoryUtils.openInventory(session, new Container(entity.getMetadata().getString(EntityData.NAMETAG), packet.getWindowId(), packet.getNumberOfSlots(), null, session.getPlayerInventory()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
|
|||||||
Inventory newInventory = newTranslator.createInventory(name, packet.getWindowId(), packet.getType(), session.getPlayerInventory());
|
Inventory newInventory = newTranslator.createInventory(name, packet.getWindowId(), packet.getType(), session.getPlayerInventory());
|
||||||
if (openInventory != null) {
|
if (openInventory != null) {
|
||||||
// Sometimes the server can double-open an inventory with the same ID - don't confirm in that instance.
|
// Sometimes the server can double-open an inventory with the same ID - don't confirm in that instance.
|
||||||
InventoryUtils.closeInventory(session, openInventory.getId(), openInventory.getId() != packet.getWindowId());
|
// If the window type is the same, don't confirm; in rare cases, inventories can do funny things where it keeps the same window type up but change the contents.
|
||||||
|
InventoryUtils.closeInventory(session, openInventory.getId(), (openInventory.getId() != packet.getWindowId() && openInventory.getWindowType() != packet.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setInventoryTranslator(newTranslator);
|
session.setInventoryTranslator(newTranslator);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren