mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-29 15:49:09 +01:00
Handful of review fixes
This commit is contained in:
parent
82ccfb1417
commit
821e3126ea
8 changed files with 33 additions and 31 deletions
|
@ -27,10 +27,13 @@ package org.geysermc.connector.inventory;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
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
|
||||
private boolean isDropper = false;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
|||
new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()),
|
||||
BlockFace.values()[0],
|
||||
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);
|
||||
session.sendDownstreamPacket(blockPacket);
|
||||
} else {
|
||||
|
@ -78,7 +78,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
|||
int currentJavaPage = (lecternContainer.getCurrentBedrockPage() * 2);
|
||||
// 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
|
||||
// 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) {
|
||||
for (int i = currentJavaPage; i < newJavaPage; i++) {
|
||||
ClientClickWindowButtonPacket clickButtonPacket = new ClientClickWindowButtonPacket(session.getOpenInventory().getId(), 2);
|
||||
|
|
|
@ -108,8 +108,8 @@ public abstract class InventoryTranslator {
|
|||
public abstract void updateInventory(GeyserSession session, Inventory inventory);
|
||||
public abstract void updateSlot(GeyserSession session, Inventory inventory, int slot);
|
||||
public abstract int bedrockSlotToJava(StackRequestSlotInfoData slotInfoData);
|
||||
public abstract int javaSlotToBedrock(int javaSlot); //TODO
|
||||
public abstract BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot); //TODO
|
||||
public abstract int javaSlotToBedrock(int javaSlot);
|
||||
public abstract BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot);
|
||||
public abstract SlotType getSlotType(int javaSlot);
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
|
@ -151,15 +151,22 @@ public abstract class InventoryTranslator {
|
|||
if (shouldHandleRequestFirst(firstAction, inventory)) {
|
||||
// Some special request that shouldn't be processed normally
|
||||
response = translateSpecialRequest(session, inventory, request);
|
||||
} else if (firstAction.getType() == StackRequestActionType.CRAFT_RECIPE) {
|
||||
response = translateCraftingRequest(session, inventory, request);
|
||||
} else if (firstAction.getType() == StackRequestActionType.CRAFT_RECIPE_AUTO) {
|
||||
response = translateAutoCraftingRequest(session, inventory, request);
|
||||
} else if (firstAction.getType() == StackRequestActionType.CRAFT_CREATIVE) {
|
||||
// This is also used for pulling items out of creative
|
||||
response = translateCreativeRequest(session, inventory, request);
|
||||
} else {
|
||||
response = translateRequest(session, inventory, request);
|
||||
switch (firstAction.getType()) {
|
||||
case CRAFT_RECIPE:
|
||||
response = translateCraftingRequest(session, inventory, request);
|
||||
break;
|
||||
case CRAFT_RECIPE_AUTO:
|
||||
response = translateAutoCraftingRequest(session, inventory, request);
|
||||
break;
|
||||
case CRAFT_CREATIVE:
|
||||
// This is also used for pulling items out of creative
|
||||
response = translateCreativeRequest(session, inventory, request);
|
||||
break;
|
||||
default:
|
||||
response = translateRequest(session, inventory, request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response = rejectRequest(request);
|
||||
|
@ -693,8 +700,10 @@ public abstract class InventoryTranslator {
|
|||
return acceptRequest(request, makeContainerEntries(session, inventory, plan.getAffectedSlots()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handled in {@link PlayerInventoryTranslator}
|
||||
*/
|
||||
public ItemStackResponsePacket.Response translateCreativeRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) {
|
||||
// Handled in PlayerInventoryTranslator
|
||||
return rejectRequest(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,22 +51,19 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
|||
|
||||
public LecternInventoryTranslator() {
|
||||
super(1);
|
||||
this.updater = new LecternInventoryUpdater();
|
||||
this.updater = new InventoryUpdater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,7 +78,6 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
|||
|
||||
@Override
|
||||
public void updateInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -171,8 +167,4 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
|||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static class LecternInventoryUpdater extends InventoryUpdater {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,17 +41,14 @@ public abstract class AbstractHorseInventoryTranslator extends BaseInventoryTran
|
|||
|
||||
@Override
|
||||
public void prepareInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(GeyserSession session, Inventory inventory) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class InventoryUpdater {
|
||||
public class InventoryUpdater {
|
||||
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
|
||||
ItemData[] bedrockItems = new ItemData[36];
|
||||
for (int i = 0; i < 36; i++) {
|
||||
|
|
|
@ -134,7 +134,6 @@ public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket>
|
|||
height += -firstRow + 1;
|
||||
width += -firstCol + 1;
|
||||
|
||||
//TODO
|
||||
recipes:
|
||||
for (Recipe recipe : session.getCraftingRecipes().values()) {
|
||||
if (recipe.getType() == RecipeType.CRAFTING_SHAPED) {
|
||||
|
|
|
@ -112,8 +112,6 @@ public abstract class BlockTranslator {
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -413,6 +411,10 @@ public abstract class BlockTranslator {
|
|||
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 byte[] getEmptyChunkData() {
|
||||
|
|
Loading…
Reference in a new issue