mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix compile errors
This commit is contained in:
parent
bc3992f775
commit
bfca25bbe3
14 changed files with 58 additions and 77 deletions
|
@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.inventory;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryAction;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -42,7 +42,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(InventoryAction action) {
|
||||
public int bedrockSlotToJava(InventoryActionData action) {
|
||||
if (action.getSource().getContainerId() == ContainerId.CURSOR) {
|
||||
switch (action.getSlot()) {
|
||||
case 1:
|
||||
|
@ -77,10 +77,10 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryAction> actions) {
|
||||
InventoryAction anvilResult = null;
|
||||
InventoryAction anvilInput = null;
|
||||
for (InventoryAction action : actions) {
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
|
||||
InventoryActionData anvilResult = null;
|
||||
InventoryActionData anvilInput = null;
|
||||
for (InventoryActionData action : actions) {
|
||||
if (action.getSource().getContainerId() == ContainerId.ANVIL_MATERIAL) {
|
||||
//useless packet
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
|||
String rename;
|
||||
com.nukkitx.nbt.tag.CompoundTag tag = itemName.getTag();
|
||||
if (tag != null) {
|
||||
rename = tag.getAsCompound("display").getAsString("Name");
|
||||
rename = tag.getCompound("display").getString("Name");
|
||||
} else {
|
||||
rename = "";
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
package org.geysermc.connector.network.translators.inventory;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryAction;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryActionData;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.inventory.action.InventoryActionTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.action.InventoryActionDataTranslator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public abstract class BaseInventoryTranslator extends InventoryTranslator{
|
|||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(InventoryAction action) {
|
||||
public int bedrockSlotToJava(InventoryActionData action) {
|
||||
int slotnum = action.getSlot();
|
||||
if (action.getSource().getContainerId() == ContainerId.INVENTORY) {
|
||||
//hotbar
|
||||
|
@ -76,7 +76,7 @@ public abstract class BaseInventoryTranslator extends InventoryTranslator{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryAction> actions) {
|
||||
InventoryActionTranslator.translate(this, session, inventory, actions);
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
|
||||
InventoryActionDataTranslator.translate(this, session, inventory, actions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.inventory;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryAction;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryActionData;
|
||||
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -66,7 +66,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(InventoryAction action) {
|
||||
public int bedrockSlotToJava(InventoryActionData action) {
|
||||
final int slot = super.bedrockSlotToJava(action);
|
||||
switch (slot) {
|
||||
case 0:
|
||||
|
|
|
@ -28,13 +28,11 @@ package org.geysermc.connector.network.translators.inventory;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryAction;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.InventorySource;
|
||||
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;
|
||||
import org.geysermc.connector.utils.InventoryUtils;
|
||||
|
@ -80,7 +78,7 @@ public class CraftingInventoryTranslator extends BaseInventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(InventoryAction action) {
|
||||
public int bedrockSlotToJava(InventoryActionData action) {
|
||||
if (action.getSource().getContainerId() == ContainerId.CURSOR) {
|
||||
int slotnum = action.getSlot();
|
||||
if (slotnum >= 32 && 42 >= slotnum) {
|
||||
|
@ -105,9 +103,9 @@ public class CraftingInventoryTranslator extends BaseInventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryAction> actions) {
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
|
||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||
for (InventoryAction action : actions) {
|
||||
for (InventoryActionData action : actions) {
|
||||
if (action.getSource().getType() == InventorySource.Type.CREATIVE) {
|
||||
updateInventory(session, inventory);
|
||||
InventoryUtils.updateCursor(session);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.inventory;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryAction;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryActionData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -42,8 +42,8 @@ public abstract class InventoryTranslator {
|
|||
public abstract void updateProperty(GeyserSession session, Inventory inventory, int key, int value);
|
||||
public abstract void updateInventory(GeyserSession session, Inventory inventory);
|
||||
public abstract void updateSlot(GeyserSession session, Inventory inventory, int slot);
|
||||
public abstract int bedrockSlotToJava(InventoryAction action);
|
||||
public abstract int bedrockSlotToJava(InventoryActionData action);
|
||||
public abstract int javaSlotToBedrock(int slot);
|
||||
public abstract SlotType getSlotType(int javaSlot);
|
||||
public abstract void translateActions(GeyserSession session, Inventory inventory, List<InventoryAction> actions);
|
||||
public abstract void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
|
|||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||
import org.geysermc.connector.network.translators.inventory.action.InventoryActionTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.action.InventoryActionDataTranslator;
|
||||
import org.geysermc.connector.utils.InventoryUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -50,8 +50,8 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
for (int i = 1; i < 5; i++) {
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(ContainerId.CURSOR);
|
||||
slotPacket.setInventorySlot(i + 27);
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(i)));
|
||||
slotPacket.setSlot(i + 27);
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(i)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
}
|
||||
|
||||
|
@ -93,18 +93,18 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
if (slot >= 9) {
|
||||
slotPacket.setContainerId(ContainerId.INVENTORY);
|
||||
if (slot >= 36) {
|
||||
slotPacket.setInventorySlot(slot - 36);
|
||||
slotPacket.setSlot(slot - 36);
|
||||
} else {
|
||||
slotPacket.setInventorySlot(slot);
|
||||
slotPacket.setSlot(slot);
|
||||
}
|
||||
} else if (slot >= 5) {
|
||||
slotPacket.setContainerId(ContainerId.ARMOR);
|
||||
slotPacket.setInventorySlot(slot - 5);
|
||||
slotPacket.setSlot(slot - 5);
|
||||
} else {
|
||||
slotPacket.setContainerId(ContainerId.CURSOR);
|
||||
slotPacket.setInventorySlot(slot + 27);
|
||||
slotPacket.setSlot(slot + 27);
|
||||
}
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(slot)));
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(slot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
} else if (slot == 45) {
|
||||
InventoryContentPacket offhandPacket = new InventoryContentPacket();
|
||||
|
@ -115,7 +115,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(InventoryAction action) {
|
||||
public int bedrockSlotToJava(InventoryActionData action) {
|
||||
int slotnum = action.getSlot();
|
||||
switch (action.getSource().getContainerId()) {
|
||||
case ContainerId.INVENTORY:
|
||||
|
@ -159,10 +159,10 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryAction> actions) {
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
|
||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||
//crafting grid is not visible in creative mode in java edition
|
||||
for (InventoryAction action : actions) {
|
||||
for (InventoryActionData action : actions) {
|
||||
if (action.getSource().getContainerId() == ContainerId.CURSOR && (action.getSlot() >= 28 && 31 >= action.getSlot())) {
|
||||
updateInventory(session, inventory);
|
||||
InventoryUtils.updateCursor(session);
|
||||
|
@ -171,7 +171,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
}
|
||||
|
||||
ItemStack javaItem;
|
||||
for (InventoryAction action : actions) {
|
||||
for (InventoryActionData action : actions) {
|
||||
switch (action.getSource().getContainerId()) {
|
||||
case ContainerId.INVENTORY:
|
||||
case ContainerId.ARMOR:
|
||||
|
@ -204,7 +204,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
return;
|
||||
}
|
||||
|
||||
InventoryActionTranslator.translate(this, session, inventory, actions);
|
||||
InventoryActionDataTranslator.translate(this, session, inventory, actions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientWindowActionPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryAction;
|
||||
import com.nukkitx.protocol.bedrock.data.InventoryActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.InventorySource;
|
||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
|
@ -45,16 +45,16 @@ import org.geysermc.connector.utils.InventoryUtils;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class InventoryActionTranslator {
|
||||
public static void translate(InventoryTranslator translator, GeyserSession session, Inventory inventory, List<InventoryAction> actions) {
|
||||
public class InventoryActionDataTranslator {
|
||||
public static void translate(InventoryTranslator translator, GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
|
||||
if (actions.size() != 2)
|
||||
return;
|
||||
|
||||
InventoryAction worldAction = null;
|
||||
InventoryAction cursorAction = null;
|
||||
InventoryAction containerAction = null;
|
||||
InventoryActionData worldAction = null;
|
||||
InventoryActionData cursorAction = null;
|
||||
InventoryActionData containerAction = null;
|
||||
boolean refresh = false;
|
||||
for (InventoryAction action : actions) {
|
||||
for (InventoryActionData action : actions) {
|
||||
if (action.getSource().getContainerId() == ContainerId.CRAFTING_USE_INGREDIENT || action.getSource().getContainerId() == ContainerId.CRAFTING_RESULT) {
|
||||
return;
|
||||
} else if (action.getSource().getType() == InventorySource.Type.WORLD_INTERACTION) {
|
||||
|
@ -78,7 +78,7 @@ public class InventoryActionTranslator {
|
|||
session.setCraftSlot(0);
|
||||
|
||||
if (worldAction != null) {
|
||||
InventoryAction sourceAction;
|
||||
InventoryActionData sourceAction;
|
||||
if (cursorAction != null) {
|
||||
sourceAction = cursorAction;
|
||||
} else {
|
||||
|
@ -208,8 +208,8 @@ public class InventoryActionTranslator {
|
|||
return;
|
||||
} else {
|
||||
ClickPlan plan = new ClickPlan();
|
||||
InventoryAction fromAction;
|
||||
InventoryAction toAction;
|
||||
InventoryActionData fromAction;
|
||||
InventoryActionData toAction;
|
||||
if (actions.get(0).getFromItem().getCount() >= actions.get(0).getToItem().getCount()) {
|
||||
fromAction = actions.get(0);
|
||||
toAction = actions.get(1);
|
|
@ -64,8 +64,8 @@ public class ChestInventoryUpdater extends InventoryUpdater {
|
|||
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(inventory.getId());
|
||||
slotPacket.setInventorySlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
|
|||
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(inventory.getId());
|
||||
slotPacket.setInventorySlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ public class CursorInventoryUpdater extends InventoryUpdater {
|
|||
continue;
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(ContainerId.CURSOR);
|
||||
slotPacket.setInventorySlot(bedrockSlot);
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(i)));
|
||||
slotPacket.setSlot(bedrockSlot);
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(i)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ public class CursorInventoryUpdater extends InventoryUpdater {
|
|||
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(ContainerId.CURSOR);
|
||||
slotPacket.setInventorySlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public abstract class InventoryUpdater {
|
|||
if (javaSlot >= translator.size) {
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(ContainerId.INVENTORY);
|
||||
slotPacket.setInventorySlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -189,13 +189,13 @@ public class ItemTranslator {
|
|||
continue;
|
||||
|
||||
com.nukkitx.nbt.tag.CompoundTag tagValue = (com.nukkitx.nbt.tag.CompoundTag) value;
|
||||
int bedrockId = tagValue.getAsShort("id", (short) -1);
|
||||
int bedrockId = tagValue.getShort("id", (short) -1);
|
||||
Enchantment enchantment = Enchantment.getByBedrockId(bedrockId);
|
||||
if (enchantment != null) {
|
||||
CompoundTag javaTag = new CompoundTag("");
|
||||
Map<String, Tag> javaValue = javaTag.getValue();
|
||||
javaValue.put("id", new StringTag("id", enchantment.getJavaIdentifier()));
|
||||
javaValue.put("lvl", new IntTag("lvl", tagValue.getAsShort("lvl", (short) 1)));
|
||||
javaValue.put("lvl", new IntTag("lvl", tagValue.getShort("lvl", (short) 1)));
|
||||
javaTag.setValue(javaValue);
|
||||
tags.add(javaTag);
|
||||
} else {
|
||||
|
|
|
@ -82,8 +82,8 @@ public class InventoryUtils {
|
|||
public static void updateCursor(GeyserSession session) {
|
||||
InventorySlotPacket cursorPacket = new InventorySlotPacket();
|
||||
cursorPacket.setContainerId(ContainerId.CURSOR);
|
||||
cursorPacket.setInventorySlot(0);
|
||||
cursorPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(session.getInventory().getCursor()));
|
||||
cursorPacket.setSlot(0);
|
||||
cursorPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(session.getInventory().getCursor()));
|
||||
session.getUpstream().sendPacket(cursorPacket);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,21 +53,4 @@ public class ChunkPosition {
|
|||
|
||||
return new Position(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof ChunkPosition))
|
||||
return false;
|
||||
ChunkPosition other = (ChunkPosition)obj;
|
||||
return x == other.x && z == other.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, z);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue