Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Remove unneeded GeyserItemStack constructor and add comments
Dieser Commit ist enthalten in:
Ursprung
8928d554a1
Commit
50f295b4cd
@ -91,11 +91,7 @@ public class GeyserItemStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GeyserItemStack from(ItemStack itemStack) {
|
public static GeyserItemStack from(ItemStack itemStack) {
|
||||||
return from(itemStack, 1);
|
return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getNbt());
|
||||||
}
|
|
||||||
|
|
||||||
public static GeyserItemStack from(ItemStack itemStack, int netId) {
|
|
||||||
return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getNbt(), netId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack() {
|
||||||
|
@ -757,7 +757,7 @@ public abstract class InventoryTranslator {
|
|||||||
ItemStack javaCreativeItem = ItemTranslator.translateToJava(creativeItem);
|
ItemStack javaCreativeItem = ItemTranslator.translateToJava(creativeItem);
|
||||||
|
|
||||||
if (isCursor(transferAction.getDestination())) {
|
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(
|
return acceptRequest(request, Collections.singletonList(
|
||||||
new ItemStackResponsePacket.ContainerEntry(ContainerSlotType.CURSOR,
|
new ItemStackResponsePacket.ContainerEntry(ContainerSlotType.CURSOR,
|
||||||
Collections.singletonList(makeItemEntry(0, session.getPlayerInventory().getCursor())))));
|
Collections.singletonList(makeItemEntry(0, session.getPlayerInventory().getCursor())))));
|
||||||
@ -769,7 +769,7 @@ public abstract class InventoryTranslator {
|
|||||||
existingItem.setAmount(existingItem.getAmount() + transferAction.getCount());
|
existingItem.setAmount(existingItem.getAmount() + transferAction.getCount());
|
||||||
javaCreativeItem = existingItem.getItemStack();
|
javaCreativeItem = existingItem.getItemStack();
|
||||||
} else {
|
} else {
|
||||||
inventory.setItem(javaSlot, GeyserItemStack.from(javaCreativeItem, session.getNextItemNetId()), session);
|
inventory.setItem(javaSlot, GeyserItemStack.from(javaCreativeItem), session);
|
||||||
}
|
}
|
||||||
ClientCreativeInventoryActionPacket creativeActionPacket = new ClientCreativeInventoryActionPacket(
|
ClientCreativeInventoryActionPacket creativeActionPacket = new ClientCreativeInventoryActionPacket(
|
||||||
javaSlot,
|
javaSlot,
|
||||||
|
@ -86,7 +86,7 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
|
|||||||
container.setStonecutterButton(button);
|
container.setStonecutterButton(button);
|
||||||
if (inventory.getItem(1).getJavaId() != javaOutput.getId()) {
|
if (inventory.getItem(1).getJavaId() != javaOutput.getId()) {
|
||||||
// We don't know there is an output here, so we tell ourselves that there is
|
// 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);
|
return translateRequest(session, inventory, request);
|
||||||
|
@ -47,6 +47,11 @@ import org.geysermc.connector.network.translators.item.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
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)
|
@Translator(packet = ServerDeclareRecipesPacket.class)
|
||||||
public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclareRecipesPacket> {
|
public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclareRecipesPacket> {
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ import org.geysermc.connector.network.translators.Translator;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
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)
|
@Translator(packet = ServerUnlockRecipesPacket.class)
|
||||||
public class JavaUnlockRecipesTranslator extends PacketTranslator<ServerUnlockRecipesPacket> {
|
public class JavaUnlockRecipesTranslator extends PacketTranslator<ServerUnlockRecipesPacket> {
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren