mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add grindstone and smithing table
This commit is contained in:
parent
c6b4d163a1
commit
009905184e
4 changed files with 205 additions and 3 deletions
|
@ -73,9 +73,9 @@ public abstract class InventoryTranslator {
|
|||
put(WindowType.SHULKER_BOX, new ShulkerInventoryTranslator());
|
||||
put(WindowType.BREWING_STAND, new BrewingInventoryTranslator());
|
||||
//put(WindowType.ANVIL, new AnvilInventoryTranslator());
|
||||
//put(WindowType.GRINDSTONE, new GrindstoneInventoryTranslator());
|
||||
put(WindowType.GRINDSTONE, new GrindstoneInventoryTranslator());
|
||||
put(WindowType.MERCHANT, new MerchantInventoryTranslator());
|
||||
//put(WindowType.SMITHING, new SmithingInventoryTranslator());
|
||||
put(WindowType.SMITHING, new SmithingInventoryTranslator());
|
||||
//put(WindowType.ENCHANTMENT, new EnchantmentInventoryTranslator()); //TODO
|
||||
|
||||
put(WindowType.FURNACE, new FurnaceInventoryTranslator());
|
||||
|
@ -154,7 +154,7 @@ public abstract class InventoryTranslator {
|
|||
|
||||
if (isCursor(transferAction.getSource()) && isCursor(transferAction.getDestination())) { //???
|
||||
return rejectRequest(request);
|
||||
} else if (session.getGameMode().equals(GameMode.CREATIVE) && inventory instanceof PlayerInventory) { // TODO: does the Java server use the player inventory in all instances?
|
||||
} else if (session.getGameMode().equals(GameMode.CREATIVE) && inventory instanceof PlayerInventory) { // TODO: does the Java server use this stuff all the time in creative?
|
||||
// Creative acts a little differently because it just edits slots
|
||||
int sourceSlot = bedrockSlotToJava(transferAction.getSource());
|
||||
int destSlot = bedrockSlotToJava(transferAction.getDestination());
|
||||
|
@ -369,6 +369,7 @@ public abstract class InventoryTranslator {
|
|||
return rejectRequest(request);
|
||||
}
|
||||
if (!isCursor(destroyAction.getSource())) {
|
||||
// Item exists; let's remove it from the inventory
|
||||
int javaSlot = bedrockSlotToJava(destroyAction.getSource());
|
||||
ClientCreativeInventoryActionPacket destroyItemPacket = new ClientCreativeInventoryActionPacket(
|
||||
javaSlot,
|
||||
|
@ -384,6 +385,16 @@ public abstract class InventoryTranslator {
|
|||
}
|
||||
break;
|
||||
}
|
||||
// These three are called for the grindstone
|
||||
case CONSUME: {
|
||||
break;
|
||||
}
|
||||
case CRAFT_NON_IMPLEMENTED_DEPRECATED: {
|
||||
break;
|
||||
}
|
||||
case CRAFT_RESULTS_DEPRECATED: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return rejectRequest(request);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.ContainerType;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater;
|
||||
|
||||
public class EnchantingInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
public EnchantingInventoryTranslator() {
|
||||
super(2, "minecraft:enchanting_table", ContainerType.ENCHANTMENT, CursorInventoryUpdater.INSTANCE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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 com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData;
|
||||
import org.geysermc.connector.network.translators.inventory.BedrockContainerSlot;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater;
|
||||
|
||||
public class GrindstoneInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
public GrindstoneInventoryTranslator() {
|
||||
super(3, "minecraft:grindstone[face=floor,facing=north]", ContainerType.GRINDSTONE, CursorInventoryUpdater.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(StackRequestSlotInfoData slotInfoData) {
|
||||
if (slotInfoData.getContainer() == ContainerSlotType.GRINDSTONE_INPUT) {
|
||||
return 0;
|
||||
}
|
||||
if (slotInfoData.getContainer() == ContainerSlotType.GRINDSTONE_ADDITIONAL) {
|
||||
return 1;
|
||||
}
|
||||
if (slotInfoData.getContainer() == ContainerSlotType.GRINDSTONE_RESULT || slotInfoData.getContainer() == ContainerSlotType.CREATIVE_OUTPUT) {
|
||||
return 2;
|
||||
}
|
||||
return super.bedrockSlotToJava(slotInfoData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BedrockContainerSlot javaSlotToBedrockContainer(int slot) {
|
||||
switch (slot) {
|
||||
case 0:
|
||||
return new BedrockContainerSlot(ContainerSlotType.GRINDSTONE_INPUT, 16);
|
||||
case 1:
|
||||
return new BedrockContainerSlot(ContainerSlotType.GRINDSTONE_ADDITIONAL, 17);
|
||||
case 2:
|
||||
return new BedrockContainerSlot(ContainerSlotType.GRINDSTONE_RESULT, 50);
|
||||
}
|
||||
return super.javaSlotToBedrockContainer(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int javaSlotToBedrock(int slot) {
|
||||
switch (slot) {
|
||||
case 0:
|
||||
return 16;
|
||||
case 1:
|
||||
return 17;
|
||||
case 2:
|
||||
return 50;
|
||||
}
|
||||
return super.javaSlotToBedrock(slot);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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 com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData;
|
||||
import org.geysermc.connector.network.translators.inventory.BedrockContainerSlot;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater;
|
||||
|
||||
public class SmithingInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
public SmithingInventoryTranslator() {
|
||||
super(3, "minecraft:smithing_table", ContainerType.SMITHING_TABLE, CursorInventoryUpdater.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(StackRequestSlotInfoData slotInfoData) {
|
||||
if (slotInfoData.getContainer() == ContainerSlotType.SMITHING_TABLE_INPUT) {
|
||||
return 0;
|
||||
}
|
||||
if (slotInfoData.getContainer() == ContainerSlotType.SMITHING_TABLE_MATERIAL) {
|
||||
return 1;
|
||||
}
|
||||
if (slotInfoData.getContainer() == ContainerSlotType.SMITHING_TABLE_RESULT || slotInfoData.getContainer() == ContainerSlotType.CREATIVE_OUTPUT) {
|
||||
return 2;
|
||||
}
|
||||
return super.bedrockSlotToJava(slotInfoData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BedrockContainerSlot javaSlotToBedrockContainer(int slot) {
|
||||
switch (slot) {
|
||||
case 0:
|
||||
return new BedrockContainerSlot(ContainerSlotType.SMITHING_TABLE_INPUT, 51);
|
||||
case 1:
|
||||
return new BedrockContainerSlot(ContainerSlotType.SMITHING_TABLE_MATERIAL, 52);
|
||||
case 2:
|
||||
return new BedrockContainerSlot(ContainerSlotType.SMITHING_TABLE_RESULT, 50);
|
||||
}
|
||||
return super.javaSlotToBedrockContainer(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int javaSlotToBedrock(int slot) {
|
||||
switch (slot) {
|
||||
case 0:
|
||||
return 51;
|
||||
case 1:
|
||||
return 52;
|
||||
case 2:
|
||||
return 50;
|
||||
}
|
||||
return super.javaSlotToBedrock(slot);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue