Skip to content

Commit

Permalink
Clean up and add mobile button for horse opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jan 6, 2021
1 parent a88678a commit c801664
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
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;
Expand Down Expand Up @@ -212,6 +213,11 @@ else if (javaIdentifierStripped.equals("bowl")) {
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:
Expand All @@ -230,9 +236,9 @@ else if (javaIdentifierStripped.equals("bowl")) {
}
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;
}
Expand Down Expand Up @@ -351,7 +357,7 @@ else if (javaIdentifierStripped.equals("bowl")) {
} 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {

@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) {
Expand Down

0 comments on commit c801664

Please sign in to comment.