Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Implement dropper/dispenser, hopper, shulker
Dieser Commit ist enthalten in:
Ursprung
929b0ba80c
Commit
33a86485dc
@ -38,6 +38,7 @@ public class BedrockItemStackRequestTranslator extends PacketTranslator<ItemStac
|
||||
|
||||
@Override
|
||||
public void translate(ItemStackRequestPacket packet, GeyserSession session) {
|
||||
session.getConnector().getLogger().info(packet.toString());
|
||||
Inventory inventory = session.getOpenInventory();
|
||||
if (inventory == null)
|
||||
return;
|
||||
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.*;
|
||||
import com.nukkitx.protocol.bedrock.packet.ItemStackRequestPacket;
|
||||
@ -40,16 +41,12 @@ import org.geysermc.connector.inventory.PlayerInventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.inventory.click.Click;
|
||||
import org.geysermc.connector.network.translators.inventory.click.ClickPlan;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.CraftingInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.MerchantInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.PlayerInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.*;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.chest.DoubleChestInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.chest.SingleChestInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.furnace.BlastFurnaceInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.furnace.FurnaceInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.translators.furnace.SmokerInventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.ContainerInventoryUpdater;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;
|
||||
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
||||
import org.geysermc.connector.network.translators.item.ItemTranslator;
|
||||
import org.geysermc.connector.utils.InventoryUtils;
|
||||
@ -69,6 +66,7 @@ public abstract class InventoryTranslator {
|
||||
put(WindowType.GENERIC_9X5, new DoubleChestInventoryTranslator(45));
|
||||
put(WindowType.GENERIC_9X6, new DoubleChestInventoryTranslator(54));
|
||||
put(WindowType.CRAFTING, new CraftingInventoryTranslator());
|
||||
put(WindowType.SHULKER_BOX, new ShulkerInventoryTranslator());
|
||||
/*put(WindowType.BREWING_STAND, new BrewingInventoryTranslator());
|
||||
put(WindowType.ANVIL, new AnvilInventoryTranslator());
|
||||
put(WindowType.GRINDSTONE, new GrindstoneInventoryTranslator());*/
|
||||
@ -80,10 +78,8 @@ public abstract class InventoryTranslator {
|
||||
put(WindowType.BLAST_FURNACE, new BlastFurnaceInventoryTranslator());
|
||||
put(WindowType.SMOKER, new SmokerInventoryTranslator());
|
||||
|
||||
InventoryUpdater containerUpdater = new ContainerInventoryUpdater();
|
||||
//put(WindowType.GENERIC_3X3, new AbstractBlockInventoryTranslator(9, "minecraft:dispenser[facing=north,triggered=false]", ContainerType.DISPENSER, containerUpdater));
|
||||
//put(WindowType.HOPPER, new AbstractBlockInventoryTranslator(5, "minecraft:hopper[enabled=false,facing=down]", ContainerType.HOPPER, containerUpdater));
|
||||
//put(WindowType.SHULKER_BOX, new AbstractBlockInventoryTranslator(27, "minecraft:shulker_box[facing=north]", ContainerType.CONTAINER, containerUpdater));
|
||||
put(WindowType.GENERIC_3X3, new GenericBlockInventoryTranslator(9, "minecraft:dispenser[facing=north,triggered=false]", ContainerType.DISPENSER));
|
||||
put(WindowType.HOPPER, new GenericBlockInventoryTranslator(5, "minecraft:hopper[enabled=false,facing=down]", ContainerType.HOPPER));
|
||||
//put(WindowType.BEACON, new AbstractBlockInventoryTranslator(1, "minecraft:beacon", ContainerType.BEACON)); //TODO*/
|
||||
}
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ import org.geysermc.connector.network.translators.inventory.updater.CursorInvent
|
||||
|
||||
public class CraftingInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
public CraftingInventoryTranslator() {
|
||||
super(10, "minecraft:crafting_table", ContainerType.WORKBENCH, new CursorInventoryUpdater());
|
||||
super(10, "minecraft:crafting_table", ContainerType.WORKBENCH, CursorInventoryUpdater.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.inventory.translators;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import org.geysermc.connector.network.translators.inventory.BedrockContainerSlot;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.ContainerInventoryUpdater;
|
||||
|
||||
/**
|
||||
* Implemented on top of any block that does not have special properties implemented
|
||||
*/
|
||||
public class GenericBlockInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
public GenericBlockInventoryTranslator(int size, String javaBlockIdentifier, ContainerType containerType) {
|
||||
super(size, javaBlockIdentifier, containerType, ContainerInventoryUpdater.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot) {
|
||||
if (javaSlot < this.size) {
|
||||
return new BedrockContainerSlot(ContainerSlotType.CONTAINER, javaSlot);
|
||||
}
|
||||
return super.javaSlotToBedrockContainer(javaSlot);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.inventory.translators;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import org.geysermc.connector.network.translators.inventory.BedrockContainerSlot;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.ContainerInventoryUpdater;
|
||||
|
||||
public class ShulkerInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
public ShulkerInventoryTranslator() {
|
||||
super(27, "minecraft:shulker_box[facing=north]", ContainerType.CONTAINER, ContainerInventoryUpdater.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot) {
|
||||
if (javaSlot < this.size) {
|
||||
return new BedrockContainerSlot(ContainerSlotType.SHULKER, javaSlot);
|
||||
}
|
||||
return super.javaSlotToBedrockContainer(javaSlot);
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ import org.geysermc.connector.network.translators.inventory.updater.ContainerInv
|
||||
|
||||
public abstract class AbstractFurnaceInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
AbstractFurnaceInventoryTranslator(String javaBlockIdentifier, ContainerType containerType) {
|
||||
super(3, javaBlockIdentifier, containerType, new ContainerInventoryUpdater());
|
||||
super(3, javaBlockIdentifier, containerType, ContainerInventoryUpdater.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,11 +31,12 @@ 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.inventory.InventoryTranslator;
|
||||
import org.geysermc.connector.network.translators.item.ItemTranslator;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ContainerInventoryUpdater extends InventoryUpdater {
|
||||
public static final ContainerInventoryUpdater INSTANCE = new ContainerInventoryUpdater();
|
||||
|
||||
@Override
|
||||
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
|
||||
super.updateInventory(translator, session, inventory);
|
||||
|
@ -32,6 +32,7 @@ import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
||||
|
||||
public class CursorInventoryUpdater extends InventoryUpdater {
|
||||
public static final CursorInventoryUpdater INSTANCE = new CursorInventoryUpdater();
|
||||
|
||||
@Override
|
||||
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren