Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 1dd9ba3
Author: chris <github@onechris.mozmail.com>
Date:   Mon Jul 22 07:24:21 2024 +0200

    Fix: Allow items to be worn as hats if their Java base items also allow it (GeyserMC#4885)

commit b248abf
Author: chris <github@onechris.mozmail.com>
Date:   Sun Jul 21 13:11:27 2024 +0200

    Fix: Text display offset <GeyserMC#4439> (GeyserMC#4883)

commit ddce101
Merge: 7d5c4a3 96f0098
Author: Camotoy <20743703+Camotoy@users.noreply.github.com>
Date:   Sat Jul 20 23:22:12 2024 -0400

    Merge branch 'master' of https://github.com/GeyserMC/Geyser

commit 7d5c4a3
Author: Camotoy <20743703+Camotoy@users.noreply.github.com>
Date:   Sat Jul 20 23:22:04 2024 -0400

    Respect block range attribute where we can

    GeyserMC#4864

commit c9e423a
Author: Camotoy <20743703+Camotoy@users.noreply.github.com>
Date:   Sat Jul 20 23:21:36 2024 -0400

    Small cleanups

commit 96f0098
Author: chris <github@onechris.mozmail.com>
Date:   Sun Jul 21 02:15:38 2024 +0200

    Somewhat fix: firework recipe not showing up in recipe book (GeyserMC#4873)

    * Somewhat fix firework crafting

    * Use instanceof instead of casting

commit f62cef7
Author: chris <github@onechris.mozmail.com>
Date:   Sun Jul 21 02:10:51 2024 +0200

    Fix: Only shutdown/close handlers in onDisable if they're nonnull (GeyserMC#4882)

commit 8fd99e1
Author: LetsGoAway <68365423+letsgoawaydev@users.noreply.github.com>
Date:   Sat Jul 20 18:09:22 2024 +0800

    Use the correct way of sending block breaking particles (GeyserMC#4825)

commit 9fe3acc
Author: chris <github@onechris.mozmail.com>
Date:   Wed Jul 17 21:44:53 2024 +0200

    Properly fix hanging signs (GeyserMC#4872)

commit 406eae2
Author: Camotoy <20743703+Camotoy@users.noreply.github.com>
Date:   Wed Jul 17 14:21:41 2024 -0400

    Fix GeyserMC#4870

commit 669a76c
Author: Valaphee The Meerkat <32491319+valaphee@users.noreply.github.com>
Date:   Tue Jul 16 14:13:34 2024 +0200

    Empty player list on phase transition, despawn skulls, always reset weather (GeyserMC#4847)

    * Empty player list on transition, despawn skulls

    * Always reset weather

commit 677a56c
Author: masel.io <git@byteexception.eu>
Date:   Tue Jul 16 11:23:30 2024 +0200

    Add Timeout to CompletableFuture in GeyserBungeePingPassthrough to Prevent Memory Leak (GeyserMC#4858)

    * fix: Add timeout for GeyserBungeePingPassthrough#getPingInformation

    Signed-off-by: ByteExceptionM <git@byteexception.eu>

    * fix: Use Geyser Logger instead of Bungee Logger

    Signed-off-by: ByteExceptionM <git@byteexception.eu>

    * Fix typo

    Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>

    * chore: Add ip suppression if configured

    Signed-off-by: ByteExceptionM <git@byteexception.eu>

    * Remove empty line

    Co-authored-by: chris <github@onechris.mozmail.com>

    * Remove empty line

    Co-authored-by: chris <github@onechris.mozmail.com>

    ---------

    Signed-off-by: ByteExceptionM <git@byteexception.eu>
    Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
    Co-authored-by: chris <github@onechris.mozmail.com>

commit 305495c
Author: Camotoy <20743703+Camotoy@users.noreply.github.com>
Date:   Mon Jul 15 15:16:45 2024 -0400

    Indicate support for Bedrock 1.21.3

commit efc8ba0
Author: chris <github@onechris.mozmail.com>
Date:   Mon Jul 15 01:31:03 2024 +0200

    Fix: Block place sounds on mod platforms (GeyserMC#4859)

commit 0689050
Author: chris <github@onechris.mozmail.com>
Date:   Sun Jul 14 21:55:57 2024 +0200

    Fix: Totem animation when playing totem effects manually (GeyserMC#4860)

    * Fix: Totem animation for manually played totem effects

    * Ensure we always reset the offhand correctly

commit 9cdda70
Author: chris <github@onechris.mozmail.com>
Date:   Sun Jul 14 20:17:22 2024 +0200

    Fix: Send a container close packet to Java for containers that could not be opened (GeyserMC#4861)

    * Close containers if we did not manage to open it

    * Mark session inventory translator as nonnull

commit 49f66c2
Author: LetsGoAway <68365423+letsgoawaydev@users.noreply.github.com>
Date:   Sun Jul 14 16:44:39 2024 +0800

    Correctly cap scale attribute (GeyserMC#4856)

    * Fix scale attribute cap

    * Update LivingEntity.java

commit 6ab0186
Author: chris <github@onechris.mozmail.com>
Date:   Sat Jul 13 22:00:15 2024 +0200

    Fix: Manually translated item names for block items not showing up properly (GeyserMC#4857)

commit b0c7ddb
Author: chris <github@onechris.mozmail.com>
Date:   Sat Jul 13 18:53:13 2024 +0200

    Fix: Item color names/glint for rare items (GeyserMC#4763)

    * debug stick changes

    * yay light purple item name

    * Address review

    * Auto-generate rarity

    * Add glint generation

    * Translate all rare items properly

    * Use putIfAbsent instead of double checks

commit 93b0a61
Author: chris <github@onechris.mozmail.com>
Date:   Fri Jul 12 20:55:40 2024 +0200

    Fix: hanging sign recipe not showing up in the recipe book (GeyserMC#4814)
  • Loading branch information
letsgoawaydev committed Jul 22, 2024
1 parent c61a564 commit fd01f06
Show file tree
Hide file tree
Showing 35 changed files with 512 additions and 290 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t

Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!

### Currently supporting Minecraft Bedrock 1.20.80 - 1.21.2 and Minecraft Java 1.21
### Currently supporting Minecraft Bedrock 1.20.80 - 1.21.3 and Minecraft Java 1.21

## Setting Up
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
Expand Down Expand Up @@ -42,7 +42,7 @@ There are a few things Geyser is unable to support due to various differences be
3. Run `gradlew build` and locate to `bootstrap/build` folder.

## Contributing
Any contributions are appreciated. Please feel free to reach out to us on [Discord](http://discord.geysermc.org/) if
Any contributions are appreciated. Please feel free to reach out to us on [Discord](https://discord.gg/geysermc) if
you're interested in helping out with Geyser.

## Libraries Used:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.protocol.ProtocolConstants;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.ping.GeyserPingInfo;
import org.geysermc.geyser.ping.IGeyserPingPassthrough;

import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

@AllArgsConstructor
public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, Listener {
Expand All @@ -59,7 +61,17 @@ public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
future.complete(event);
}
}));
ProxyPingEvent event = future.join();

ProxyPingEvent event;

try {
event = future.get(100, TimeUnit.MILLISECONDS);
} catch (Throwable cause) {
String address = GeyserImpl.getInstance().getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
GeyserImpl.getInstance().getLogger().error("Failed to get ping information for " + address, cause);
return null;
}

ServerPing response = event.getResponse();
return new GeyserPingInfo(
response.getDescriptionComponent().toLegacyText(),
Expand Down
1 change: 1 addition & 0 deletions bootstrap/mod/src/main/resources/geyser.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"package": "org.geysermc.geyser.platform.mod.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"server.BlockPlaceMixin",
"server.ServerConnectionListenerMixin"
],
"server": [
Expand Down
45 changes: 32 additions & 13 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
import org.geysermc.geyser.api.command.CommandSource;
import org.geysermc.geyser.api.event.EventBus;
import org.geysermc.geyser.api.event.EventRegistrar;
import org.geysermc.geyser.api.event.lifecycle.*;
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
import org.geysermc.geyser.api.event.lifecycle.GeyserPostReloadEvent;
import org.geysermc.geyser.api.event.lifecycle.GeyserPreInitializeEvent;
import org.geysermc.geyser.api.event.lifecycle.GeyserPreReloadEvent;
import org.geysermc.geyser.api.event.lifecycle.GeyserShutdownEvent;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.api.network.BedrockListener;
import org.geysermc.geyser.api.network.RemoteServer;
Expand Down Expand Up @@ -85,7 +89,13 @@
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.text.MinecraftLocale;
import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.*;
import org.geysermc.geyser.util.AssetUtils;
import org.geysermc.geyser.util.CooldownUtils;
import org.geysermc.geyser.util.DimensionUtils;
import org.geysermc.geyser.util.Metrics;
import org.geysermc.geyser.util.NewsHandler;
import org.geysermc.geyser.util.VersionCheckUtils;
import org.geysermc.geyser.util.WebUtils;
import org.geysermc.mcprotocollib.network.tcp.TcpSession;

import java.io.File;
Expand All @@ -97,11 +107,19 @@
import java.nio.file.Path;
import java.security.Key;
import java.text.DecimalFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -646,16 +664,11 @@ public void disable() {
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.kick.done"));
}

scheduledThread.shutdown();
geyserServer.shutdown();
if (skinUploader != null) {
skinUploader.close();
}
newsHandler.shutdown();

if (this.erosionUnixListener != null) {
this.erosionUnixListener.close();
}
runIfNonNull(scheduledThread, ScheduledExecutorService::shutdown);
runIfNonNull(geyserServer, GeyserServer::shutdown);
runIfNonNull(skinUploader, FloodgateSkinUploader::close);
runIfNonNull(newsHandler, NewsHandler::shutdown);
runIfNonNull(erosionUnixListener, UnixSocketClientListener::close);

Registries.RESOURCE_PACKS.get().clear();

Expand Down Expand Up @@ -836,6 +849,12 @@ public void saveRefreshToken(@NonNull String bedrockName, @NonNull String refres
}
}

private <T> void runIfNonNull(T nullable, Consumer<T> consumer) {
if (nullable != null) {
consumer.accept(nullable);
}
}

private void scheduleRefreshTokensWrite() {
scheduledThread.execute(() -> {
// Ensure all writes are handled on the same thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ public final class EntityDefinitions {
TEXT_DISPLAY = EntityDefinition.inherited(TextDisplayEntity::new, displayBase)
.type(EntityType.TEXT_DISPLAY)
.identifier("minecraft:armor_stand")
.offset(-0.5f)
.addTranslator(MetadataType.CHAT, TextDisplayEntity::setText)
.addTranslator(null) // Line width
.addTranslator(null) // Background color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public enum GeyserAttributeType {
ATTACK_KNOCKBACK("minecraft:generic.attack_knockback", null, 1.5f, Float.MAX_VALUE, 0f),
ATTACK_SPEED("minecraft:generic.attack_speed", null, 0f, 1024f, 4f),
MAX_HEALTH("minecraft:generic.max_health", null, 0f, 1024f, 20f),
SCALE("minecraft:generic.scale", null, 0.0625f, 16f, 1f), // Unused. Do we need this?
SCALE("minecraft:generic.scale", null, 0.0625f, 16f, 1f),
BLOCK_INTERACTION_RANGE("minecraft:player.block_interaction_range", null, 0.0f, 64f, 4.5f),

// Bedrock Attributes
ABSORPTION(null, "minecraft:absorption", 0f, 1024f, 0f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.util.AttributeUtils;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.MathUtils;
import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute;
import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.AttributeType;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
Expand Down Expand Up @@ -252,7 +253,7 @@ protected void setScale(float scale) {
}

private void setAttributeScale(float scale) {
this.attributeScale = scale;
this.attributeScale = MathUtils.clamp(scale, GeyserAttributeType.SCALE.getMinimum(), GeyserAttributeType.SCALE.getMaximum());
applyScale();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@
// Note: 1.19.4 requires that the billboard is set to something in order to show, on Java Edition
public class TextDisplayEntity extends DisplayBaseEntity {
public TextDisplayEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
super(session, entityId, geyserId, uuid, definition, position.add(0, definition.offset(), 0), motion, yaw, pitch, headYaw);
}

@Override
public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround) {
super.moveRelative(relX, relY + definition.offset(), relZ, yaw, pitch, isOnGround);
}

@Override
public void moveAbsolute(Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) {
super.moveAbsolute(position.add(Vector3f.from(0, definition.offset(), 0)), yaw, pitch, headYaw, isOnGround, teleported);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,16 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;

import java.util.Set;
import java.util.UUID;

public class ParrotEntity extends TameableEntity {
// Note: is the same as chicken. Reuse?
private static final Set<Item> TAMING_FOOD = Set.of(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS);

public ParrotEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public class SessionPlayerEntity extends PlayerEntity {
*/
@Getter
protected final Map<GeyserAttributeType, AttributeData> attributes = new Object2ObjectOpenHashMap<>();
/**
* Java-only attribute
*/
@Getter
private double blockInteractionRange = GeyserAttributeType.BLOCK_INTERACTION_RANGE.getDefaultValue();
/**
* Used in PlayerInputTranslator for movement checks.
*/
Expand Down Expand Up @@ -232,6 +237,8 @@ protected boolean hasShield(boolean offhand) {
protected void updateAttribute(Attribute javaAttribute, List<AttributeData> newAttributes) {
if (javaAttribute.getType() == AttributeType.Builtin.GENERIC_ATTACK_SPEED) {
session.setAttackSpeed(AttributeUtils.calculateValue(javaAttribute));
} else if (javaAttribute.getType() == AttributeType.Builtin.PLAYER_BLOCK_INTERACTION_RANGE) {
this.blockInteractionRange = AttributeUtils.calculateValue(javaAttribute);
} else {
super.updateAttribute(javaAttribute, newAttributes);
}
Expand Down Expand Up @@ -295,6 +302,7 @@ public void resetMetadata() {
public void resetAttributes() {
attributes.clear();
maxHealth = GeyserAttributeType.MAX_HEALTH.getDefaultValue();
blockInteractionRange = GeyserAttributeType.BLOCK_INTERACTION_RANGE.getDefaultValue();

UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket();
attributesPacket.setRuntimeEntityId(geyserId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import lombok.Setter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
import org.jetbrains.annotations.Range;
Expand Down Expand Up @@ -73,6 +74,10 @@ public GeyserItemStack getItemInHand() {
return items[36 + heldItemSlot];
}

public boolean eitherHandMatchesItem(@NonNull Item item) {
return getItemInHand().asItem() == item || getItemInHand(Hand.OFF_HAND).asItem() == item;
}

public void setItemInHand(@NonNull GeyserItemStack item) {
if (36 + heldItemSlot > this.size) {
GeyserImpl.getInstance().getLogger().debug("Held item slot was larger than expected!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class StoredItemMappings {
private final ItemMapping milkBucket;
private final ItemMapping powderSnowBucket;
private final ItemMapping shield;
private final ItemMapping totem;
private final ItemMapping upgradeTemplate;
private final ItemMapping wheat;
private final ItemMapping writableBook;
Expand All @@ -66,6 +67,7 @@ public StoredItemMappings(Map<Item, ItemMapping> itemMappings) {
this.milkBucket = load(itemMappings, Items.MILK_BUCKET);
this.powderSnowBucket = load(itemMappings, Items.POWDER_SNOW_BUCKET);
this.shield = load(itemMappings, Items.SHIELD);
this.totem = load(itemMappings, Items.TOTEM_OF_UNDYING);
this.upgradeTemplate = load(itemMappings, Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE);
this.wheat = load(itemMappings, Items.WHEAT);
this.writableBook = load(itemMappings, Items.WRITABLE_BOOK);
Expand Down
Loading

0 comments on commit fd01f06

Please sign in to comment.