mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Merge branch 'feature/protocol-3.0' of https://github.com/GeyserMC/Geyser into feature/blocky-protocol-3.0
This commit is contained in:
commit
d7a3430e98
470 changed files with 18808 additions and 4812 deletions
|
@ -1,5 +1,4 @@
|
|||
org.geysermc.geyser.processor.BlockEntityProcessor
|
||||
org.geysermc.geyser.processor.CollisionRemapperProcessor
|
||||
org.geysermc.geyser.processor.ItemRemapperProcessor
|
||||
org.geysermc.geyser.processor.PacketTranslatorProcessor
|
||||
org.geysermc.geyser.processor.SoundHandlerProcessor
|
|
@ -25,11 +25,31 @@
|
|||
|
||||
package org.geysermc.geyser.api.connection;
|
||||
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.api.connection.Connection;
|
||||
import org.geysermc.geyser.api.command.CommandSource;
|
||||
import org.geysermc.geyser.api.entity.type.GeyserEntity;
|
||||
import org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Represents a player connection used in Geyser.
|
||||
*/
|
||||
public interface GeyserConnection extends Connection, CommandSource {
|
||||
/**
|
||||
* @param javaId the Java entity ID to look up.
|
||||
* @return a {@link GeyserEntity} if present in this connection's entity tracker.
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<@Nullable GeyserEntity> entityByJavaId(@NonNegative int javaId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param emoter the player entity emoting.
|
||||
* @param emoteId the emote ID to send to the client.
|
||||
*/
|
||||
void showEmote(@NonNull GeyserPlayerEntity emoter, @NonNull String emoteId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.api.entity.type;
|
||||
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
|
||||
/**
|
||||
* Represents a unique instance of an entity. Each {@link org.geysermc.geyser.api.connection.GeyserConnection}
|
||||
* have their own sets of entities - no two instances will share the same GeyserEntity instance.
|
||||
*/
|
||||
public interface GeyserEntity {
|
||||
/**
|
||||
* @return the entity ID that the server has assigned to this entity.
|
||||
*/
|
||||
@NonNegative
|
||||
int javaId();
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.api.entity.type.player;
|
||||
|
||||
import org.geysermc.geyser.api.entity.type.GeyserEntity;
|
||||
|
||||
public interface GeyserPlayerEntity extends GeyserEntity {
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.api.event.bedrock;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.connection.GeyserConnection;
|
||||
import org.geysermc.geyser.api.event.connection.ConnectionEvent;
|
||||
|
||||
/**
|
||||
* Called when Geyser initialises a session for a new bedrock client.
|
||||
*/
|
||||
public final class SessionInitializeEvent extends ConnectionEvent {
|
||||
public SessionInitializeEvent(@NonNull GeyserConnection connection) {
|
||||
super(connection);
|
||||
}
|
||||
}
|
|
@ -68,6 +68,13 @@ public interface CustomItemData {
|
|||
*/
|
||||
boolean allowOffhand();
|
||||
|
||||
/**
|
||||
* Gets if the item should be displayed as handheld, like a tool.
|
||||
*
|
||||
* @return true if the item should be displayed as handheld, false otherwise
|
||||
*/
|
||||
boolean displayHandheld();
|
||||
|
||||
/**
|
||||
* Gets the item's texture size. This is to resize the item if the texture is not 16x16.
|
||||
*
|
||||
|
@ -100,6 +107,8 @@ public interface CustomItemData {
|
|||
|
||||
Builder allowOffhand(boolean allowOffhand);
|
||||
|
||||
Builder displayHandheld(boolean displayHandheld);
|
||||
|
||||
Builder textureSize(int textureSize);
|
||||
|
||||
Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets);
|
||||
|
|
|
@ -56,6 +56,14 @@ public interface CustomItemOptions {
|
|||
*/
|
||||
@NonNull OptionalInt damagePredicate();
|
||||
|
||||
/**
|
||||
* Gets if this mapping should just translate to the default item.
|
||||
* This is used for the damage predicate of damaged 1 damage 0 that is required to allow the default item to exist.
|
||||
*
|
||||
* @return true if this mapping should just translate to the default item, false otherwise
|
||||
*/
|
||||
boolean defaultItem();
|
||||
|
||||
/**
|
||||
* Checks if the item has at least one option set
|
||||
*
|
||||
|
@ -78,6 +86,8 @@ public interface CustomItemOptions {
|
|||
|
||||
Builder damagePredicate(int damagePredicate);
|
||||
|
||||
Builder defaultItem(boolean defaultItem);
|
||||
|
||||
CustomItemOptions build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,17 +130,22 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
|||
boolean isHat();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #displayHandheld()} instead.
|
||||
* Gets if the item is a tool. This is used to set the render type of the item, if the item is handheld.
|
||||
*
|
||||
* @return if the item is a tool
|
||||
*/
|
||||
boolean isTool();
|
||||
@Deprecated
|
||||
default boolean isTool() {
|
||||
return displayHandheld();
|
||||
}
|
||||
|
||||
static NonVanillaCustomItemData.Builder builder() {
|
||||
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
|
||||
}
|
||||
|
||||
interface Builder extends CustomItemData.Builder {
|
||||
@Override
|
||||
Builder name(@NonNull String name);
|
||||
|
||||
Builder identifier(@NonNull String identifier);
|
||||
|
@ -169,14 +174,29 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
|||
|
||||
Builder hat(boolean isHat);
|
||||
|
||||
Builder tool(boolean isTool);
|
||||
/**
|
||||
* @deprecated Use {@link #displayHandheld(boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
default Builder tool(boolean isTool) {
|
||||
return displayHandheld(isTool);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder customItemOptions(@NonNull CustomItemOptions customItemOptions);
|
||||
|
||||
@Override
|
||||
Builder displayName(@NonNull String displayName);
|
||||
|
||||
@Override
|
||||
Builder icon(@NonNull String icon);
|
||||
|
||||
@Override
|
||||
Builder allowOffhand(boolean allowOffhand);
|
||||
|
||||
@Override
|
||||
Builder displayHandheld(boolean displayHandheld);
|
||||
|
||||
@Override
|
||||
Builder textureSize(int textureSize);
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
|||
import org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -55,6 +56,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
@ -116,26 +118,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
return;
|
||||
}
|
||||
|
||||
if (getProxy().getConfig().getListeners().size() == 1) {
|
||||
ListenerInfo listener = getProxy().getConfig().getListeners().toArray(new ListenerInfo[0])[0];
|
||||
|
||||
InetSocketAddress javaAddr = listener.getHost();
|
||||
|
||||
// By default this should be localhost but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't use localhost if not listening on all interfaces
|
||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
||||
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
||||
}
|
||||
this.geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
}
|
||||
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||
geyserConfig.getBedrock().setPort(javaAddr.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
// Force-disable query if enabled, or else Geyser won't enable
|
||||
for (ListenerInfo info : getProxy().getConfig().getListeners()) {
|
||||
if (info.isQueryEnabled() && info.getQueryPort() == geyserConfig.getBedrock().port()) {
|
||||
|
@ -154,15 +136,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) {
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate") != null) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this);
|
||||
|
||||
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
|
||||
|
@ -274,4 +247,27 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
public SocketAddress getSocketAddress() {
|
||||
return this.geyserInjector.getServerSocketAddress();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
return findCompatibleListener().map(InetSocketAddress::getHostString).orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return findCompatibleListener().stream().mapToInt(InetSocketAddress::getPort).findFirst().orElse(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloodgatePluginPresent() {
|
||||
return getProxy().getPluginManager().getPlugin("floodgate") != null;
|
||||
}
|
||||
|
||||
private Optional<InetSocketAddress> findCompatibleListener() {
|
||||
return getProxy().getConfig().getListeners().stream()
|
||||
.filter(info -> info.getSocketAddress() instanceof InetSocketAddress)
|
||||
.map(info -> (InetSocketAddress) info.getSocketAddress())
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,11 @@ tasks {
|
|||
relocate("net.kyori", "org.geysermc.relocate.kyori")
|
||||
|
||||
dependencies {
|
||||
// Exclude everything EXCEPT KQueue and some DNS stuff required for HAProxyc
|
||||
// Exclude everything EXCEPT some DNS stuff required for HAProxy
|
||||
exclude(dependency("io.netty:netty-transport-classes-epoll:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-native-epoll:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-native-unix-common:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-classes-kqueue:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-native-kqueue:.*"))
|
||||
exclude(dependency("io.netty:netty-handler:.*"))
|
||||
exclude(dependency("io.netty:netty-common:.*"))
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.geysermc.geyser.GeyserBootstrap;
|
|||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.network.AuthType;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
|
@ -53,13 +52,15 @@ import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
|||
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||
private static GeyserFabricMod instance;
|
||||
|
@ -137,33 +138,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||
*/
|
||||
public void startGeyser(MinecraftServer server) {
|
||||
this.server = server;
|
||||
|
||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
String ip = server.getLocalIp();
|
||||
int port = ((GeyserServerPortGetter) server).geyser$getServerPort();
|
||||
if (ip != null && !ip.isEmpty() && !ip.equals("0.0.0.0")) {
|
||||
this.geyserConfig.getRemote().setAddress(ip);
|
||||
}
|
||||
this.geyserConfig.getRemote().setPort(port);
|
||||
}
|
||||
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().port());
|
||||
}
|
||||
|
||||
Optional<ModContainer> floodgate = FabricLoader.getInstance().getModContainer("floodgate");
|
||||
boolean floodgatePresent = floodgate.isPresent();
|
||||
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && !floodgatePresent) {
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && floodgatePresent) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this, floodgate.orElse(null));
|
||||
geyserConfig.loadFloodgate(this, FabricLoader.getInstance().getModContainer("floodgate").orElse(null));
|
||||
|
||||
GeyserImpl.start();
|
||||
|
||||
|
@ -242,6 +217,22 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||
return this.server.getServerVersion();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
return this.server.getLocalIp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return ((GeyserServerPortGetter) server).geyser$getServerPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloodgatePluginPresent() {
|
||||
return FabricLoader.getInstance().getModContainer("floodgate").isPresent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public InputStream getResourceOrNull(String resource) {
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
package org.geysermc.geyser.platform.fabric.world;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import com.nukkitx.nbt.NbtType;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.*;
|
||||
|
@ -42,6 +38,10 @@ import net.minecraft.world.level.block.entity.BannerBlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.LecternBlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.cloudburstmc.nbt.NbtType;
|
||||
import org.geysermc.erosion.util.LecternUtils;
|
||||
import org.geysermc.geyser.level.GeyserWorldManager;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -29,7 +29,6 @@ platformRelocate("com.fasterxml.jackson")
|
|||
platformRelocate("net.kyori", "net.kyori.adventure.text.logger.slf4j.ComponentLogger")
|
||||
platformRelocate("org.objectweb.asm")
|
||||
platformRelocate("me.lucko.commodore")
|
||||
platformRelocate("io.netty.channel.kqueue")
|
||||
|
||||
// These dependencies are already present on the platform
|
||||
provided(libs.viaversion)
|
||||
|
@ -50,6 +49,7 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
|||
exclude(dependency("io.netty:netty-transport-classes-epoll:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-native-epoll:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-native-unix-common:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-classes-kqueue:.*"))
|
||||
exclude(dependency("io.netty:netty-transport-native-kqueue:.*"))
|
||||
exclude(dependency("io.netty:netty-handler:.*"))
|
||||
exclude(dependency("io.netty:netty-common:.*"))
|
||||
|
|
|
@ -65,6 +65,7 @@ import org.geysermc.geyser.platform.spigot.world.GeyserSpigotBlockPlaceListener;
|
|||
import org.geysermc.geyser.platform.spigot.world.manager.*;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -170,29 +171,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
return;
|
||||
}
|
||||
|
||||
// By default this should be localhost but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||
geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't use localhost if not listening on all interfaces
|
||||
if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
|
||||
geyserConfig.getRemote().setAddress(Bukkit.getIp());
|
||||
}
|
||||
geyserConfig.getRemote().setPort(Bukkit.getPort());
|
||||
}
|
||||
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||
geyserConfig.getBedrock().setPort(Bukkit.getPort());
|
||||
}
|
||||
|
||||
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && Bukkit.getPluginManager().getPlugin("floodgate") == null) {
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
this.getPluginLoader().disablePlugin(this);
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && Bukkit.getPluginManager().getPlugin("floodgate") != null) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this);
|
||||
|
||||
this.geyserCommandManager = new GeyserSpigotCommandManager(geyser);
|
||||
|
@ -431,40 +409,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
return this.geyserInjector.getServerSocketAddress();
|
||||
}
|
||||
|
||||
public boolean isCompatible(String version, String whichVersion) {
|
||||
int[] currentVersion = parseVersion(version);
|
||||
int[] otherVersion = parseVersion(whichVersion);
|
||||
int length = Math.max(currentVersion.length, otherVersion.length);
|
||||
for (int index = 0; index < length; index = index + 1) {
|
||||
int self = (index < currentVersion.length) ? currentVersion[index] : 0;
|
||||
int other = (index < otherVersion.length) ? otherVersion[index] : 0;
|
||||
|
||||
if (self != other) {
|
||||
return (self - other) > 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] parseVersion(String versionParam) {
|
||||
versionParam = (versionParam == null) ? "" : versionParam;
|
||||
if (versionParam.contains("(MC: ")) {
|
||||
versionParam = versionParam.split("\\(MC: ")[1];
|
||||
versionParam = versionParam.split("\\)")[0];
|
||||
}
|
||||
String[] stringArray = versionParam.split("[_.-]");
|
||||
int[] temp = new int[stringArray.length];
|
||||
for (int index = 0; index <= (stringArray.length - 1); index = index + 1) {
|
||||
String t = stringArray[index].replaceAll("\\D", "");
|
||||
try {
|
||||
temp[index] = Integer.parseInt(t);
|
||||
} catch (NumberFormatException ex) {
|
||||
temp[index] = 0;
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the server version before ViaVersion finishes initializing
|
||||
*/
|
||||
|
@ -494,4 +438,20 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
// All mapping data is null, which means client and server block states are the same
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
return Bukkit.getIp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return Bukkit.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloodgatePluginPresent() {
|
||||
return Bukkit.getPluginManager().getPlugin("floodgate") != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.geyser.platform.spigot.world;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.bukkit.Bukkit;
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.platform.spigot.world;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -59,7 +59,7 @@ public class GeyserSpigotBlockPlaceListener implements Listener {
|
|||
event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ())));
|
||||
} else {
|
||||
String javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
|
||||
placeBlockSoundPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(BlockRegistries.JAVA_IDENTIFIERS.get().getOrDefault(javaBlockId, BlockStateValues.JAVA_AIR_ID)));
|
||||
placeBlockSoundPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(BlockRegistries.JAVA_IDENTIFIER_TO_ID.get().getOrDefault(javaBlockId, BlockStateValues.JAVA_AIR_ID)));
|
||||
}
|
||||
placeBlockSoundPacket.setIdentifier(":");
|
||||
session.sendUpstreamPacket(placeBlockSoundPacket);
|
||||
|
|
|
@ -27,13 +27,13 @@ package org.geysermc.geyser.platform.spigot.world.manager;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.geysermc.erosion.bukkit.BukkitLecterns;
|
||||
import org.geysermc.erosion.bukkit.BukkitUtils;
|
||||
import org.geysermc.erosion.bukkit.PickBlockUtils;
|
||||
|
@ -82,9 +82,9 @@ public class GeyserSpigotWorldManager extends WorldManager {
|
|||
// Terrible behavior, but this is basically what's always been happening behind the scenes anyway.
|
||||
CompletableFuture<String> blockData = new CompletableFuture<>();
|
||||
Bukkit.getRegionScheduler().execute(this.plugin, block.getLocation(), () -> blockData.complete(block.getBlockData().getAsString()));
|
||||
return BlockRegistries.JAVA_IDENTIFIERS.getOrDefault(blockData.join(), BlockStateValues.JAVA_AIR_ID);
|
||||
return BlockRegistries.JAVA_IDENTIFIER_TO_ID.getOrDefault(blockData.join(), BlockStateValues.JAVA_AIR_ID);
|
||||
}
|
||||
return BlockRegistries.JAVA_IDENTIFIERS.getOrDefault(block.getBlockData().getAsString(), BlockStateValues.JAVA_AIR_ID);
|
||||
return BlockRegistries.JAVA_IDENTIFIER_TO_ID.getOrDefault(block.getBlockData().getAsString(), BlockStateValues.JAVA_AIR_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandManager;
|
|||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
|
@ -179,24 +180,6 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Sponge.server().boundAddress().isPresent()) {
|
||||
InetSocketAddress javaAddr = Sponge.server().boundAddress().get();
|
||||
|
||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't change the ip if its listening on all interfaces
|
||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
||||
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
||||
}
|
||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().port());
|
||||
}
|
||||
|
||||
GeyserImpl.start();
|
||||
|
||||
if (geyserConfig.isLegacyPingPassthrough()) {
|
||||
|
@ -245,4 +228,20 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||
public String getMinecraftServerVersion() {
|
||||
return Sponge.platform().minecraftVersion().name();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
return Sponge.server().boundAddress().map(InetSocketAddress::getHostString).orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return Sponge.server().boundAddress().stream().mapToInt(InetSocketAddress::getPort).findFirst().orElse(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloodgatePluginPresent() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,4 +26,11 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
|||
archiveBaseName.set("Geyser-Standalone")
|
||||
|
||||
transform(Log4j2PluginsCacheFileTransformer())
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<JavaExec>("run") {
|
||||
val dir = projectDir.resolve("run")
|
||||
dir.mkdirs()
|
||||
jvmArgs("-Dio.netty.leakDetection.level=PARANOID")
|
||||
workingDir = dir
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.geysermc.geyser.platform.standalone.gui.GeyserStandaloneGUI;
|
|||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.LoopbackUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -291,6 +292,22 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||
return new GeyserStandaloneDumpInfo(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloodgatePluginPresent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link BeanPropertyDefinition}s for the given class
|
||||
*
|
||||
|
|
|
@ -50,12 +50,12 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
|||
import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -111,22 +111,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
return;
|
||||
}
|
||||
|
||||
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
|
||||
|
||||
// By default this should be localhost but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't use localhost if not listening on all interfaces
|
||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
||||
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
||||
}
|
||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
}
|
||||
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||
geyserConfig.getBedrock().setPort(javaAddr.getPort());
|
||||
}
|
||||
|
||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
|
||||
|
@ -142,18 +126,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
|
||||
|
||||
}
|
||||
|
||||
private void postStartup() {
|
||||
|
@ -247,4 +220,20 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
public SocketAddress getSocketAddress() {
|
||||
return this.geyserInjector.getServerSocketAddress();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
return proxyServer.getBoundAddress().getHostString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return proxyServer.getBoundAddress().getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloodgatePluginPresent() {
|
||||
return proxyServer.getPluginManager().getPlugin("floodgate").isPresent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,12 @@ allprojects {
|
|||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(16))
|
||||
}
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
projects.fabric,
|
||||
projects.bungeecord,
|
||||
|
|
|
@ -20,9 +20,7 @@ dependencies {
|
|||
// Network libraries
|
||||
implementation(libs.websocket)
|
||||
|
||||
api(libs.protocol) {
|
||||
exclude("com.nukkitx.network", "raknet")
|
||||
}
|
||||
api(libs.bundles.protocol)
|
||||
|
||||
api(libs.mcauthlib)
|
||||
api(libs.mcprotocollib) {
|
||||
|
@ -60,12 +58,18 @@ dependencies {
|
|||
compileOnly(projects.ap)
|
||||
|
||||
annotationProcessor(projects.ap)
|
||||
|
||||
api(libs.events)
|
||||
}
|
||||
|
||||
configurations.api {
|
||||
// This is still experimental - additionally, it could only really benefit standalone
|
||||
exclude(group = "io.netty.incubator", module = "netty-incubator-transport-native-io_uring")
|
||||
}
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_14
|
||||
targetCompatibility = JavaVersion.VERSION_14
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
// This is solely for backwards compatibility for other programs that used this file before the switch to gradle.
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -52,10 +51,6 @@ public class GeyserConnector {
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
public BedrockServer getBedrockServer() {
|
||||
return GeyserImpl.getInstance().getBedrockServer();
|
||||
}
|
||||
|
||||
public boolean isShuttingDown() {
|
||||
return GeyserImpl.getInstance().isShuttingDown();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.session;
|
||||
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
|
||||
import org.geysermc.connector.network.session.auth.AuthData;
|
||||
|
||||
/**
|
||||
|
|
|
@ -158,4 +158,17 @@ public interface GeyserBootstrap {
|
|||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bind address being used by the Java server.
|
||||
*/
|
||||
@Nonnull
|
||||
String getServerBindAddress();
|
||||
|
||||
/**
|
||||
* @return the listening port being used by the Java server. -1 if can't be found
|
||||
*/
|
||||
int getServerPort();
|
||||
|
||||
boolean isFloodgatePluginPresent();
|
||||
}
|
||||
|
|
|
@ -30,11 +30,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.steveice10.packetlib.tcp.TcpSession;
|
||||
import com.nukkitx.network.raknet.RakNetConstants;
|
||||
import com.nukkitx.network.util.EventLoops;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.kqueue.KQueue;
|
||||
import io.netty.util.NettyRuntime;
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import io.netty.util.internal.SystemPropertyUtil;
|
||||
|
@ -72,7 +68,7 @@ import org.geysermc.geyser.erosion.UnixSocketClientListener;
|
|||
import org.geysermc.geyser.event.GeyserEventBus;
|
||||
import org.geysermc.geyser.extension.GeyserExtensionManager;
|
||||
import org.geysermc.geyser.level.WorldManager;
|
||||
import org.geysermc.geyser.network.ConnectorServerEventHandler;
|
||||
import org.geysermc.geyser.network.netty.GeyserServer;
|
||||
import org.geysermc.geyser.pack.ResourcePack;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
|
@ -85,7 +81,6 @@ import org.geysermc.geyser.skin.ProvidedSkins;
|
|||
import org.geysermc.geyser.skin.SkinProvider;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.text.MinecraftLocale;
|
||||
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.geyser.util.*;
|
||||
|
||||
|
@ -148,7 +143,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
private ScheduledExecutorService scheduledThread;
|
||||
|
||||
private BedrockServer bedrockServer;
|
||||
private GeyserServer geyserServer;
|
||||
private final PlatformType platformType;
|
||||
private final GeyserBootstrap bootstrap;
|
||||
|
||||
|
@ -199,7 +194,6 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
/* Initialize translators */
|
||||
EntityDefinitions.init();
|
||||
ItemTranslator.init();
|
||||
MessageTranslator.init();
|
||||
|
||||
// Download the latest asset list and cache it
|
||||
|
@ -266,18 +260,81 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
ResourcePack.loadPacks();
|
||||
|
||||
if (platformType != PlatformType.STANDALONE && config.getRemote().address().equals("auto")) {
|
||||
// Set the remote address to localhost since that is where we are always connecting
|
||||
try {
|
||||
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
|
||||
} catch (UnknownHostException ex) {
|
||||
logger.debug("Unknown host when trying to find localhost.");
|
||||
if (config.isDebugMode()) {
|
||||
ex.printStackTrace();
|
||||
String geyserUdpPort = System.getProperty("geyserUdpPort", "");
|
||||
String pluginUdpPort = geyserUdpPort.isEmpty() ? System.getProperty("pluginUdpPort", "") : geyserUdpPort;
|
||||
if ("-1".equals(pluginUdpPort)) {
|
||||
throw new UnsupportedOperationException("This hosting/service provider does not support applications running on the UDP port");
|
||||
}
|
||||
boolean portPropertyApplied = false;
|
||||
String pluginUdpAddress = System.getProperty("geyserUdpAddress", System.getProperty("pluginUdpAddress", ""));
|
||||
|
||||
if (platformType != PlatformType.STANDALONE) {
|
||||
int javaPort = bootstrap.getServerPort();
|
||||
if (config.getRemote().address().equals("auto")) {
|
||||
config.setAutoconfiguredRemote(true);
|
||||
String serverAddress = bootstrap.getServerBindAddress();
|
||||
if (!serverAddress.isEmpty() && !"0.0.0.0".equals(serverAddress)) {
|
||||
config.getRemote().setAddress(serverAddress);
|
||||
} else {
|
||||
// Set the remote address to localhost since that is where we are always connecting
|
||||
try {
|
||||
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
|
||||
} catch (UnknownHostException ex) {
|
||||
logger.debug("Unknown host when trying to find localhost.");
|
||||
if (config.isDebugMode()) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
config.getRemote().setAddress(InetAddress.getLoopbackAddress().getHostAddress());
|
||||
}
|
||||
}
|
||||
config.getRemote().setAddress(InetAddress.getLoopbackAddress().getHostAddress());
|
||||
if (javaPort != -1) {
|
||||
config.getRemote().setPort(javaPort);
|
||||
}
|
||||
}
|
||||
|
||||
boolean forceMatchServerPort = "server".equals(pluginUdpPort);
|
||||
if ((config.getBedrock().isCloneRemotePort() || forceMatchServerPort) && javaPort != -1) {
|
||||
config.getBedrock().setPort(javaPort);
|
||||
if (forceMatchServerPort) {
|
||||
if (geyserUdpPort.isEmpty()) {
|
||||
logger.info("Port set from system generic property to match Java server.");
|
||||
} else {
|
||||
logger.info("Port set from system property to match Java server.");
|
||||
}
|
||||
portPropertyApplied = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ("server".equals(pluginUdpAddress)) {
|
||||
String address = bootstrap.getServerBindAddress();
|
||||
if (!address.isEmpty()) {
|
||||
config.getBedrock().setAddress(address);
|
||||
}
|
||||
} else if (!pluginUdpAddress.isEmpty()) {
|
||||
config.getBedrock().setAddress(pluginUdpAddress);
|
||||
}
|
||||
|
||||
if (!portPropertyApplied && !pluginUdpPort.isEmpty()) {
|
||||
int port = Integer.parseInt(pluginUdpPort);
|
||||
config.getBedrock().setPort(port);
|
||||
if (geyserUdpPort.isEmpty()) {
|
||||
logger.info("Port set from generic system property: " + port);
|
||||
} else {
|
||||
logger.info("Port set from system property: " + port);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getRemote().authType() == AuthType.FLOODGATE && !bootstrap.isFloodgatePluginPresent()) {
|
||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (config.isAutoconfiguredRemote() && bootstrap.isFloodgatePluginPresent()) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
logger.debug("Auto-setting to Floodgate authentication.");
|
||||
config.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
}
|
||||
}
|
||||
|
||||
String remoteAddress = config.getRemote().address();
|
||||
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
|
||||
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
|
||||
|
@ -308,53 +365,29 @@ public class GeyserImpl implements GeyserApi {
|
|||
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
||||
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
||||
|
||||
// https://github.com/GeyserMC/Geyser/issues/957
|
||||
RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();
|
||||
logger.debug("Setting MTU to " + config.getMtu());
|
||||
|
||||
Integer bedrockThreadCount = Integer.getInteger("Geyser.BedrockNetworkThreads");
|
||||
if (bedrockThreadCount == null) {
|
||||
// Copy the code from Netty's default thread count fallback
|
||||
bedrockThreadCount = Math.max(1, SystemPropertyUtil.getInt("io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2));
|
||||
}
|
||||
|
||||
boolean enableProxyProtocol = config.getBedrock().isEnableProxyProtocol();
|
||||
bedrockServer = new BedrockServer(
|
||||
new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()),
|
||||
bedrockThreadCount,
|
||||
EventLoops.commonGroup(),
|
||||
enableProxyProtocol
|
||||
);
|
||||
|
||||
if (config.isDebugMode()) {
|
||||
logger.debug("EventLoop type: " + EventLoops.getChannelType());
|
||||
if (EventLoops.getChannelType() == EventLoops.ChannelType.NIO) {
|
||||
if (System.getProperties().contains("disableNativeEventLoop")) {
|
||||
logger.debug("EventLoop type is NIO because native event loops are disabled.");
|
||||
} else {
|
||||
logger.debug("Reason for no Epoll: " + Epoll.unavailabilityCause().toString());
|
||||
logger.debug("Reason for no KQueue: " + KQueue.unavailabilityCause().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bedrockServer.setHandler(new ConnectorServerEventHandler(this));
|
||||
|
||||
if (shouldStartListener) {
|
||||
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
||||
if (throwable == null) {
|
||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
|
||||
String.valueOf(config.getBedrock().port())));
|
||||
} else {
|
||||
String address = config.getBedrock().address();
|
||||
int port = config.getBedrock().port();
|
||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
|
||||
if (!"0.0.0.0".equals(address)) {
|
||||
logger.info(Component.text("Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0", NamedTextColor.GREEN));
|
||||
logger.info(Component.text("Then, restart this server.", NamedTextColor.GREEN));
|
||||
this.geyserServer = new GeyserServer(this, bedrockThreadCount);
|
||||
this.geyserServer.bind(new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()))
|
||||
.whenComplete((avoid, throwable) -> {
|
||||
if (throwable == null) {
|
||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
|
||||
String.valueOf(config.getBedrock().port())));
|
||||
} else {
|
||||
String address = config.getBedrock().address();
|
||||
int port = config.getBedrock().port();
|
||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
|
||||
if (!"0.0.0.0".equals(address)) {
|
||||
logger.info(Component.text("Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0", NamedTextColor.GREEN));
|
||||
logger.info(Component.text("Then, restart this server.", NamedTextColor.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}).join();
|
||||
}).join();
|
||||
}
|
||||
|
||||
if (config.getRemote().authType() == AuthType.FLOODGATE) {
|
||||
|
@ -575,7 +608,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
}
|
||||
|
||||
scheduledThread.shutdown();
|
||||
bedrockServer.close();
|
||||
geyserServer.shutdown();
|
||||
if (skinUploader != null) {
|
||||
skinUploader.close();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
|
@ -54,7 +54,7 @@ public class VersionCommand extends GeyserCommand {
|
|||
@Override
|
||||
public void execute(GeyserSession session, GeyserCommandSource sender, String[] args) {
|
||||
String bedrockVersions;
|
||||
List<BedrockPacketCodec> supportedCodecs = GameProtocol.SUPPORTED_BEDROCK_CODECS;
|
||||
List<BedrockCodec> supportedCodecs = GameProtocol.SUPPORTED_BEDROCK_CODECS;
|
||||
if (supportedCodecs.size() > 1) {
|
||||
bedrockVersions = supportedCodecs.get(0).getMinecraftVersion() + " - " + supportedCodecs.get(supportedCodecs.size() - 1).getMinecraftVersion();
|
||||
} else {
|
||||
|
|
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.configuration;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.api.network.AuthType;
|
||||
import org.geysermc.geyser.api.network.BedrockListener;
|
||||
import org.geysermc.geyser.api.network.RemoteServer;
|
||||
import org.geysermc.geyser.network.CIDRMatcher;
|
||||
|
@ -38,6 +39,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public interface GeyserConfiguration {
|
||||
/**
|
||||
* If the config was originally 'auto' before the values changed
|
||||
*/
|
||||
void setAutoconfiguredRemote(boolean autoconfiguredRemote);
|
||||
|
||||
// Modify this when you introduce breaking changes into the config
|
||||
int CURRENT_CONFIG_VERSION = 4;
|
||||
|
@ -115,7 +120,12 @@ public interface GeyserConfiguration {
|
|||
|
||||
int getPendingAuthenticationTimeout();
|
||||
|
||||
boolean isAutoconfiguredRemote();
|
||||
|
||||
interface IBedrockConfiguration extends BedrockListener {
|
||||
void setAddress(String address);
|
||||
|
||||
void setPort(int port);
|
||||
|
||||
boolean isCloneRemotePort();
|
||||
|
||||
|
@ -150,6 +160,8 @@ public interface GeyserConfiguration {
|
|||
default int protocolVersion() {
|
||||
return GameProtocol.getJavaProtocolVersion();
|
||||
}
|
||||
|
||||
void setAuthType(AuthType authType);
|
||||
}
|
||||
|
||||
interface IUserAuthenticationInfo {
|
||||
|
|
|
@ -53,9 +53,6 @@ import java.util.stream.Collectors;
|
|||
@SuppressWarnings("FieldMayBeFinal") // Jackson requires that the fields are not final
|
||||
public abstract class GeyserJacksonConfiguration implements GeyserConfiguration {
|
||||
|
||||
/**
|
||||
* If the config was originally 'auto' before the values changed
|
||||
*/
|
||||
@Setter
|
||||
private boolean autoconfiguredRemote = false;
|
||||
|
||||
|
@ -163,6 +160,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||
public static class BedrockConfiguration implements IBedrockConfiguration {
|
||||
@AsteriskSerializer.Asterisk(isIp = true)
|
||||
@JsonProperty("address")
|
||||
@Setter
|
||||
private String address = "0.0.0.0";
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,11 +31,11 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Files;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||
import org.geysermc.floodgate.util.DeviceOs;
|
||||
import org.geysermc.floodgate.util.FloodgateInfoHolder;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
|
@ -57,7 +57,12 @@ import java.net.InetSocketAddress;
|
|||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
|
@ -219,8 +224,8 @@ public class DumpInfo {
|
|||
private final int javaProtocol;
|
||||
|
||||
MCInfo() {
|
||||
this.bedrockVersions = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getMinecraftVersion).toList();
|
||||
this.bedrockProtocols = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getProtocolVersion).toList();
|
||||
this.bedrockVersions = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockCodec::getMinecraftVersion).toList();
|
||||
this.bedrockProtocols = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockCodec::getProtocolVersion).toList();
|
||||
this.defaultBedrockProtocol = GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion();
|
||||
this.javaVersions = GameProtocol.getJavaVersions();
|
||||
this.javaProtocol = GameProtocol.getJavaProtocolVersion();
|
||||
|
|
|
@ -29,8 +29,8 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.type.*;
|
||||
import org.geysermc.geyser.entity.type.living.*;
|
||||
import org.geysermc.geyser.entity.type.living.animal.*;
|
||||
|
@ -198,7 +198,7 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.AREA_EFFECT_CLOUD)
|
||||
.height(0.5f).width(1.0f)
|
||||
.addTranslator(MetadataType.FLOAT, AreaEffectCloudEntity::setRadius)
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.EFFECT_COLOR, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.EFFECT_COLOR, entityMetadata.getValue()))
|
||||
.addTranslator(null) // Waiting
|
||||
.addTranslator(MetadataType.PARTICLE, AreaEffectCloudEntity::setParticle)
|
||||
.build();
|
||||
|
@ -206,15 +206,15 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.BOAT)
|
||||
.height(0.6f).width(1.6f)
|
||||
.offset(0.35f)
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.HURT_TIME, entityMetadata.getValue())) // Time since last hit
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.HURT_DIRECTION, entityMetadata.getValue())) // Rocking direction
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityDataTypes.HURT_TICKS, entityMetadata.getValue())) // Time since last hit
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityDataTypes.HURT_DIRECTION, entityMetadata.getValue())) // Rocking direction
|
||||
.addTranslator(MetadataType.FLOAT, (boatEntity, entityMetadata) ->
|
||||
// 'Health' in Bedrock, damage taken in Java - it makes motion in Bedrock
|
||||
boatEntity.getDirtyMetadata().put(EntityData.HEALTH, 40 - ((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue())))
|
||||
boatEntity.getDirtyMetadata().put(EntityDataTypes.STRUCTURAL_INTEGRITY, 40 - ((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue())))
|
||||
.addTranslator(MetadataType.INT, BoatEntity::setVariant)
|
||||
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingLeft)
|
||||
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight)
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityDataTypes.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything
|
||||
.build();
|
||||
CHEST_BOAT = EntityDefinition.inherited(ChestBoatEntity::new, BOAT)
|
||||
.type(EntityType.CHEST_BOAT)
|
||||
|
@ -391,11 +391,11 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.MINECART)
|
||||
.height(0.7f).width(0.98f)
|
||||
.offset(0.35f)
|
||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityData.HEALTH, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityData.HURT_DIRECTION, entityMetadata.getValue())) // Direction in which the minecart is shaking
|
||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityDataTypes.STRUCTURAL_INTEGRITY, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityDataTypes.HURT_DIRECTION, entityMetadata.getValue())) // Direction in which the minecart is shaking
|
||||
.addTranslator(MetadataType.FLOAT, (minecartEntity, entityMetadata) ->
|
||||
// Power in Java, time in Bedrock
|
||||
minecartEntity.getDirtyMetadata().put(EntityData.HURT_TIME, Math.min((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue(), 15)))
|
||||
// Power in Java, hurt ticks in Bedrock
|
||||
minecartEntity.getDirtyMetadata().put(EntityDataTypes.HURT_TICKS, Math.min((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue(), 15)))
|
||||
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlock)
|
||||
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlockOffset)
|
||||
.addTranslator(MetadataType.BOOLEAN, MinecartEntity::setShowCustomBlock)
|
||||
|
@ -405,8 +405,8 @@ public final class EntityDefinitions {
|
|||
.build();
|
||||
COMMAND_BLOCK_MINECART = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART)
|
||||
.type(EntityType.COMMAND_BLOCK_MINECART)
|
||||
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_COMMAND, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
|
||||
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.COMMAND_BLOCK_NAME, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
|
||||
.build();
|
||||
FURNACE_MINECART = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
|
||||
.type(EntityType.FURNACE_MINECART)
|
||||
|
@ -437,9 +437,9 @@ public final class EntityDefinitions {
|
|||
.addTranslator(MetadataType.BYTE, LivingEntity::setLivingEntityFlags)
|
||||
.addTranslator(MetadataType.FLOAT, LivingEntity::setHealth)
|
||||
.addTranslator(MetadataType.INT,
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityData.EFFECT_COLOR, entityMetadata.getValue()))
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityDataTypes.EFFECT_COLOR, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN,
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityData.EFFECT_AMBIENT, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0)))
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityDataTypes.EFFECT_AMBIENCE, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0)))
|
||||
.addTranslator(null) // Arrow count
|
||||
.addTranslator(null) // Stinger count
|
||||
.addTranslator(MetadataType.OPTIONAL_POSITION, LivingEntity::setBedPosition)
|
||||
|
@ -916,9 +916,9 @@ public final class EntityDefinitions {
|
|||
LLAMA = EntityDefinition.inherited(LlamaEntity::new, chestedHorseEntityBase)
|
||||
.type(EntityType.LLAMA)
|
||||
.height(1.87f).width(0.9f)
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.STRENGTH, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.STRENGTH, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, LlamaEntity::setCarpetedColor)
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.VARIANT, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.VARIANT, entityMetadata.getValue()))
|
||||
.build();
|
||||
TRADER_LLAMA = EntityDefinition.inherited(TraderLlamaEntity::new, LLAMA)
|
||||
.type(EntityType.TRADER_LLAMA)
|
||||
|
@ -941,7 +941,7 @@ public final class EntityDefinitions {
|
|||
PARROT = EntityDefinition.inherited(ParrotEntity::new, tameableEntityBase)
|
||||
.type(EntityType.PARROT)
|
||||
.height(0.9f).width(0.5f)
|
||||
.addTranslator(MetadataType.INT, (parrotEntity, entityMetadata) -> parrotEntity.getDirtyMetadata().put(EntityData.VARIANT, entityMetadata.getValue())) // Parrot color
|
||||
.addTranslator(MetadataType.INT, (parrotEntity, entityMetadata) -> parrotEntity.getDirtyMetadata().put(EntityDataTypes.VARIANT, entityMetadata.getValue())) // Parrot color
|
||||
.build();
|
||||
WOLF = EntityDefinition.inherited(WolfEntity::new, tameableEntityBase)
|
||||
.type(EntityType.WOLF)
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.entity;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityDataMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataMap;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -35,9 +35,9 @@ import java.util.Map;
|
|||
* A write-only wrapper for temporarily storing entity metadata that will be sent to Bedrock.
|
||||
*/
|
||||
public final class GeyserDirtyMetadata {
|
||||
private final Map<EntityData, Object> metadata = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private final Map<EntityDataType<?>, Object> metadata = new Object2ObjectLinkedOpenHashMap<>();
|
||||
|
||||
public void put(EntityData entityData, Object value) {
|
||||
public <T> void put(EntityDataType<T> entityData, T value) {
|
||||
metadata.put(entityData, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.attribute;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.factory;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.Entity;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -27,8 +27,8 @@ package org.geysermc.geyser.entity.type;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -28,11 +28,13 @@ package org.geysermc.geyser.entity.type;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.particle.Particle;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.ParticleType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
import org.geysermc.geyser.registry.type.ParticleMapping;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -47,12 +49,12 @@ public class AreaEffectCloudEntity extends Entity {
|
|||
protected void initializeMetadata() {
|
||||
super.initializeMetadata();
|
||||
// Without this the cloud doesn't appear,
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_DURATION, Integer.MAX_VALUE);
|
||||
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_DURATION, Integer.MAX_VALUE);
|
||||
|
||||
// This disabled client side shrink of the cloud
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS, 0.0f);
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_CHANGE_RATE, Float.MIN_VALUE);
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_CHANGE_ON_PICKUP, Float.MIN_VALUE);
|
||||
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_RADIUS, 0.0f);
|
||||
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_CHANGE_RATE, Float.MIN_VALUE);
|
||||
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_CHANGE_ON_PICKUP, Float.MIN_VALUE);
|
||||
|
||||
setFlag(EntityFlag.FIRE_IMMUNE, true);
|
||||
}
|
||||
|
@ -60,15 +62,13 @@ public class AreaEffectCloudEntity extends Entity {
|
|||
public void setRadius(FloatEntityMetadata entityMetadata) {
|
||||
// Anything less than 0.5 will cause the cloud to despawn
|
||||
float value = Math.max(entityMetadata.getPrimitiveValue(), 0.5f);
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS, value);
|
||||
dirtyMetadata.put(EntityData.BOUNDING_BOX_WIDTH, 2.0f * value);
|
||||
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_RADIUS, value);
|
||||
dirtyMetadata.put(EntityDataTypes.WIDTH, 2.0f * value);
|
||||
}
|
||||
|
||||
public void setParticle(EntityMetadata<Particle, ?> entityMetadata) {
|
||||
Particle particle = entityMetadata.getValue();
|
||||
int particleId = Registries.PARTICLES.map(particle.getType(), mapping -> mapping.getParticleId(this.session)).orElse(-1);
|
||||
if (particleId != -1) {
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_PARTICLE_ID, particleId);
|
||||
}
|
||||
Registries.PARTICLES.map(particle.getType(), p -> p.levelEventType() instanceof ParticleType particleType ? particleType : null).ifPresent(type ->
|
||||
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_PARTICLE, type));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@ package org.geysermc.geyser.entity.type;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.AnimatePacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
|
@ -73,8 +73,8 @@ public class BoatEntity extends Entity {
|
|||
super(session, entityId, geyserId, uuid, definition, position.add(0d, definition.offset(), 0d), motion, yaw + 90, 0, yaw + 90);
|
||||
|
||||
// Required to be able to move on land 1.16.200+ or apply gravity not in the water 1.16.100+
|
||||
dirtyMetadata.put(EntityData.IS_BUOYANT, (byte) 1);
|
||||
dirtyMetadata.put(EntityData.BUOYANCY_DATA, BUOYANCY_DATA);
|
||||
dirtyMetadata.put(EntityDataTypes.IS_BUOYANT, true);
|
||||
dirtyMetadata.put(EntityDataTypes.BUOYANCY_DATA, BUOYANCY_DATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,7 +124,7 @@ public class BoatEntity extends Entity {
|
|||
|
||||
public void setVariant(IntEntityMetadata entityMetadata) {
|
||||
variant = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.VARIANT, switch (variant) {
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, switch (variant) {
|
||||
case 6, 7 -> variant - 1; // Dark oak and mangrove
|
||||
case 5, 8 -> 0; // TODO temp until 1.20. Cherry and bamboo
|
||||
default -> variant;
|
||||
|
@ -146,7 +146,7 @@ public class BoatEntity extends Entity {
|
|||
}
|
||||
} else {
|
||||
// Indicate that the row position should be reset
|
||||
dirtyMetadata.put(EntityData.ROW_TIME_LEFT, 0.0f);
|
||||
dirtyMetadata.put(EntityDataTypes.ROW_TIME_LEFT, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class BoatEntity extends Entity {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.ROW_TIME_RIGHT, 0.0f);
|
||||
dirtyMetadata.put(EntityDataTypes.ROW_TIME_RIGHT, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.ContainerOpenPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
@ -48,10 +48,10 @@ public class CommandBlockMinecartEntity extends DefaultBlockMinecartEntity {
|
|||
protected void initializeMetadata() {
|
||||
super.initializeMetadata();
|
||||
// Required, or else the GUI will not open
|
||||
dirtyMetadata.put(EntityData.CONTAINER_TYPE, (byte) 16);
|
||||
dirtyMetadata.put(EntityData.CONTAINER_BASE_SIZE, 1);
|
||||
dirtyMetadata.put(EntityDataTypes.CONTAINER_TYPE, (byte) 16);
|
||||
dirtyMetadata.put(EntityDataTypes.CONTAINER_SIZE, 1);
|
||||
// Required, or else the client does not bother to send a packet back with the new information
|
||||
dirtyMetadata.put(EntityData.COMMAND_BLOCK_ENABLED, (byte) 1);
|
||||
dirtyMetadata.put(EntityDataTypes.COMMAND_BLOCK_ENABLED, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,8 +59,8 @@ public class CommandBlockMinecartEntity extends DefaultBlockMinecartEntity {
|
|||
*/
|
||||
@Override
|
||||
public void updateDefaultBlockMetadata() {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getCommandBlockRuntimeId());
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, 6);
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getCommandBlock());
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,8 +27,8 @@ package org.geysermc.geyser.entity.type;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
public DefaultBlockMinecartEntity(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);
|
||||
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, (byte) 1);
|
||||
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +60,7 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
customBlock = entityMetadata.getPrimitiveValue();
|
||||
|
||||
if (showCustomBlock) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(customBlock));
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(customBlock));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
customBlockOffset = entityMetadata.getPrimitiveValue();
|
||||
|
||||
if (showCustomBlock) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, customBlockOffset);
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, customBlockOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
||||
if (entityMetadata.getPrimitiveValue()) {
|
||||
showCustomBlock = true;
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(customBlock));
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, customBlockOffset);
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(customBlock));
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, customBlockOffset);
|
||||
} else {
|
||||
showCustomBlock = false;
|
||||
updateDefaultBlockMetadata();
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -54,9 +54,9 @@ public class EnderCrystalEntity extends Entity {
|
|||
// Usually performed client-side on Bedrock except for Ender Dragon respawn event
|
||||
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
||||
if (optionalPos.isPresent()) {
|
||||
dirtyMetadata.put(EntityData.BLOCK_TARGET, optionalPos.get());
|
||||
dirtyMetadata.put(EntityDataTypes.BLOCK_TARGET_POS, optionalPos.get());
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.BLOCK_TARGET, Vector3i.ZERO);
|
||||
dirtyMetadata.put(EntityDataTypes.BLOCK_TARGET_POS, Vector3i.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,16 +32,21 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEnti
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlags;
|
||||
import com.nukkitx.protocol.bedrock.packet.*;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.RemoveEntityPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
||||
import org.geysermc.geyser.api.entity.type.GeyserEntity;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -52,13 +57,14 @@ import org.geysermc.geyser.util.InteractiveTag;
|
|||
import org.geysermc.geyser.util.MathUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Entity {
|
||||
public class Entity implements GeyserEntity {
|
||||
protected final GeyserSession session;
|
||||
|
||||
protected int entityId;
|
||||
|
@ -110,7 +116,7 @@ public class Entity {
|
|||
* think they are set to false.
|
||||
*/
|
||||
@Getter(AccessLevel.NONE)
|
||||
protected final EntityFlags flags = new EntityFlags();
|
||||
protected final EnumSet<EntityFlag> flags = EnumSet.noneOf(EntityFlag.class);
|
||||
/**
|
||||
* Indicates if flags have been updated and need to be sent to the client.
|
||||
*/
|
||||
|
@ -142,9 +148,9 @@ public class Entity {
|
|||
* Called on entity spawn. Used to populate the entity metadata and flags with default values.
|
||||
*/
|
||||
protected void initializeMetadata() {
|
||||
dirtyMetadata.put(EntityData.SCALE, 1f);
|
||||
dirtyMetadata.put(EntityData.COLOR, (byte) 0);
|
||||
dirtyMetadata.put(EntityData.MAX_AIR_SUPPLY, getMaxAir());
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, 1f);
|
||||
dirtyMetadata.put(EntityDataTypes.COLOR, (byte) 0);
|
||||
dirtyMetadata.put(EntityDataTypes.AIR_SUPPLY_MAX, getMaxAir());
|
||||
setDimensions(Pose.STANDING);
|
||||
setFlag(EntityFlag.HAS_GRAVITY, true);
|
||||
setFlag(EntityFlag.HAS_COLLISION, true);
|
||||
|
@ -165,7 +171,7 @@ public class Entity {
|
|||
addEntityPacket.setUniqueEntityId(geyserId);
|
||||
addEntityPacket.setPosition(position);
|
||||
addEntityPacket.setMotion(motion);
|
||||
addEntityPacket.setRotation(getBedrockRotation());
|
||||
addEntityPacket.setRotation(getBedrockRotation().toVector2(false)); // TODO: Check this
|
||||
addEntityPacket.getMetadata().putFlags(flags);
|
||||
dirtyMetadata.apply(addEntityPacket.getMetadata());
|
||||
addAdditionalSpawnData(addEntityPacket);
|
||||
|
@ -320,14 +326,14 @@ public class Entity {
|
|||
}
|
||||
|
||||
public final boolean getFlag(EntityFlag flag) {
|
||||
return flags.getFlag(flag);
|
||||
return this.flags.contains(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a flag value and determines if the flags would need synced with the Bedrock client.
|
||||
*/
|
||||
public final void setFlag(EntityFlag flag, boolean value) {
|
||||
flagsDirty |= flags.setFlag(flag, value);
|
||||
flagsDirty |= value ? this.flags.add(flag) : this.flags.remove(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +385,7 @@ public class Entity {
|
|||
}
|
||||
|
||||
protected void setAirSupply(int amount) {
|
||||
dirtyMetadata.put(EntityData.AIR_SUPPLY, (short) MathUtils.constrain(amount, 0, getMaxAir()));
|
||||
dirtyMetadata.put(EntityDataTypes.AIR_SUPPLY, (short) MathUtils.constrain(amount, 0, getMaxAir()));
|
||||
}
|
||||
|
||||
protected short getMaxAir() {
|
||||
|
@ -390,15 +396,15 @@ public class Entity {
|
|||
Optional<Component> name = entityMetadata.getValue();
|
||||
if (name.isPresent()) {
|
||||
nametag = MessageTranslator.convertMessage(name.get(), session.locale());
|
||||
dirtyMetadata.put(EntityData.NAMETAG, nametag);
|
||||
dirtyMetadata.put(EntityDataTypes.NAME, nametag);
|
||||
} else if (!nametag.isEmpty()) {
|
||||
// Clear nametag
|
||||
dirtyMetadata.put(EntityData.NAMETAG, "");
|
||||
dirtyMetadata.put(EntityDataTypes.NAME, "");
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisplayNameVisible(BooleanEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.NAMETAG_ALWAYS_SHOW, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
dirtyMetadata.put(EntityDataTypes.NAMETAG_ALWAYS_SHOW, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
}
|
||||
|
||||
public final void setSilent(BooleanEntityMetadata entityMetadata) {
|
||||
|
@ -431,7 +437,7 @@ public class Entity {
|
|||
public boolean setBoundingBoxHeight(float height) {
|
||||
if (height != boundingBoxHeight) {
|
||||
boundingBoxHeight = height;
|
||||
dirtyMetadata.put(EntityData.BOUNDING_BOX_HEIGHT, boundingBoxHeight);
|
||||
dirtyMetadata.put(EntityDataTypes.HEIGHT, boundingBoxHeight);
|
||||
|
||||
updatePassengerOffsets();
|
||||
return true;
|
||||
|
@ -442,7 +448,7 @@ public class Entity {
|
|||
public void setBoundingBoxWidth(float width) {
|
||||
if (width != boundingBoxWidth) {
|
||||
boundingBoxWidth = width;
|
||||
dirtyMetadata.put(EntityData.BOUNDING_BOX_WIDTH, boundingBoxWidth);
|
||||
dirtyMetadata.put(EntityDataTypes.WIDTH, boundingBoxWidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,12 +460,12 @@ public class Entity {
|
|||
// The Java client caps its freezing tick percentage at 140
|
||||
int freezingTicks = Math.min(entityMetadata.getPrimitiveValue(), 140);
|
||||
float freezingPercentage = freezingTicks / 140f;
|
||||
dirtyMetadata.put(EntityData.FREEZING_EFFECT_STRENGTH, freezingPercentage);
|
||||
dirtyMetadata.put(EntityDataTypes.FREEZING_EFFECT_STRENGTH, freezingPercentage);
|
||||
return freezingPercentage;
|
||||
}
|
||||
|
||||
public void setRiderSeatPosition(Vector3f position) {
|
||||
dirtyMetadata.put(EntityData.RIDER_SEAT_POSITION, position);
|
||||
dirtyMetadata.put(EntityDataTypes.SEAT_OFFSET, position);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -504,6 +510,11 @@ public class Entity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int javaId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return this.valid;
|
||||
}
|
||||
|
@ -519,7 +530,7 @@ public class Entity {
|
|||
break;
|
||||
}
|
||||
}
|
||||
session.getPlayerEntity().getDirtyMetadata().put(EntityData.INTERACTIVE_TAG, tag.getValue());
|
||||
session.getPlayerEntity().getDirtyMetadata().put(EntityDataTypes.INTERACT_TEXT, tag.getValue());
|
||||
session.getPlayerEntity().updateBedrockMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -42,14 +42,14 @@ public class EvokerFangsEntity extends Entity implements Tickable {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
// As of 1.18.2 Bedrock, this line is required for the entity to be visible
|
||||
// 22 is the starting number on Java Edition
|
||||
dirtyMetadata.put(EntityData.LIMITED_LIFE, this.limitedLife);
|
||||
dirtyMetadata.put(EntityDataTypes.DATA_LIFETIME_TICKS, this.limitedLife);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (attackStarted) {
|
||||
if (--this.limitedLife > 0 && this.limitedLife % 2 == 0) { // Matches Bedrock behavior
|
||||
dirtyMetadata.put(EntityData.LIMITED_LIFE, this.limitedLife);
|
||||
dirtyMetadata.put(EntityDataTypes.DATA_LIFETIME_TICKS, this.limitedLife);
|
||||
updateBedrockMetadata();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -35,6 +35,6 @@ public class ExpOrbEntity extends Entity {
|
|||
public ExpOrbEntity(GeyserSession session, int amount, int entityId, long geyserId, Vector3f position) {
|
||||
super(session, entityId, geyserId, null, EntityDefinitions.EXPERIENCE_ORB, position, Vector3f.ZERO, 0, 0, 0);
|
||||
|
||||
this.dirtyMetadata.put(EntityData.EXPERIENCE_VALUE, amount);
|
||||
this.dirtyMetadata.put(EntityDataTypes.TRADE_EXPERIENCE, amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class FallingBlockEntity extends Entity {
|
|||
public FallingBlockEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw, int javaId) {
|
||||
super(session, entityId, geyserId, uuid, EntityDefinitions.FALLING_BLOCK, position, motion, yaw, pitch, headYaw);
|
||||
|
||||
this.dirtyMetadata.put(EntityData.VARIANT, session.getBlockMappings().getBedrockBlockId(javaId));
|
||||
this.dirtyMetadata.put(EntityDataTypes.BLOCK, session.getBlockMappings().getBedrockBlock(javaId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
|||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import com.nukkitx.nbt.NbtType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetEntityMotionPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.cloudburstmc.nbt.NbtType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityMotionPacket;
|
||||
import org.geysermc.floodgate.util.DeviceOs;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||
|
@ -133,7 +133,7 @@ public class FireworkEntity extends Entity {
|
|||
|
||||
NbtMapBuilder builder = NbtMap.builder();
|
||||
builder.put("Fireworks", fireworksBuilder.build());
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, builder.build());
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_FIREWORK, builder.build());
|
||||
}
|
||||
|
||||
public void setPlayerGliding(EntityMetadata<OptionalInt, ?> entityMetadata) {
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.erosion.util.BlockPositionIterator;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
|
@ -65,7 +65,7 @@ public class FishingHookEntity extends ThrowableEntity {
|
|||
setBoundingBoxHeight(128);
|
||||
|
||||
this.bedrockOwnerId = owner.getGeyserId();
|
||||
this.dirtyMetadata.put(EntityData.OWNER_EID, this.bedrockOwnerId);
|
||||
this.dirtyMetadata.put(EntityDataTypes.OWNER_EID, this.bedrockOwnerId);
|
||||
}
|
||||
|
||||
public void setHookedEntity(IntEntityMetadata entityMetadata) {
|
||||
|
@ -73,7 +73,7 @@ public class FishingHookEntity extends ThrowableEntity {
|
|||
Entity entity = session.getEntityCache().getEntityByJavaId(hookedEntityId);
|
||||
if (entity != null) {
|
||||
bedrockTargetId = entity.getGeyserId();
|
||||
dirtyMetadata.put(EntityData.TARGET_EID, bedrockTargetId);
|
||||
dirtyMetadata.put(EntityDataTypes.TARGET_EID, bedrockTargetId);
|
||||
hooked = true;
|
||||
} else {
|
||||
hooked = false;
|
||||
|
|
|
@ -27,8 +27,8 @@ package org.geysermc.geyser.entity.type;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -51,8 +51,8 @@ public class FurnaceMinecartEntity extends DefaultBlockMinecartEntity {
|
|||
|
||||
@Override
|
||||
public void updateDefaultBlockMetadata() {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(hasFuel ? BlockStateValues.JAVA_FURNACE_LIT_ID : BlockStateValues.JAVA_FURNACE_ID));
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, 6);
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(hasFuel ? BlockStateValues.JAVA_FURNACE_LIT_ID : BlockStateValues.JAVA_FURNACE_ID));
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,13 +27,13 @@ package org.geysermc.geyser.entity.type;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
import com.nukkitx.protocol.bedrock.packet.AddItemEntityPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.AddItemEntityPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -31,13 +31,14 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntit
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.cloudburstmc.protocol.bedrock.data.defintions.BlockDefinition;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.BlockEntityDataPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -59,7 +60,7 @@ public class ItemFrameEntity extends Entity {
|
|||
/**
|
||||
* Specific block 'state' we are emulating in Bedrock.
|
||||
*/
|
||||
private final int bedrockRuntimeId;
|
||||
private final BlockDefinition blockDefinition;
|
||||
/**
|
||||
* Rotation of item in frame.
|
||||
*/
|
||||
|
@ -90,7 +91,7 @@ public class ItemFrameEntity extends Entity {
|
|||
.putByte("item_frame_photo_bit", (byte) 0);
|
||||
blockBuilder.put("states", statesBuilder.build());
|
||||
|
||||
bedrockRuntimeId = session.getBlockMappings().getItemFrame(blockBuilder.build());
|
||||
blockDefinition = session.getBlockMappings().getItemFrame(blockBuilder.build());
|
||||
bedrockPosition = Vector3i.from(position.getFloorX(), position.getFloorY(), position.getFloorZ());
|
||||
|
||||
session.getItemFrameCache().put(bedrockPosition, this);
|
||||
|
@ -114,7 +115,7 @@ public class ItemFrameEntity extends Entity {
|
|||
this.heldItem = entityMetadata.getValue();
|
||||
ItemData itemData = ItemTranslator.translateToBedrock(session, heldItem);
|
||||
|
||||
String customIdentifier = session.getItemMappings().getCustomIdMappings().get(itemData.getId());
|
||||
String customIdentifier = session.getItemMappings().getCustomIdMappings().get(itemData.getDefinition().getRuntimeId());
|
||||
|
||||
NbtMapBuilder builder = NbtMap.builder();
|
||||
|
||||
|
@ -152,7 +153,7 @@ public class ItemFrameEntity extends Entity {
|
|||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||
updateBlockPacket.setDataLayer(0);
|
||||
updateBlockPacket.setBlockPosition(bedrockPosition);
|
||||
updateBlockPacket.setRuntimeId(session.getBlockMappings().getBedrockAirId()); //TODO maybe set this to the world block or another item frame?
|
||||
updateBlockPacket.setDefinition(session.getBlockMappings().getBedrockAir()); //TODO maybe set this to the world block or another item frame?
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||
|
@ -190,7 +191,7 @@ public class ItemFrameEntity extends Entity {
|
|||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||
updateBlockPacket.setDataLayer(0);
|
||||
updateBlockPacket.setBlockPosition(bedrockPosition);
|
||||
updateBlockPacket.setRuntimeId(bedrockRuntimeId);
|
||||
updateBlockPacket.setDefinition(blockDefinition);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -35,26 +35,27 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntit
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MobEquipmentPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.defintions.ItemDefinition;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MobEquipmentPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.AttributeUtils;
|
||||
import org.geysermc.geyser.util.ChunkUtils;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -88,7 +89,7 @@ public class LivingEntity extends Entity {
|
|||
protected void initializeMetadata() {
|
||||
super.initializeMetadata();
|
||||
// Matches Bedrock behavior; is always set to this
|
||||
dirtyMetadata.put(EntityData.HEALTH, 1);
|
||||
dirtyMetadata.put(EntityDataTypes.STRUCTURAL_INTEGRITY, 1);
|
||||
}
|
||||
|
||||
public void setLivingEntityFlags(ByteEntityMetadata entityMetadata) {
|
||||
|
@ -97,8 +98,7 @@ public class LivingEntity extends Entity {
|
|||
boolean isUsingItem = (xd & 0x01) == 0x01;
|
||||
boolean isUsingOffhand = (xd & 0x02) == 0x02;
|
||||
|
||||
ItemMapping shield = session.getItemMappings().getStoredItems().shield();
|
||||
boolean isUsingShield = hasShield(isUsingOffhand, shield);
|
||||
boolean isUsingShield = hasShield(isUsingOffhand);
|
||||
|
||||
setFlag(EntityFlag.USING_ITEM, isUsingItem && !isUsingShield);
|
||||
// Override the blocking
|
||||
|
@ -125,27 +125,19 @@ public class LivingEntity extends Entity {
|
|||
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
||||
if (optionalPos.isPresent()) {
|
||||
Vector3i bedPosition = optionalPos.get();
|
||||
dirtyMetadata.put(EntityData.BED_POSITION, bedPosition);
|
||||
int bed = session.getGeyser().getWorldManager().getBlockAt(session, bedPosition);
|
||||
// Bed has to be updated, or else player is floating in the air
|
||||
ChunkUtils.updateBlock(session, bed, bedPosition);
|
||||
// Indicate that the player should enter the sleep cycle
|
||||
// Has to be a byte or it does not work
|
||||
// (Bed position is what actually triggers sleep - "pose" is only optional)
|
||||
dirtyMetadata.put(EntityData.PLAYER_FLAGS, (byte) 2);
|
||||
dirtyMetadata.put(EntityDataTypes.BED_POSITION, bedPosition);
|
||||
return bedPosition;
|
||||
} else {
|
||||
// Player is no longer sleeping
|
||||
dirtyMetadata.put(EntityData.PLAYER_FLAGS, (byte) 0);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean hasShield(boolean offhand, ItemMapping shieldMapping) {
|
||||
protected boolean hasShield(boolean offhand) {
|
||||
ItemMapping shieldMapping = session.getItemMappings().getStoredItems().shield();
|
||||
if (offhand) {
|
||||
return offHand.getId() == shieldMapping.getBedrockId();
|
||||
return offHand.getDefinition().equals(shieldMapping.getBedrockDefinition());
|
||||
} else {
|
||||
return hand.getId() == shieldMapping.getBedrockId();
|
||||
return hand.getDefinition().equals(shieldMapping.getBedrockDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +181,7 @@ public class LivingEntity extends Entity {
|
|||
@Override
|
||||
public InteractionResult interact(Hand hand) {
|
||||
GeyserItemStack itemStack = session.getPlayerInventory().getItemInHand(hand);
|
||||
if (itemStack.getJavaId() == session.getItemMappings().getStoredItems().nameTag()) {
|
||||
if (itemStack.asItem() == Items.NAME_TAG) {
|
||||
InteractionResult result = checkInteractWithNameTag(itemStack);
|
||||
if (result.consumesAction()) {
|
||||
return result;
|
||||
|
@ -219,10 +211,10 @@ public class LivingEntity extends Entity {
|
|||
// If an entity has a banner on them, it will be in the helmet slot in Java but the chestplate spot in Bedrock
|
||||
// But don't overwrite the chestplate if it isn't empty
|
||||
ItemMapping banner = session.getItemMappings().getStoredItems().banner();
|
||||
if (chestplate.getId() == ItemData.AIR.getId() && helmet.getId() == banner.getBedrockId()) {
|
||||
if (ItemDefinition.AIR.equals(chestplate.getDefinition()) && helmet.getDefinition().equals(banner)) {
|
||||
chestplate = this.helmet;
|
||||
helmet = ItemData.AIR;
|
||||
} else if (chestplate.getId() == banner.getBedrockId()) {
|
||||
} else if (chestplate.getDefinition().equals(banner)) {
|
||||
// Prevent chestplate banners from showing erroneously
|
||||
chestplate = ItemData.AIR;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ package org.geysermc.geyser.entity.type;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -45,17 +45,17 @@ public class MinecartEntity extends Entity {
|
|||
}
|
||||
|
||||
public void setCustomBlock(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(entityMetadata.getPrimitiveValue()));
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(entityMetadata.getPrimitiveValue()));
|
||||
}
|
||||
|
||||
public void setCustomBlockOffset(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getPrimitiveValue());
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
||||
// If the custom block should be enabled
|
||||
// Needs a byte based off of Java's boolean
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,8 +27,8 @@ package org.geysermc.geyser.entity.type;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.AddPaintingPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.AddPaintingPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.level.PaintingType;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -41,7 +41,7 @@ public class SpawnerMinecartEntity extends DefaultBlockMinecartEntity {
|
|||
|
||||
@Override
|
||||
public void updateDefaultBlockMetadata() {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(BlockStateValues.JAVA_SPAWNER_ID));
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, 6);
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(BlockStateValues.JAVA_SPAWNER_ID));
|
||||
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, 6);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -43,9 +43,9 @@ public class TNTEntity extends Entity implements Tickable {
|
|||
}
|
||||
|
||||
public void setFuseLength(IntEntityMetadata entityMetadata) {
|
||||
currentTick = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
currentTick = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.IGNITED, true);
|
||||
dirtyMetadata.put(EntityData.FUSE_LENGTH, currentTick);
|
||||
dirtyMetadata.put(EntityDataTypes.FUSE_TIME, currentTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,11 +56,11 @@ public class TNTEntity extends Entity implements Tickable {
|
|||
}
|
||||
|
||||
if (currentTick % 5 == 0) {
|
||||
dirtyMetadata.put(EntityData.FUSE_LENGTH, currentTick);
|
||||
dirtyMetadata.put(EntityDataTypes.FUSE_TIME, currentTick);
|
||||
|
||||
SetEntityDataPacket packet = new SetEntityDataPacket();
|
||||
packet.setRuntimeEntityId(geyserId);
|
||||
packet.getMetadata().put(EntityData.FUSE_LENGTH, currentTick);
|
||||
packet.getMetadata().put(EntityDataTypes.FUSE_TIME, currentTick);
|
||||
session.sendUpstreamPacket(packet);
|
||||
}
|
||||
currentTick--;
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
|
@ -45,11 +45,11 @@ public class TextDisplayEntity extends Entity {
|
|||
protected void initializeMetadata() {
|
||||
super.initializeMetadata();
|
||||
// Remove armor stand body
|
||||
this.dirtyMetadata.put(EntityData.SCALE, 0f);
|
||||
this.dirtyMetadata.put(EntityData.NAMETAG_ALWAYS_SHOW, (byte) 1);
|
||||
this.dirtyMetadata.put(EntityDataTypes.SCALE, 0f);
|
||||
this.dirtyMetadata.put(EntityDataTypes.NAMETAG_ALWAYS_SHOW, (byte) 1);
|
||||
}
|
||||
|
||||
public void setText(EntityMetadata<Component, ?> entityMetadata) {
|
||||
this.dirtyMetadata.put(EntityData.NAMETAG, MessageTranslator.convertMessage(entityMetadata.getValue()));
|
||||
this.dirtyMetadata.put(EntityDataTypes.NAME, MessageTranslator.convertMessage(entityMetadata.getValue()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -174,7 +174,7 @@ public class ThrowableEntity extends Entity implements Tickable {
|
|||
public boolean despawnEntity() {
|
||||
if (definition.entityType() == EntityType.ENDER_PEARL) {
|
||||
LevelEventPacket particlePacket = new LevelEventPacket();
|
||||
particlePacket.setType(LevelEventType.PARTICLE_TELEPORT);
|
||||
particlePacket.setType(LevelEvent.PARTICLE_TELEPORT);
|
||||
particlePacket.setPosition(position);
|
||||
session.sendUpstreamPacket(particlePacket);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ package org.geysermc.geyser.entity.type;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -29,13 +29,14 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.item.Potion;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
@ -52,25 +53,25 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
|
|||
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||
ItemStack itemStack = entityMetadata.getValue();
|
||||
if (itemStack == null) {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
|
||||
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
|
||||
setFlag(EntityFlag.ENCHANTED, false);
|
||||
setFlag(EntityFlag.LINGERING, false);
|
||||
} else {
|
||||
ItemMapping mapping = session.getItemMappings().getMapping(itemStack);
|
||||
if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) {
|
||||
// As of Java 1.19.3, the server/client doesn't seem to care of the item is actually a potion?
|
||||
if (itemStack.getNbt() != null) {
|
||||
Tag potionTag = itemStack.getNbt().get("Potion");
|
||||
if (potionTag instanceof StringTag) {
|
||||
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
||||
if (potion != null) {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, potion.getBedrockId());
|
||||
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, (int) potion.getBedrockId());
|
||||
setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion));
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
|
||||
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
|
||||
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionTag.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
boolean isLingering = mapping.getJavaIdentifier().equals("minecraft:lingering_potion");
|
||||
boolean isLingering = Registries.JAVA_ITEMS.get().get(itemStack.getId()) == Items.LINGERING_POTION;
|
||||
setFlag(EntityFlag.LINGERING, isLingering);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.item.TippedArrowPotion;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -47,13 +47,13 @@ public class TippedArrowEntity extends AbstractArrowEntity {
|
|||
int potionColor = entityMetadata.getPrimitiveValue();
|
||||
// -1 means no color
|
||||
if (potionColor == -1) {
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, 0);
|
||||
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) 0);
|
||||
} else {
|
||||
TippedArrowPotion potion = TippedArrowPotion.getByJavaColor(potionColor);
|
||||
if (potion != null && potion.getJavaColor() != -1) {
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, (byte) potion.getBedrockId());
|
||||
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) potion.getBedrockId());
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, 0);
|
||||
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.geyser.entity.type;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -51,7 +51,7 @@ public class AbstractFishEntity extends WaterEntity {
|
|||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (EntityUtils.attemptToBucket(session, itemInHand)) {
|
||||
if (EntityUtils.attemptToBucket(itemInHand)) {
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
return super.mobInteract(hand, itemInHand);
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -44,12 +44,12 @@ public class AgeableEntity extends CreatureEntity {
|
|||
protected void initializeMetadata() {
|
||||
super.initializeMetadata();
|
||||
// Required as of 1.19.3 Java
|
||||
dirtyMetadata.put(EntityData.SCALE, getAdultSize());
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, getAdultSize());
|
||||
}
|
||||
|
||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||
boolean isBaby = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.SCALE, isBaby ? getBabySize() : getAdultSize());
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, isBaby ? getBabySize() : getAdultSize());
|
||||
setFlag(EntityFlag.BABY, isBaby);
|
||||
|
||||
setBoundingBoxHeight(definition.height() * (isBaby ? getBabySize() : getAdultSize()));
|
||||
|
|
|
@ -27,10 +27,11 @@ package org.geysermc.geyser.entity.type.living;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
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.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -87,6 +88,6 @@ public class AllayEntity extends MobEntity {
|
|||
}
|
||||
|
||||
private boolean isDuplicationItem(GeyserItemStack itemStack) {
|
||||
return itemStack.getJavaId() == session.getItemMappings().getStoredItems().amethystShard();
|
||||
return itemStack.asItem() == Items.AMETHYST_SHARD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -29,15 +29,17 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.MathUtils;
|
||||
|
@ -171,27 +173,27 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
}
|
||||
|
||||
public void setHeadRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.MARK_VARIANT, EntityFlag.INTERESTED, EntityFlag.CHARGED, EntityFlag.POWERED, entityMetadata.getValue());
|
||||
onRotationUpdate(EntityDataTypes.MARK_VARIANT, EntityFlag.INTERESTED, EntityFlag.CHARGED, EntityFlag.POWERED, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setBodyRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.VARIANT, EntityFlag.IN_LOVE, EntityFlag.CELEBRATING, EntityFlag.CELEBRATING_SPECIAL, entityMetadata.getValue());
|
||||
onRotationUpdate(EntityDataTypes.VARIANT, EntityFlag.IN_LOVE, EntityFlag.CELEBRATING, EntityFlag.CELEBRATING_SPECIAL, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setLeftArmRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.TRADE_TIER, EntityFlag.CHARGING, EntityFlag.CRITICAL, EntityFlag.DANCING, entityMetadata.getValue());
|
||||
onRotationUpdate(EntityDataTypes.TRADE_TIER, EntityFlag.CHARGING, EntityFlag.CRITICAL, EntityFlag.DANCING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setRightArmRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.MAX_TRADE_TIER, EntityFlag.ELDER, EntityFlag.EMOTING, EntityFlag.IDLING, entityMetadata.getValue());
|
||||
onRotationUpdate(EntityDataTypes.MAX_TRADE_TIER, EntityFlag.ELDER, EntityFlag.EMOTING, EntityFlag.IDLING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setLeftLegRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.SKIN_ID, EntityFlag.IS_ILLAGER_CAPTAIN, EntityFlag.IS_IN_UI, EntityFlag.LINGERING, entityMetadata.getValue());
|
||||
onRotationUpdate(EntityDataTypes.SKIN_ID, EntityFlag.IS_ILLAGER_CAPTAIN, EntityFlag.IS_IN_UI, EntityFlag.LINGERING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setRightLegRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.HURT_DIRECTION, EntityFlag.IS_PREGNANT, EntityFlag.SHEARED, EntityFlag.STALKING, entityMetadata.getValue());
|
||||
onRotationUpdate(EntityDataTypes.HURT_DIRECTION, EntityFlag.IS_PREGNANT, EntityFlag.SHEARED, EntityFlag.STALKING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,7 +207,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
* @param negativeZToggle the flag to set true if the Z value of rotation is negative
|
||||
* @param rotation the Java rotation value
|
||||
*/
|
||||
private void onRotationUpdate(EntityData dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) {
|
||||
private void onRotationUpdate(EntityDataType dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) {
|
||||
// Indicate that rotation should be checked
|
||||
setFlag(EntityFlag.BRIBED, true);
|
||||
|
||||
|
@ -246,7 +248,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
|
||||
@Override
|
||||
public InteractionResult interactAt(Hand hand) {
|
||||
if (!isMarker && session.getPlayerInventory().getItemInHand(hand).getJavaId() != session.getItemMappings().getStoredItems().nameTag()) {
|
||||
if (!isMarker && session.getPlayerInventory().getItemInHand(hand).asItem() != Items.NAME_TAG) {
|
||||
// Java Edition returns SUCCESS if in spectator mode, but this is overrided with an earlier check on the client
|
||||
return InteractionResult.CONSUME;
|
||||
} else {
|
||||
|
@ -308,7 +310,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
if (!isInvisible) {
|
||||
// The armor stand isn't invisible. We good.
|
||||
setFlag(EntityFlag.INVISIBLE, false);
|
||||
dirtyMetadata.put(EntityData.SCALE, getScale());
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, getScale());
|
||||
updateOffsetRequirement(false);
|
||||
|
||||
if (secondEntity != null) {
|
||||
|
@ -324,7 +326,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
if (!isNametagEmpty && (!helmet.equals(ItemData.AIR) || !chestplate.equals(ItemData.AIR) || !leggings.equals(ItemData.AIR)
|
||||
|| !boots.equals(ItemData.AIR) || !hand.equals(ItemData.AIR) || !offHand.equals(ItemData.AIR))) {
|
||||
// Reset scale of the proper armor stand
|
||||
this.dirtyMetadata.put(EntityData.SCALE, getScale());
|
||||
this.dirtyMetadata.put(EntityDataTypes.SCALE, getScale());
|
||||
// Set the proper armor stand to invisible to show armor
|
||||
setFlag(EntityFlag.INVISIBLE, true);
|
||||
// Update the position of the armor stand
|
||||
|
@ -341,23 +343,23 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
secondEntity.isSmall = isSmall;
|
||||
secondEntity.isMarker = isMarker;
|
||||
secondEntity.positionRequiresOffset = true; // Offset should always be applied
|
||||
secondEntity.getDirtyMetadata().put(EntityData.NAMETAG, nametag);
|
||||
secondEntity.getDirtyMetadata().put(EntityData.NAMETAG_ALWAYS_SHOW, isNameTagVisible ? (byte) 1 : (byte) 0);
|
||||
secondEntity.flags.merge(this.flags);
|
||||
secondEntity.getDirtyMetadata().put(EntityDataTypes.NAME, nametag);
|
||||
secondEntity.getDirtyMetadata().put(EntityDataTypes.NAMETAG_ALWAYS_SHOW, isNameTagVisible ? (byte) 1 : (byte) 0);
|
||||
secondEntity.flags.addAll(this.flags);
|
||||
// Guarantee this copy is NOT invisible
|
||||
secondEntity.setFlag(EntityFlag.INVISIBLE, false);
|
||||
// Scale to 0 to show nametag
|
||||
secondEntity.getDirtyMetadata().put(EntityData.SCALE, 0.0f);
|
||||
secondEntity.getDirtyMetadata().put(EntityDataTypes.SCALE, 0.0f);
|
||||
// No bounding box as we don't want to interact with this entity
|
||||
secondEntity.getDirtyMetadata().put(EntityData.BOUNDING_BOX_WIDTH, 0.0f);
|
||||
secondEntity.getDirtyMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f);
|
||||
secondEntity.getDirtyMetadata().put(EntityDataTypes.WIDTH, 0.0f);
|
||||
secondEntity.getDirtyMetadata().put(EntityDataTypes.HEIGHT, 0.0f);
|
||||
if (!secondEntity.valid) { // Spawn the entity once
|
||||
secondEntity.spawnEntity();
|
||||
}
|
||||
} else if (isNametagEmpty) {
|
||||
// We can just make an invisible entity
|
||||
// Reset scale of the proper armor stand
|
||||
dirtyMetadata.put(EntityData.SCALE, getScale());
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, getScale());
|
||||
// Set the proper armor stand to invisible to show armor
|
||||
setFlag(EntityFlag.INVISIBLE, true);
|
||||
// Update offset
|
||||
|
@ -371,7 +373,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
// Nametag is not empty and there is no armor
|
||||
// We don't need to make a new entity
|
||||
setFlag(EntityFlag.INVISIBLE, false);
|
||||
dirtyMetadata.put(EntityData.SCALE, 0.0f);
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, 0.0f);
|
||||
// As the above is applied, we need an offset
|
||||
updateOffsetRequirement(!isMarker);
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
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.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class IronGolemEntity extends GolemEntity {
|
|||
// Indicate that we should show cracks through a resource pack
|
||||
setFlag(EntityFlag.BRIBED, true);
|
||||
// Required, or else the overlay is black
|
||||
dirtyMetadata.put(EntityData.COLOR_2, (byte) 0);
|
||||
dirtyMetadata.put(EntityDataTypes.COLOR_2, (byte) 0);
|
||||
// Default max health. Ensures correct cracked texture is used
|
||||
// Bug reproducible in 1.19.0 JE vanilla/fabric when spawning a new iron golem
|
||||
maxHealth = 100f;
|
||||
|
@ -52,8 +53,8 @@ public class IronGolemEntity extends GolemEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().ironIngot()) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (itemInHand.asItem() == Items.IRON_INGOT) {
|
||||
if (health < maxHealth) {
|
||||
// Healing the iron golem
|
||||
return InteractionResult.SUCCESS;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class MagmaCubeEntity extends SlimeEntity {
|
|||
public void updateJump(boolean newOnGround) {
|
||||
if (newOnGround != onGround) {
|
||||
// Add the jumping effect to the magma cube
|
||||
dirtyMetadata.put(EntityData.CLIENT_EVENT, (byte) (newOnGround ? 1 : 2));
|
||||
dirtyMetadata.put(EntityDataTypes.CLIENT_EVENT, (byte) (newOnGround ? 1 : 2));
|
||||
updateBedrockMetadata();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,15 +27,15 @@ package org.geysermc.geyser.entity.type.living;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import lombok.Getter;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.SpawnEggItem;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -67,7 +67,7 @@ public class MobEntity extends LivingEntity {
|
|||
|
||||
public void setLeashHolderBedrockId(long bedrockId) {
|
||||
this.leashHolderBedrockId = bedrockId;
|
||||
dirtyMetadata.put(EntityData.LEASH_HOLDER_EID, bedrockId);
|
||||
dirtyMetadata.put(EntityDataTypes.LEASH_HOLDER, bedrockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,11 +79,10 @@ public class MobEntity extends LivingEntity {
|
|||
return InteractiveTag.REMOVE_LEASH;
|
||||
} else {
|
||||
GeyserItemStack itemStack = session.getPlayerInventory().getItemInHand(hand);
|
||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
||||
if (itemStack.getJavaId() == storedItems.lead() && canBeLeashed()) {
|
||||
if (itemStack.asItem() == Items.LEAD && canBeLeashed()) {
|
||||
// We shall leash
|
||||
return InteractiveTag.LEASH;
|
||||
} else if (itemStack.getJavaId() == storedItems.nameTag()) {
|
||||
} else if (itemStack.asItem() == Items.NAME_TAG) {
|
||||
InteractionResult result = checkInteractWithNameTag(itemStack);
|
||||
if (result.consumesAction()) {
|
||||
return InteractiveTag.NAME;
|
||||
|
@ -116,18 +115,16 @@ public class MobEntity extends LivingEntity {
|
|||
}
|
||||
|
||||
private InteractionResult checkPriorityInteractions(GeyserItemStack itemInHand) {
|
||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
||||
if (itemInHand.getJavaId() == storedItems.lead() && canBeLeashed()) {
|
||||
if (itemInHand.asItem() == Items.LEAD && canBeLeashed()) {
|
||||
// We shall leash
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (itemInHand.getJavaId() == storedItems.nameTag()) {
|
||||
} else if (itemInHand.asItem() == Items.NAME_TAG) {
|
||||
InteractionResult result = checkInteractWithNameTag(itemInHand);
|
||||
if (result.consumesAction()) {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
ItemMapping mapping = itemInHand.getMapping(session);
|
||||
if (mapping.getJavaIdentifier().endsWith("_spawn_egg")) {
|
||||
if (itemInHand.asItem() instanceof SpawnEggItem) {
|
||||
// Using the spawn egg on this entity to create a child
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class SlimeEntity extends MobEntity {
|
|||
}
|
||||
|
||||
public void setScale(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.SCALE, 0.10f + entityMetadata.getPrimitiveValue());
|
||||
dirtyMetadata.put(EntityDataTypes.SCALE, 0.10f + entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,10 +27,11 @@ package org.geysermc.geyser.entity.type.living;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
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.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -52,8 +53,8 @@ public class SnowGolemEntity extends GolemEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (session.getItemMappings().getStoredItems().shears() == itemInHand.getJavaId() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
||||
// Shearing the snow golem
|
||||
return InteractiveTag.SHEAR;
|
||||
}
|
||||
|
@ -62,8 +63,8 @@ public class SnowGolemEntity extends GolemEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (session.getItemMappings().getStoredItems().shears() == itemInHand.getJavaId() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
||||
// Shearing the snow golem
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.Tickable;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -61,6 +62,6 @@ public class TadpoleEntity extends AbstractFishEntity {
|
|||
}
|
||||
|
||||
private boolean isFood(GeyserItemStack itemStack) {
|
||||
return itemStack.getJavaId() == session.getItemMappings().getStoredItems().slimeBall();
|
||||
return itemStack.asItem() == Items.SLIME_BALL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
|
|
|
@ -26,13 +26,14 @@
|
|||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.living.AgeableEntity;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -47,24 +48,20 @@ public class AnimalEntity extends AgeableEntity {
|
|||
}
|
||||
|
||||
public final boolean canEat(GeyserItemStack itemStack) {
|
||||
ItemMapping mapping = itemStack.getMapping(session);
|
||||
String handIdentifier = mapping.getJavaIdentifier();
|
||||
return canEat(handIdentifier.replace("minecraft:", ""), mapping);
|
||||
return canEat(itemStack.asItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param javaIdentifierStripped the stripped Java identifier of the item that is potential breeding food. For example,
|
||||
* <code>wheat</code>.
|
||||
* @return true if this is a valid item to breed with for this animal.
|
||||
*/
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
public boolean canEat(Item item) {
|
||||
// This is what it defaults to. OK.
|
||||
return javaIdentifierStripped.equals("wheat");
|
||||
return item == Items.WHEAT;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (canEat(itemInHand)) {
|
||||
return InteractiveTag.FEED;
|
||||
}
|
||||
|
@ -73,7 +70,7 @@ public class AnimalEntity extends AgeableEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (canEat(itemInHand)) {
|
||||
// FEED
|
||||
if (getFlag(EntityFlag.BABY)) {
|
||||
|
|
|
@ -28,12 +28,12 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.EntityUtils;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
@ -52,7 +52,7 @@ public class AxolotlEntity extends AnimalEntity {
|
|||
case 1 -> variant = 3; // Java - "Wild" (brown)
|
||||
case 3 -> variant = 1; // Java - cyan
|
||||
}
|
||||
dirtyMetadata.put(EntityData.VARIANT, variant);
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, variant);
|
||||
}
|
||||
|
||||
public void setPlayingDead(BooleanEntityMetadata entityMetadata) {
|
||||
|
@ -60,8 +60,8 @@ public class AxolotlEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return session.getTagCache().isAxolotlTemptItem(mapping);
|
||||
public boolean canEat(Item item) {
|
||||
return session.getTagCache().isAxolotlTemptItem(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,8 +76,8 @@ public class AxolotlEntity extends AnimalEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (EntityUtils.attemptToBucket(session, itemInHand)) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (EntityUtils.attemptToBucket(itemInHand)) {
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
return super.mobInteract(hand, itemInHand);
|
||||
|
|
|
@ -27,13 +27,13 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -55,7 +55,7 @@ public class BeeEntity extends AnimalEntity {
|
|||
session.sendUpstreamPacket(packet);
|
||||
}
|
||||
// If the bee has stung
|
||||
dirtyMetadata.put(EntityData.MARK_VARIANT, (xd & 0x04) == 0x04 ? 1 : 0);
|
||||
dirtyMetadata.put(EntityDataTypes.MARK_VARIANT, (xd & 0x04) == 0x04 ? 1 : 0);
|
||||
// If the bee has nectar or not
|
||||
setFlag(EntityFlag.POWERED, (xd & 0x08) == 0x08);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class BeeEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return session.getTagCache().isFlower(mapping);
|
||||
public boolean canEat(Item item) {
|
||||
return session.getTagCache().isFlower(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,21 +25,24 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChickenEntity extends AnimalEntity {
|
||||
private static final Set<Item> VALID_FOOD = Set.of(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS);
|
||||
|
||||
public ChickenEntity(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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return javaIdentifierStripped.contains("seeds");
|
||||
public boolean canEat(Item item) {
|
||||
return VALID_FOOD.contains(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||
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.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -45,8 +46,8 @@ public class CowEntity extends AnimalEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (getFlag(EntityFlag.BABY) || !itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) {
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
|
||||
return super.testMobInteraction(hand, itemInHand);
|
||||
}
|
||||
|
||||
|
@ -55,8 +56,8 @@ public class CowEntity extends AnimalEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (getFlag(EntityFlag.BABY) || !itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
|
||||
return super.mobInteract(hand, itemInHand);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -43,7 +43,7 @@ public class FoxEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
public void setFoxVariant(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.VARIANT, entityMetadata.getPrimitiveValue());
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setFoxFlags(ByteEntityMetadata entityMetadata) {
|
||||
|
@ -55,7 +55,7 @@ public class FoxEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return session.getTagCache().isFoxFood(mapping);
|
||||
public boolean canEat(Item item) {
|
||||
return session.getTagCache().isFoxFood(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,13 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.Entity;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
@ -55,7 +56,7 @@ public class FrogEntity extends AnimalEntity {
|
|||
|
||||
public void setFrogVariant(IntEntityMetadata entityMetadata) {
|
||||
int variant = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.VARIANT, switch (variant) {
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, switch (variant) {
|
||||
case 1 -> 2; // White
|
||||
case 2 -> 1; // Green
|
||||
default -> variant;
|
||||
|
@ -67,15 +68,15 @@ public class FrogEntity extends AnimalEntity {
|
|||
if (entityId.isPresent()) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(entityId.getAsInt());
|
||||
if (entity != null) {
|
||||
dirtyMetadata.put(EntityData.TARGET_EID, entity.getGeyserId());
|
||||
dirtyMetadata.put(EntityDataTypes.TARGET_EID, entity.getGeyserId());
|
||||
}
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.TARGET_EID, 0L);
|
||||
dirtyMetadata.put(EntityDataTypes.TARGET_EID, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return mapping.getJavaId() == session.getItemMappings().getStoredItems().slimeBall();
|
||||
public boolean canEat(Item item) {
|
||||
return item == Items.SLIME_BALL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,13 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
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.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
||||
|
@ -67,10 +68,12 @@ public class GoatEntity extends AnimalEntity {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO testMobInteraction?
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!getFlag(EntityFlag.BABY) && itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!getFlag(EntityFlag.BABY) && itemInHand.asItem() == Items.BUCKET) {
|
||||
session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position);
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
|
@ -89,6 +92,6 @@ public class GoatEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
private void setHornCount() {
|
||||
dirtyMetadata.put(EntityData.GOAT_HORN_COUNT, (hasLeftHorn ? 1 : 0) + (hasRightHorn ? 1 : 0));
|
||||
dirtyMetadata.put(EntityDataTypes.GOAT_HORN_COUNT, (hasLeftHorn ? 1 : 0) + (hasRightHorn ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,11 @@
|
|||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -53,8 +54,8 @@ public class HoglinEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return javaIdentifierStripped.equals("crimson_fungus");
|
||||
public boolean canEat(Item item) {
|
||||
return item == Items.CRIMSON_FUNGUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,11 +27,12 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.FlowerItem;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -48,18 +49,17 @@ public class MooshroomEntity extends AnimalEntity {
|
|||
|
||||
public void setVariant(ObjectEntityMetadata<String> entityMetadata) {
|
||||
isBrown = entityMetadata.getValue().equals("brown");
|
||||
dirtyMetadata.put(EntityData.VARIANT, isBrown ? 1 : 0);
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, isBrown ? 1 : 0);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!isBaby()) {
|
||||
if (itemInHand.getJavaId() == storedItems.bowl()) {
|
||||
if (itemInHand.asItem() == Items.BOWL) {
|
||||
// Stew
|
||||
return InteractiveTag.MOOSHROOM_MILK_STEW;
|
||||
} else if (isAlive() && itemInHand.getJavaId() == storedItems.shears()) {
|
||||
} else if (isAlive() && itemInHand.asItem() == Items.SHEARS) {
|
||||
// Shear items
|
||||
return InteractiveTag.MOOSHROOM_SHEAR;
|
||||
}
|
||||
|
@ -69,16 +69,15 @@ public class MooshroomEntity extends AnimalEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
boolean isBaby = isBaby();
|
||||
if (!isBaby && itemInHand.getJavaId() == storedItems.bowl()) {
|
||||
if (!isBaby && itemInHand.asItem() == Items.BOWL) {
|
||||
// Stew
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (!isBaby && isAlive() && itemInHand.getJavaId() == storedItems.shears()) {
|
||||
} else if (!isBaby && isAlive() && itemInHand.asItem() == Items.SHEARS) {
|
||||
// Shear items
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (isBrown && session.getTagCache().isSmallFlower(itemInHand) && itemInHand.getMapping(session).isHasSuspiciousStewEffect()) {
|
||||
} else if (isBrown && session.getTagCache().isSmallFlower(itemInHand) && itemInHand.asItem() instanceof FlowerItem) {
|
||||
// ?
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -45,8 +46,8 @@ public class OcelotEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return javaIdentifierStripped.equals("cod") || javaIdentifierStripped.equals("salmon");
|
||||
public boolean canEat(Item item) {
|
||||
return item == Items.COD || item == Items.SALMON;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -28,14 +28,15 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InteractiveTag;
|
||||
|
@ -55,13 +56,13 @@ public class PandaEntity extends AnimalEntity {
|
|||
public void setEatingCounter(IntEntityMetadata entityMetadata) {
|
||||
int count = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.EATING, count > 0);
|
||||
dirtyMetadata.put(EntityData.EATING_COUNTER, count);
|
||||
dirtyMetadata.put(EntityDataTypes.EATING_COUNTER, count);
|
||||
if (count != 0) {
|
||||
// Particles and sound
|
||||
EntityEventPacket packet = new EntityEventPacket();
|
||||
packet.setRuntimeEntityId(geyserId);
|
||||
packet.setType(EntityEventType.EATING_ITEM);
|
||||
packet.setData(session.getItemMappings().getStoredItems().bamboo().getBedrockId() << 16);
|
||||
packet.setData(session.getItemMappings().getStoredItems().bamboo().getBedrockDefinition().getRuntimeId() << 16);
|
||||
session.sendUpstreamPacket(packet);
|
||||
}
|
||||
}
|
||||
|
@ -82,19 +83,19 @@ public class PandaEntity extends AnimalEntity {
|
|||
setFlag(EntityFlag.ROLLING, (xd & 0x04) == 0x04);
|
||||
setFlag(EntityFlag.SITTING, (xd & 0x08) == 0x08);
|
||||
// Required to put these both for sitting to actually show
|
||||
dirtyMetadata.put(EntityData.SITTING_AMOUNT, (xd & 0x08) == 0x08 ? 1f : 0f);
|
||||
dirtyMetadata.put(EntityData.SITTING_AMOUNT_PREVIOUS, (xd & 0x08) == 0x08 ? 1f : 0f);
|
||||
dirtyMetadata.put(EntityDataTypes.SITTING_AMOUNT, (xd & 0x08) == 0x08 ? 1f : 0f);
|
||||
dirtyMetadata.put(EntityDataTypes.SITTING_AMOUNT_PREVIOUS, (xd & 0x08) == 0x08 ? 1f : 0f);
|
||||
setFlag(EntityFlag.LAYING_DOWN, (xd & 0x10) == 0x10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return javaIdentifierStripped.equals("bamboo");
|
||||
public boolean canEat(Item item) {
|
||||
return item == Items.BAMBOO;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (mainGene == Gene.WORRIED && session.isThunder()) {
|
||||
return InteractiveTag.NONE;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ public class PandaEntity extends AnimalEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (mainGene == Gene.WORRIED && session.isThunder()) {
|
||||
// Huh!
|
||||
return InteractionResult.PASS;
|
||||
|
@ -133,14 +134,14 @@ public class PandaEntity extends AnimalEntity {
|
|||
if (mainGene.isRecessive) {
|
||||
if (mainGene == hiddenGene) {
|
||||
// Main and hidden genes match; this is what the panda looks like.
|
||||
dirtyMetadata.put(EntityData.VARIANT, mainGene.ordinal());
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, mainGene.ordinal());
|
||||
} else {
|
||||
// Genes have no effect on appearance
|
||||
dirtyMetadata.put(EntityData.VARIANT, Gene.NORMAL.ordinal());
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, Gene.NORMAL.ordinal());
|
||||
}
|
||||
} else {
|
||||
// No need to worry about hidden gene
|
||||
dirtyMetadata.put(EntityData.VARIANT, mainGene.ordinal());
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, mainGene.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.EntityUtils;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
|
@ -46,13 +47,13 @@ public class PigEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
return javaIdentifierStripped.equals("carrot") || javaIdentifierStripped.equals("potato") || javaIdentifierStripped.equals("beetroot");
|
||||
public boolean canEat(Item item) {
|
||||
return item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
|
||||
// Mount
|
||||
return InteractiveTag.MOUNT;
|
||||
|
@ -61,7 +62,7 @@ public class PigEntity extends AnimalEntity {
|
|||
if (superTag != InteractiveTag.NONE) {
|
||||
return superTag;
|
||||
} else {
|
||||
return EntityUtils.attemptToSaddle(session, this, itemInHand).consumesAction()
|
||||
return EntityUtils.attemptToSaddle(this, itemInHand).consumesAction()
|
||||
? InteractiveTag.SADDLE : InteractiveTag.NONE;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +70,7 @@ public class PigEntity extends AnimalEntity {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
|
||||
// Mount
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@ -78,7 +79,7 @@ public class PigEntity extends AnimalEntity {
|
|||
if (superResult.consumesAction()) {
|
||||
return superResult;
|
||||
} else {
|
||||
return EntityUtils.attemptToSaddle(session, this, itemInHand);
|
||||
return EntityUtils.attemptToSaddle(this, itemInHand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -39,7 +39,7 @@ public class PolarBearEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
||||
public boolean canEat(Item item) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.geyser.entity.type.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.type.living.AbstractFishEntity;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -42,7 +42,7 @@ public class PufferFishEntity extends AbstractFishEntity {
|
|||
|
||||
public void setPufferfishSize(IntEntityMetadata entityMetadata) {
|
||||
int puffsize = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.PUFFERFISH_SIZE, (byte) puffsize);
|
||||
dirtyMetadata.put(EntityData.VARIANT, puffsize);
|
||||
dirtyMetadata.put(EntityDataTypes.PUFFED_STATE, (byte) puffsize);
|
||||
dirtyMetadata.put(EntityDataTypes.VARIANT, puffsize);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue