Clean up and add mobile button for horse opening

This commit is contained in:
Camotoy 2021-01-05 19:08:54 -05:00
parent a88678a5c1
commit c8016647f2
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
3 changed files with 13 additions and 5 deletions

View File

@ -39,6 +39,7 @@ import com.nukkitx.protocol.bedrock.packet.InteractPacket;
import lombok.Getter;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.living.animal.horse.AbstractHorseEntity;
import org.geysermc.connector.entity.living.animal.horse.HorseEntity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.inventory.GeyserItemStack;
import org.geysermc.connector.network.session.GeyserSession;
@ -212,6 +213,11 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
case SKELETON_HORSE:
case TRADER_LLAMA:
case ZOMBIE_HORSE:
boolean tamed = entityMetadata.getFlags().getFlag(EntityFlag.TAMED);
if (session.isSneaking() && tamed && (interactEntity instanceof HorseEntity || entityMetadata.getFlags().getFlag(EntityFlag.CHESTED))) {
interactiveTag = InteractiveTag.OPEN_CONTAINER;
break;
}
// have another switch statement as, while these share mount attributes they don't share food
switch (interactEntity.getEntityType()) {
case LLAMA:
@ -230,9 +236,9 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
}
if (!entityMetadata.getFlags().getFlag(EntityFlag.BABY)) {
// Can't ride a baby
if (entityMetadata.getFlags().getFlag(EntityFlag.TAMED)) {
if (tamed) {
interactiveTag = InteractiveTag.RIDE_HORSE;
} else if (!entityMetadata.getFlags().getFlag(EntityFlag.TAMED) && itemEntry.equals(ItemEntry.AIR)) {
} else if (itemEntry.equals(ItemEntry.AIR)) {
// Can't hide an untamed entity without having your hand empty
interactiveTag = InteractiveTag.MOUNT;
}
@ -351,7 +357,7 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
} else {
if (!session.getPlayerEntity().getMetadata().getString(EntityData.INTERACTIVE_TAG).isEmpty()) {
// No interactive tag should be sent
session.getPlayerEntity().getMetadata().remove(EntityData.INTERACTIVE_TAG);
session.getPlayerEntity().getMetadata().put(EntityData.INTERACTIVE_TAG, "");
session.getPlayerEntity().updateBedrockMetadata(session);
}
}

View File

@ -59,6 +59,10 @@ public class RecipeRegistry {
*/
public static int LAST_RECIPE_NET_ID = 0;
/**
* A list of all the following crafting recipes, but in a format understood by Java servers.
* Used for console autocrafting.
*/
public static final Int2ObjectMap<Recipe> ALL_CRAFTING_RECIPES = new Int2ObjectOpenHashMap<>();
/**
@ -163,7 +167,6 @@ public class RecipeRegistry {
for (JsonNode entry : items.get("tipped_arrows")) {
TIPPED_ARROW_RECIPES.add(getCraftingDataFromJsonNode(entry));
}
System.out.println(ALL_CRAFTING_RECIPES);
}
/**

View File

@ -70,7 +70,6 @@ public class TippedArrowTranslator extends ItemTranslator {
@Override
public ItemStack translateToJava(ItemData itemData, ItemEntry itemEntry) {
GeyserConnector.getInstance().getLogger().warning(itemData.toString() + " " + itemEntry.getJavaIdentifier());
TippedArrowPotion tippedArrowPotion = TippedArrowPotion.getByBedrockId(itemData.getDamage());
ItemStack itemStack = super.translateToJava(itemData, itemEntry);
if (tippedArrowPotion != null) {