Remove unneeded GeyserItemStack constructor and add comments

This commit is contained in:
Camotoy 2021-01-04 18:19:43 -05:00
parent 8928d554a1
commit 50f295b4cd
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
5 changed files with 12 additions and 8 deletions

View file

@ -91,11 +91,7 @@ public class GeyserItemStack {
}
public static GeyserItemStack from(ItemStack itemStack) {
return from(itemStack, 1);
}
public static GeyserItemStack from(ItemStack itemStack, int netId) {
return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getNbt(), netId);
return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getNbt());
}
public ItemStack getItemStack() {

View file

@ -757,7 +757,7 @@ public abstract class InventoryTranslator {
ItemStack javaCreativeItem = ItemTranslator.translateToJava(creativeItem);
if (isCursor(transferAction.getDestination())) {
session.getPlayerInventory().setCursor(GeyserItemStack.from(javaCreativeItem, session.getNextItemNetId()), session);
session.getPlayerInventory().setCursor(GeyserItemStack.from(javaCreativeItem), session);
return acceptRequest(request, Collections.singletonList(
new ItemStackResponsePacket.ContainerEntry(ContainerSlotType.CURSOR,
Collections.singletonList(makeItemEntry(0, session.getPlayerInventory().getCursor())))));
@ -769,7 +769,7 @@ public abstract class InventoryTranslator {
existingItem.setAmount(existingItem.getAmount() + transferAction.getCount());
javaCreativeItem = existingItem.getItemStack();
} else {
inventory.setItem(javaSlot, GeyserItemStack.from(javaCreativeItem, session.getNextItemNetId()), session);
inventory.setItem(javaSlot, GeyserItemStack.from(javaCreativeItem), session);
}
ClientCreativeInventoryActionPacket creativeActionPacket = new ClientCreativeInventoryActionPacket(
javaSlot,

View file

@ -86,7 +86,7 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
container.setStonecutterButton(button);
if (inventory.getItem(1).getJavaId() != javaOutput.getId()) {
// We don't know there is an output here, so we tell ourselves that there is
inventory.setItem(1, GeyserItemStack.from(javaOutput, session.getNextItemNetId()), session);
inventory.setItem(1, GeyserItemStack.from(javaOutput), session);
}
}
return translateRequest(session, inventory, request);

View file

@ -47,6 +47,11 @@ import org.geysermc.connector.network.translators.item.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* Used to send all valid recipes from Java to Bedrock.
*
* Bedrock REQUIRES a CraftingDataPacket to be sent in order to craft anything.
*/
@Translator(packet = ServerDeclareRecipesPacket.class)
public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclareRecipesPacket> {

View file

@ -33,6 +33,9 @@ import org.geysermc.connector.network.translators.Translator;
import java.util.Arrays;
/**
* Used to list recipes that we can definitely use the recipe book for (and therefore save on packet usage)
*/
@Translator(packet = ServerUnlockRecipesPacket.class)
public class JavaUnlockRecipesTranslator extends PacketTranslator<ServerUnlockRecipesPacket> {