Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +01:00
Add villager interactive tag (#788)
* Add villager interactive tag This adds a button/controller guide for villager trading, if the villager is able to trade. * Use a broader variable for metadata
Dieser Commit ist enthalten in:
Ursprung
effd7602af
Commit
100d7b7759
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.connector.network.translators.bedrock;
|
package org.geysermc.connector.network.translators.bedrock;
|
||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.EntityDataMap;
|
||||||
import com.nukkitx.protocol.bedrock.data.EntityFlag;
|
import com.nukkitx.protocol.bedrock.data.EntityFlag;
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -74,33 +75,43 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
|||||||
Entity interactEntity = session.getEntityCache().getEntityByGeyserId(packet.getRuntimeEntityId());
|
Entity interactEntity = session.getEntityCache().getEntityByGeyserId(packet.getRuntimeEntityId());
|
||||||
if (interactEntity == null)
|
if (interactEntity == null)
|
||||||
return;
|
return;
|
||||||
|
EntityDataMap entityMetadata = interactEntity.getMetadata();
|
||||||
|
|
||||||
String interactiveTag;
|
String interactiveTag;
|
||||||
switch (interactEntity.getEntityType()) {
|
switch (interactEntity.getEntityType()) {
|
||||||
case PIG:
|
case BOAT:
|
||||||
if (interactEntity.getMetadata().getFlags().getFlag(EntityFlag.SADDLED)) {
|
interactiveTag = "action.interact.ride.boat";
|
||||||
interactiveTag = "action.interact.mount";
|
|
||||||
} else interactiveTag = "";
|
|
||||||
break;
|
break;
|
||||||
case HORSE:
|
|
||||||
case SKELETON_HORSE:
|
|
||||||
case ZOMBIE_HORSE:
|
|
||||||
case DONKEY:
|
case DONKEY:
|
||||||
case MULE:
|
case HORSE:
|
||||||
case LLAMA:
|
case LLAMA:
|
||||||
|
case MULE:
|
||||||
|
case SKELETON_HORSE:
|
||||||
case TRADER_LLAMA:
|
case TRADER_LLAMA:
|
||||||
if (interactEntity.getMetadata().getFlags().getFlag(EntityFlag.TAMED)) {
|
case ZOMBIE_HORSE:
|
||||||
|
if (entityMetadata.getFlags().getFlag(EntityFlag.TAMED)) {
|
||||||
interactiveTag = "action.interact.ride.horse";
|
interactiveTag = "action.interact.ride.horse";
|
||||||
} else {
|
} else {
|
||||||
interactiveTag = "action.interact.mount";
|
interactiveTag = "action.interact.mount";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BOAT:
|
|
||||||
interactiveTag = "action.interact.ride.boat";
|
|
||||||
break;
|
|
||||||
case MINECART:
|
case MINECART:
|
||||||
interactiveTag = "action.interact.ride.minecart";
|
interactiveTag = "action.interact.ride.minecart";
|
||||||
break;
|
break;
|
||||||
|
case PIG:
|
||||||
|
if (entityMetadata.getFlags().getFlag(EntityFlag.SADDLED)) {
|
||||||
|
interactiveTag = "action.interact.mount";
|
||||||
|
} else interactiveTag = "";
|
||||||
|
break;
|
||||||
|
case VILLAGER:
|
||||||
|
if (entityMetadata.getInt(EntityData.VARIANT) != 14 && entityMetadata.getInt(EntityData.VARIANT) != 0
|
||||||
|
&& entityMetadata.getFloat(EntityData.SCALE) >= 0.75f) { // Not a nitwit, has a profession and is not a baby
|
||||||
|
interactiveTag = "action.interact.trade";
|
||||||
|
} else interactiveTag = "";
|
||||||
|
break;
|
||||||
|
case WANDERING_TRADER:
|
||||||
|
interactiveTag = "action.interact.trade"; // Since you can always trade with a wandering villager, presumably.
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return; // No need to process any further since there is no interactive tag
|
return; // No need to process any further since there is no interactive tag
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren