Translate window properties

Furnace and brewing stand
This commit is contained in:
AJ Ferguson 2019-12-07 14:56:00 -09:00
parent 211436c1e0
commit cdab1ce5ec
2 changed files with 21 additions and 9 deletions

View file

@ -36,22 +36,31 @@ public class BrewingStandInventoryTranslator extends BlockInventoryTranslator {
super(5, 117 << 4, ContainerType.BREWING_STAND); super(5, 117 << 4, ContainerType.BREWING_STAND);
} }
@Override
public void openInventory(GeyserSession session, Inventory inventory) {
super.openInventory(session, inventory);
ContainerSetDataPacket dataPacket = new ContainerSetDataPacket();
dataPacket.setWindowId((byte) inventory.getId());
dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL);
dataPacket.setValue(20);
session.getUpstream().sendPacket(dataPacket);
}
@Override @Override
public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) { public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) {
//bedrock protocol library is currently missing property mappings for windows.
ContainerSetDataPacket dataPacket = new ContainerSetDataPacket(); ContainerSetDataPacket dataPacket = new ContainerSetDataPacket();
dataPacket.setWindowId((byte) inventory.getId()); dataPacket.setWindowId((byte) inventory.getId());
switch (key) { switch (key) {
case 0: case 0:
dataPacket.setProperty(ContainerSetDataPacket.Property.BREWING_STAND_BREW_TIME); dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_BREW_TIME);
break; break;
case 1: case 1:
dataPacket.setProperty(ContainerSetDataPacket.Property.BREWING_STAND_FUEL_AMOUNT); dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_AMOUNT);
break; break;
default: default:
return; return;
} }
dataPacket.setValue((short) value); dataPacket.setValue(value);
session.getUpstream().sendPacket(dataPacket); session.getUpstream().sendPacket(dataPacket);
} }

View file

@ -25,6 +25,7 @@
package org.geysermc.connector.network.translators.inventory; package org.geysermc.connector.network.translators.inventory;
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
import com.nukkitx.protocol.bedrock.data.ContainerType; import com.nukkitx.protocol.bedrock.data.ContainerType;
import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket; import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
@ -37,23 +38,25 @@ public class FurnaceInventoryTranslator extends BlockInventoryTranslator {
@Override @Override
public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) { public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) {
//bedrock protocol library is currently missing property mappings for windows. only the furnace arrow will update for now
ContainerSetDataPacket dataPacket = new ContainerSetDataPacket(); ContainerSetDataPacket dataPacket = new ContainerSetDataPacket();
dataPacket.setWindowId((byte) inventory.getId()); dataPacket.setWindowId((byte) inventory.getId());
switch (key) { switch (key) {
case 0: case 0:
dataPacket.setProperty(ContainerSetDataPacket.Property.FURNACE_LIT_TIME); dataPacket.setProperty(ContainerSetDataPacket.FURNACE_LIT_TIME);
break; break;
case 1: case 1:
dataPacket.setProperty(ContainerSetDataPacket.Property.FURNACE_LIT_DURATION); dataPacket.setProperty(ContainerSetDataPacket.FURNACE_LIT_DURATION);
break; break;
case 2: case 2:
dataPacket.setProperty(ContainerSetDataPacket.Property.FURNACE_TICK_COUNT); dataPacket.setProperty(ContainerSetDataPacket.FURNACE_TICK_COUNT);
if (inventory.getWindowType() == WindowType.BLAST_FURNACE || inventory.getWindowType() == WindowType.SMOKER) {
value *= 2;
}
break; break;
default: default:
return; return;
} }
dataPacket.setValue((short) value); dataPacket.setValue(value);
session.getUpstream().sendPacket(dataPacket); session.getUpstream().sendPacket(dataPacket);
} }