Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +01:00
Implement remainder slot display recipes
Dieser Commit ist enthalten in:
Ursprung
52679f9f81
Commit
8ba70f0fc8
@ -858,6 +858,7 @@ public final class EntityDefinitions {
|
|||||||
SALMON = EntityDefinition.inherited(abstractFishEntityBase.factory(), abstractFishEntityBase)
|
SALMON = EntityDefinition.inherited(abstractFishEntityBase.factory(), abstractFishEntityBase)
|
||||||
.type(EntityType.SALMON)
|
.type(EntityType.SALMON)
|
||||||
.height(0.5f).width(0.7f)
|
.height(0.5f).width(0.7f)
|
||||||
|
.addTranslator(null) // Scale/variant - TODO
|
||||||
.build();
|
.build();
|
||||||
TADPOLE = EntityDefinition.inherited(TadpoleEntity::new, abstractFishEntityBase)
|
TADPOLE = EntityDefinition.inherited(TadpoleEntity::new, abstractFishEntityBase)
|
||||||
.type(EntityType.TADPOLE)
|
.type(EntityType.TADPOLE)
|
||||||
|
@ -74,6 +74,7 @@ public class JavaFinishConfigurationTranslator extends PacketTranslator<Clientbo
|
|||||||
session.getUpstream().sendPacket(craftingDataPacket);
|
session.getUpstream().sendPacket(craftingDataPacket);
|
||||||
session.getCraftingRecipes().clear();
|
session.getCraftingRecipes().clear();
|
||||||
session.getJavaToBedrockRecipeIds().clear();
|
session.getJavaToBedrockRecipeIds().clear();
|
||||||
|
session.getSmithingRecipes().clear();
|
||||||
session.getStonecutterRecipes().clear();
|
session.getStonecutterRecipes().clear();
|
||||||
} else {
|
} else {
|
||||||
session.getUpstream().queuePostStartGamePacket(craftingDataPacket);
|
session.getUpstream().queuePostStartGamePacket(craftingDataPacket);
|
||||||
|
@ -67,6 +67,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.ItemSta
|
|||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SmithingTrimDemoSlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SmithingTrimDemoSlotDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.WithRemainderSlotDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundRecipeBookAddPacket;
|
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundRecipeBookAddPacket;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -208,6 +209,10 @@ public class JavaRecipeBookAddTranslator extends PacketTranslator<ClientboundRec
|
|||||||
.flatMap(List::stream)
|
.flatMap(List::stream)
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
if (slotDisplay instanceof WithRemainderSlotDisplay remainder) {
|
||||||
|
// Don't need to worry about what will stay in the crafting table after crafting for the purposes of sending recipes to Bedrock
|
||||||
|
return translateToInput(session, remainder.input());
|
||||||
|
}
|
||||||
if (slotDisplay instanceof ItemSlotDisplay itemSlot) {
|
if (slotDisplay instanceof ItemSlotDisplay itemSlot) {
|
||||||
return Collections.singletonList(fromItem(session, itemSlot.item()));
|
return Collections.singletonList(fromItem(session, itemSlot.item()));
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
@Translator(packet = ClientboundSelectKnownPacks.class)
|
@Translator(packet = ClientboundSelectKnownPacks.class)
|
||||||
public class JavaSelectKnownPacksTranslator extends PacketTranslator<ClientboundSelectKnownPacks> {
|
public class JavaSelectKnownPacksTranslator extends PacketTranslator<ClientboundSelectKnownPacks> {
|
||||||
// todo: dump from client?
|
// todo: dump from client?
|
||||||
private static final Set<String> KNOWN_PACK_IDS = Set.of("core", "update_1_21", "bundle", "trade_rebalance");
|
private static final Set<String> KNOWN_PACK_IDS = Set.of("core", "winter_drop", "trade_rebalance", "redstone_experiments", "minecart_improvements");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundSelectKnownPacks packet) {
|
public void translate(GeyserSession session, ClientboundSelectKnownPacks packet) {
|
||||||
@ -62,6 +62,7 @@ public class JavaSelectKnownPacksTranslator extends PacketTranslator<Clientbound
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecuteInEventLoop() {
|
public boolean shouldExecuteInEventLoop() {
|
||||||
|
// This technically isn't correct behavior, but it prevents race conditions between MCProtocolLib's packet handler and ours.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,14 +268,12 @@ public class JavaContainerSetSlotTranslator extends PacketTranslator<Clientbound
|
|||||||
|
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
|
|
||||||
ItemData bedrockAddition = ItemTranslator.translateToBedrock(session, material.getItemStack());
|
|
||||||
|
|
||||||
CraftingDataPacket craftPacket = new CraftingDataPacket();
|
CraftingDataPacket craftPacket = new CraftingDataPacket();
|
||||||
craftPacket.getCraftingData().add(SmithingTransformRecipeData.of(
|
craftPacket.getCraftingData().add(SmithingTransformRecipeData.of(
|
||||||
uuid.toString(),
|
uuid.toString(),
|
||||||
ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, template.getItemStack())),
|
ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, template.getItemStack())),
|
||||||
ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, input.getItemStack())),
|
ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, input.getItemStack())),
|
||||||
ItemDescriptorWithCount.fromItem(bedrockAddition),
|
ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, material.getItemStack())),
|
||||||
ItemTranslator.translateToBedrock(session, output),
|
ItemTranslator.translateToBedrock(session, output),
|
||||||
"smithing_table",
|
"smithing_table",
|
||||||
session.getLastRecipeNetId().incrementAndGet()
|
session.getLastRecipeNetId().incrementAndGet()
|
||||||
|
@ -28,6 +28,7 @@ package org.geysermc.geyser.translator.sound.block;
|
|||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
||||||
|
import org.geysermc.geyser.level.block.property.Properties;
|
||||||
import org.geysermc.geyser.level.block.type.BlockState;
|
import org.geysermc.geyser.level.block.type.BlockState;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
||||||
@ -38,12 +39,10 @@ public class ComparatorSoundInteractionTranslator implements BlockSoundInteracti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
||||||
String identifier = state.toString();
|
|
||||||
boolean powered = identifier.contains("mode=compare");
|
|
||||||
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
||||||
levelEventPacket.setPosition(position);
|
levelEventPacket.setPosition(position);
|
||||||
levelEventPacket.setType(LevelEvent.SOUND_CLICK); //TODO: New ID?
|
levelEventPacket.setType(LevelEvent.SOUND_CLICK); //TODO: New ID?
|
||||||
levelEventPacket.setData(powered ? 500 : 550);
|
levelEventPacket.setData(state.getValue(Properties.MODE_COMPARATOR).equals("compare") ? 500 : 550);
|
||||||
session.sendUpstreamPacket(levelEventPacket);
|
session.sendUpstreamPacket(levelEventPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import org.cloudburstmc.math.vector.Vector3f;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
import org.geysermc.geyser.level.block.type.BlockState;
|
import org.geysermc.geyser.level.block.type.BlockState;
|
||||||
import org.geysermc.geyser.registry.BlockRegistries;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
||||||
import org.geysermc.geyser.translator.sound.SoundTranslator;
|
import org.geysermc.geyser.translator.sound.SoundTranslator;
|
||||||
@ -39,14 +38,13 @@ public class GrassPathInteractionTranslator implements BlockSoundInteractionTran
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
||||||
String identifier = state.toString();
|
|
||||||
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
||||||
levelSoundEventPacket.setPosition(position);
|
levelSoundEventPacket.setPosition(position);
|
||||||
levelSoundEventPacket.setBabySound(false);
|
levelSoundEventPacket.setBabySound(false);
|
||||||
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
||||||
levelSoundEventPacket.setIdentifier(":");
|
levelSoundEventPacket.setIdentifier(":");
|
||||||
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
|
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
|
||||||
levelSoundEventPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(BlockRegistries.JAVA_IDENTIFIER_TO_ID.get().getInt(identifier)));
|
levelSoundEventPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(state.javaId()));
|
||||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import org.cloudburstmc.math.vector.Vector3f;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
import org.geysermc.geyser.level.block.type.BlockState;
|
import org.geysermc.geyser.level.block.type.BlockState;
|
||||||
import org.geysermc.geyser.registry.BlockRegistries;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
||||||
import org.geysermc.geyser.translator.sound.SoundTranslator;
|
import org.geysermc.geyser.translator.sound.SoundTranslator;
|
||||||
@ -39,14 +38,13 @@ public class HoeInteractionTranslator implements BlockSoundInteractionTranslator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
||||||
String identifier = state.toString();
|
|
||||||
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
||||||
levelSoundEventPacket.setPosition(position);
|
levelSoundEventPacket.setPosition(position);
|
||||||
levelSoundEventPacket.setBabySound(false);
|
levelSoundEventPacket.setBabySound(false);
|
||||||
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
||||||
levelSoundEventPacket.setIdentifier(":");
|
levelSoundEventPacket.setIdentifier(":");
|
||||||
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
|
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
|
||||||
levelSoundEventPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(BlockRegistries.JAVA_IDENTIFIER_TO_ID.get().getInt(identifier)));
|
levelSoundEventPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(state.javaId()));
|
||||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ package org.geysermc.geyser.translator.sound.block;
|
|||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
||||||
|
import org.geysermc.geyser.level.block.property.Properties;
|
||||||
import org.geysermc.geyser.level.block.type.BlockState;
|
import org.geysermc.geyser.level.block.type.BlockState;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
||||||
@ -38,12 +39,10 @@ public class LeverSoundInteractionTranslator implements BlockSoundInteractionTra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
||||||
String identifier = state.toString();
|
|
||||||
boolean powered = identifier.contains("powered=true");
|
|
||||||
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
||||||
levelEventPacket.setPosition(position);
|
levelEventPacket.setPosition(position);
|
||||||
levelEventPacket.setType(LevelEvent.SOUND_CLICK);
|
levelEventPacket.setType(LevelEvent.SOUND_CLICK);
|
||||||
levelEventPacket.setData(powered ? 600 : 500);
|
levelEventPacket.setData(state.getValue(Properties.POWERED) ? 600 : 500);
|
||||||
session.sendUpstreamPacket(levelEventPacket);
|
session.sendUpstreamPacket(levelEventPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,9 @@
|
|||||||
package org.geysermc.geyser.translator.sound.block;
|
package org.geysermc.geyser.translator.sound.block;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
|
import org.geysermc.geyser.level.block.property.Properties;
|
||||||
import org.geysermc.geyser.level.block.type.BlockState;
|
import org.geysermc.geyser.level.block.type.BlockState;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
||||||
@ -42,7 +41,7 @@ public class OpenableSoundInteractionTranslator implements BlockSoundInteraction
|
|||||||
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
public void translate(GeyserSession session, Vector3f position, BlockState state) {
|
||||||
String identifier = state.toString();
|
String identifier = state.toString();
|
||||||
if (identifier.contains("iron")) return;
|
if (identifier.contains("iron")) return;
|
||||||
SoundEvent event = getSound(identifier.contains("open=true"), identifier);
|
SoundEvent event = getSound(state.getValue(Properties.OPEN, false), identifier);
|
||||||
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
||||||
levelSoundEventPacket.setPosition(position.add(0.5, 0.5, 0.5));
|
levelSoundEventPacket.setPosition(position.add(0.5, 0.5, 0.5));
|
||||||
levelSoundEventPacket.setBabySound(false);
|
levelSoundEventPacket.setBabySound(false);
|
||||||
|
@ -67,6 +67,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.ItemSlo
|
|||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.ItemStackSlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.ItemStackSlotDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.WithRemainderSlotDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket;
|
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket;
|
||||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemPacket;
|
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemPacket;
|
||||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
|
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
|
||||||
@ -462,6 +463,9 @@ public class InventoryUtils {
|
|||||||
}
|
}
|
||||||
return compositeSlotDisplay.contents().stream().anyMatch(aSlotDisplay -> acceptsAsInput(session, aSlotDisplay, itemStack));
|
return compositeSlotDisplay.contents().stream().anyMatch(aSlotDisplay -> acceptsAsInput(session, aSlotDisplay, itemStack));
|
||||||
}
|
}
|
||||||
|
if (slotDisplay instanceof WithRemainderSlotDisplay remainderSlotDisplay) {
|
||||||
|
return acceptsAsInput(session, remainderSlotDisplay.input(), itemStack);
|
||||||
|
}
|
||||||
if (slotDisplay instanceof ItemSlotDisplay itemSlotDisplay) {
|
if (slotDisplay instanceof ItemSlotDisplay itemSlotDisplay) {
|
||||||
return itemStack.getJavaId() == itemSlotDisplay.item();
|
return itemStack.getJavaId() == itemSlotDisplay.item();
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren