3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 08:10:11 +01:00

Handful of review fixes

Dieser Commit ist enthalten in:
Camotoy 2021-03-12 11:51:37 -05:00
Ursprung 82ccfb1417
Commit 821e3126ea
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
8 geänderte Dateien mit 33 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -27,10 +27,13 @@ package org.geysermc.connector.inventory;
import com.github.steveice10.mc.protocol.data.game.window.WindowType; import com.github.steveice10.mc.protocol.data.game.window.WindowType;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.network.session.GeyserSession;
public class Generic3X3Container extends Container { public class Generic3X3Container extends Container {
/** /**
* Whether we need to set the container type as {@link com.nukkitx.protocol.bedrock.data.inventory.ContainerType#DROPPER} * Whether we need to set the container type as {@link com.nukkitx.protocol.bedrock.data.inventory.ContainerType#DROPPER}.
*
* Used at {@link org.geysermc.connector.network.translators.inventory.translators.Generic3X3InventoryTranslator#openInventory(GeyserSession, Inventory)}
*/ */
@Getter @Getter
private boolean isDropper = false; private boolean isDropper = false;

Datei anzeigen

@ -56,7 +56,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()),
BlockFace.values()[0], BlockFace.values()[0],
Hand.MAIN_HAND, Hand.MAIN_HAND,
packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ(), //TODO 0, 0, 0, // Java doesn't care about these when dealing with a lectern
false); false);
session.sendDownstreamPacket(blockPacket); session.sendDownstreamPacket(blockPacket);
} else { } else {
@ -78,7 +78,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
int currentJavaPage = (lecternContainer.getCurrentBedrockPage() * 2); int currentJavaPage = (lecternContainer.getCurrentBedrockPage() * 2);
// Send as many click button packets as we need to // Send as many click button packets as we need to
// Java has the option to specify exact page numbers by adding 100 to the number, but buttonId variable // Java has the option to specify exact page numbers by adding 100 to the number, but buttonId variable
// is a byte and therefore this stops us at 128 // is a byte when transmitted over the network and therefore this stops us at 128
if (newJavaPage > currentJavaPage) { if (newJavaPage > currentJavaPage) {
for (int i = currentJavaPage; i < newJavaPage; i++) { for (int i = currentJavaPage; i < newJavaPage; i++) {
ClientClickWindowButtonPacket clickButtonPacket = new ClientClickWindowButtonPacket(session.getOpenInventory().getId(), 2); ClientClickWindowButtonPacket clickButtonPacket = new ClientClickWindowButtonPacket(session.getOpenInventory().getId(), 2);

Datei anzeigen

@ -108,8 +108,8 @@ public abstract class InventoryTranslator {
public abstract void updateInventory(GeyserSession session, Inventory inventory); public abstract void updateInventory(GeyserSession session, Inventory inventory);
public abstract void updateSlot(GeyserSession session, Inventory inventory, int slot); public abstract void updateSlot(GeyserSession session, Inventory inventory, int slot);
public abstract int bedrockSlotToJava(StackRequestSlotInfoData slotInfoData); public abstract int bedrockSlotToJava(StackRequestSlotInfoData slotInfoData);
public abstract int javaSlotToBedrock(int javaSlot); //TODO public abstract int javaSlotToBedrock(int javaSlot);
public abstract BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot); //TODO public abstract BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot);
public abstract SlotType getSlotType(int javaSlot); public abstract SlotType getSlotType(int javaSlot);
public abstract Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory); public abstract Inventory createInventory(String name, int windowId, WindowType windowType, PlayerInventory playerInventory);
@ -138,7 +138,7 @@ public abstract class InventoryTranslator {
* If {@link #shouldHandleRequestFirst(StackRequestActionData, Inventory)} returns true, this will be called * If {@link #shouldHandleRequestFirst(StackRequestActionData, Inventory)} returns true, this will be called
*/ */
public ItemStackResponsePacket.Response translateSpecialRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) { public ItemStackResponsePacket.Response translateSpecialRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) {
return null; return rejectRequest(request);
} }
public void translateRequests(GeyserSession session, Inventory inventory, List<ItemStackRequest> requests) { public void translateRequests(GeyserSession session, Inventory inventory, List<ItemStackRequest> requests) {
@ -151,15 +151,22 @@ public abstract class InventoryTranslator {
if (shouldHandleRequestFirst(firstAction, inventory)) { if (shouldHandleRequestFirst(firstAction, inventory)) {
// Some special request that shouldn't be processed normally // Some special request that shouldn't be processed normally
response = translateSpecialRequest(session, inventory, request); response = translateSpecialRequest(session, inventory, request);
} else if (firstAction.getType() == StackRequestActionType.CRAFT_RECIPE) { } else {
switch (firstAction.getType()) {
case CRAFT_RECIPE:
response = translateCraftingRequest(session, inventory, request); response = translateCraftingRequest(session, inventory, request);
} else if (firstAction.getType() == StackRequestActionType.CRAFT_RECIPE_AUTO) { break;
case CRAFT_RECIPE_AUTO:
response = translateAutoCraftingRequest(session, inventory, request); response = translateAutoCraftingRequest(session, inventory, request);
} else if (firstAction.getType() == StackRequestActionType.CRAFT_CREATIVE) { break;
case CRAFT_CREATIVE:
// This is also used for pulling items out of creative // This is also used for pulling items out of creative
response = translateCreativeRequest(session, inventory, request); response = translateCreativeRequest(session, inventory, request);
} else { break;
default:
response = translateRequest(session, inventory, request); response = translateRequest(session, inventory, request);
break;
}
} }
} else { } else {
response = rejectRequest(request); response = rejectRequest(request);
@ -693,8 +700,10 @@ public abstract class InventoryTranslator {
return acceptRequest(request, makeContainerEntries(session, inventory, plan.getAffectedSlots())); return acceptRequest(request, makeContainerEntries(session, inventory, plan.getAffectedSlots()));
} }
/**
* Handled in {@link PlayerInventoryTranslator}
*/
public ItemStackResponsePacket.Response translateCreativeRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) { public ItemStackResponsePacket.Response translateCreativeRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) {
// Handled in PlayerInventoryTranslator
return rejectRequest(request); return rejectRequest(request);
} }

Datei anzeigen

@ -51,22 +51,19 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
public LecternInventoryTranslator() { public LecternInventoryTranslator() {
super(1); super(1);
this.updater = new LecternInventoryUpdater(); this.updater = new InventoryUpdater();
} }
@Override @Override
public void prepareInventory(GeyserSession session, Inventory inventory) { public void prepareInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override
public void openInventory(GeyserSession session, Inventory inventory) { public void openInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override
public void closeInventory(GeyserSession session, Inventory inventory) { public void closeInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override
@ -81,7 +78,6 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
@Override @Override
public void updateInventory(GeyserSession session, Inventory inventory) { public void updateInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override
@ -171,8 +167,4 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
} }
return builder; return builder;
} }
private static class LecternInventoryUpdater extends InventoryUpdater {
}
} }

Datei anzeigen

@ -41,17 +41,14 @@ public abstract class AbstractHorseInventoryTranslator extends BaseInventoryTran
@Override @Override
public void prepareInventory(GeyserSession session, Inventory inventory) { public void prepareInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override
public void openInventory(GeyserSession session, Inventory inventory) { public void openInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override
public void closeInventory(GeyserSession session, Inventory inventory) { public void closeInventory(GeyserSession session, Inventory inventory) {
} }
@Override @Override

Datei anzeigen

@ -35,7 +35,7 @@ import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
import java.util.Arrays; import java.util.Arrays;
public abstract class InventoryUpdater { public class InventoryUpdater {
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) { public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
ItemData[] bedrockItems = new ItemData[36]; ItemData[] bedrockItems = new ItemData[36];
for (int i = 0; i < 36; i++) { for (int i = 0; i < 36; i++) {

Datei anzeigen

@ -134,7 +134,6 @@ public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket>
height += -firstRow + 1; height += -firstRow + 1;
width += -firstCol + 1; width += -firstCol + 1;
//TODO
recipes: recipes:
for (Recipe recipe : session.getCraftingRecipes().values()) { for (Recipe recipe : session.getCraftingRecipes().values()) {
if (recipe.getType() == RecipeType.CRAFTING_SHAPED) { if (recipe.getType() == RecipeType.CRAFTING_SHAPED) {

Datei anzeigen

@ -112,8 +112,6 @@ public abstract class BlockTranslator {
*/ */
private final Map<String, NbtMap> javaIdentifierToBedrockTag; private final Map<String, NbtMap> javaIdentifierToBedrockTag;
private static final int BLOCK_STATE_VERSION = 17825808;
/** /**
* Stores the raw blocks JSON until it is no longer needed. * Stores the raw blocks JSON until it is no longer needed.
*/ */
@ -413,6 +411,10 @@ public abstract class BlockTranslator {
return bedrockWaterId; return bedrockWaterId;
} }
/**
* @return the "block state version" generated in the Bedrock block palette that completes an NBT indication of a
* block state.
*/
public abstract int getBlockStateVersion(); public abstract int getBlockStateVersion();
public byte[] getEmptyChunkData() { public byte[] getEmptyChunkData() {