Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 22:40:18 +01:00
Merge pull request #5 from blockgamecode/feature/blocky-protocol-3.0
Feature/blocky protocol 3.0
Dieser Commit ist enthalten in:
Commit
67ae0e8b9a
@ -14,7 +14,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
|
|||||||
|
|
||||||
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
|
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
|
||||||
|
|
||||||
### Currently supporting Minecraft Bedrock 1.19.30 - 1.19.71 and Minecraft Java 1.19.4.
|
### Currently supporting Minecraft Bedrock 1.19.40 - 1.19.80 and Minecraft Java 1.19.4.
|
||||||
|
|
||||||
## Setting Up
|
## Setting Up
|
||||||
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
|
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
org.geysermc.geyser.processor.BlockEntityProcessor
|
org.geysermc.geyser.processor.BlockEntityProcessor
|
||||||
org.geysermc.geyser.processor.CollisionRemapperProcessor
|
org.geysermc.geyser.processor.CollisionRemapperProcessor
|
||||||
org.geysermc.geyser.processor.ItemRemapperProcessor
|
|
||||||
org.geysermc.geyser.processor.PacketTranslatorProcessor
|
org.geysermc.geyser.processor.PacketTranslatorProcessor
|
||||||
org.geysermc.geyser.processor.SoundHandlerProcessor
|
org.geysermc.geyser.processor.SoundHandlerProcessor
|
@ -25,11 +25,31 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.api.connection;
|
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.api.connection.Connection;
|
||||||
import org.geysermc.geyser.api.command.CommandSource;
|
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.
|
* Represents a player connection used in Geyser.
|
||||||
*/
|
*/
|
||||||
public interface GeyserConnection extends Connection, CommandSource {
|
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();
|
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.
|
* 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 allowOffhand(boolean allowOffhand);
|
||||||
|
|
||||||
|
Builder displayHandheld(boolean displayHandheld);
|
||||||
|
|
||||||
Builder textureSize(int textureSize);
|
Builder textureSize(int textureSize);
|
||||||
|
|
||||||
Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets);
|
Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets);
|
||||||
|
@ -56,6 +56,14 @@ public interface CustomItemOptions {
|
|||||||
*/
|
*/
|
||||||
@NonNull OptionalInt damagePredicate();
|
@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
|
* Checks if the item has at least one option set
|
||||||
*
|
*
|
||||||
@ -78,6 +86,8 @@ public interface CustomItemOptions {
|
|||||||
|
|
||||||
Builder damagePredicate(int damagePredicate);
|
Builder damagePredicate(int damagePredicate);
|
||||||
|
|
||||||
|
Builder defaultItem(boolean defaultItem);
|
||||||
|
|
||||||
CustomItemOptions build();
|
CustomItemOptions build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,17 +130,22 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
|||||||
boolean isHat();
|
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.
|
* 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
|
* @return if the item is a tool
|
||||||
*/
|
*/
|
||||||
boolean isTool();
|
@Deprecated
|
||||||
|
default boolean isTool() {
|
||||||
|
return displayHandheld();
|
||||||
|
}
|
||||||
|
|
||||||
static NonVanillaCustomItemData.Builder builder() {
|
static NonVanillaCustomItemData.Builder builder() {
|
||||||
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
|
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Builder extends CustomItemData.Builder {
|
interface Builder extends CustomItemData.Builder {
|
||||||
|
@Override
|
||||||
Builder name(@NonNull String name);
|
Builder name(@NonNull String name);
|
||||||
|
|
||||||
Builder identifier(@NonNull String identifier);
|
Builder identifier(@NonNull String identifier);
|
||||||
@ -169,14 +174,29 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
|||||||
|
|
||||||
Builder hat(boolean isHat);
|
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
|
@Override
|
||||||
Builder displayName(@NonNull String displayName);
|
Builder displayName(@NonNull String displayName);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Builder icon(@NonNull String icon);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Builder allowOffhand(boolean allowOffhand);
|
Builder allowOffhand(boolean allowOffhand);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Builder displayHandheld(boolean displayHandheld);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Builder textureSize(int textureSize);
|
Builder textureSize(int textureSize);
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import org.geysermc.geyser.GeyserBootstrap;
|
|||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
@ -45,6 +44,7 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
|||||||
import org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor;
|
import org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -55,6 +55,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -116,26 +117,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||||||
return;
|
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
|
// Force-disable query if enabled, or else Geyser won't enable
|
||||||
for (ListenerInfo info : getProxy().getConfig().getListeners()) {
|
for (ListenerInfo info : getProxy().getConfig().getListeners()) {
|
||||||
if (info.isQueryEnabled() && info.getQueryPort() == geyserConfig.getBedrock().port()) {
|
if (info.isQueryEnabled() && info.getQueryPort() == geyserConfig.getBedrock().port()) {
|
||||||
@ -154,17 +135,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
|
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
|
||||||
// task that waits for a field to be filled which is set after the plugin enable
|
// task that waits for a field to be filled which is set after the plugin enable
|
||||||
// process is complete
|
// process is complete
|
||||||
@ -274,4 +244,31 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||||||
public SocketAddress getSocketAddress() {
|
public SocketAddress getSocketAddress() {
|
||||||
return this.geyserInjector.getServerSocketAddress();
|
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 testFloodgatePluginPresent() {
|
||||||
|
if (getProxy().getPluginManager().getPlugin("floodgate") != null) {
|
||||||
|
geyserConfig.loadFloodgate(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
relocate("net.kyori", "org.geysermc.relocate.kyori")
|
||||||
|
|
||||||
dependencies {
|
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-classes-epoll:.*"))
|
||||||
exclude(dependency("io.netty:netty-transport-native-epoll:.*"))
|
exclude(dependency("io.netty:netty-transport-native-epoll:.*"))
|
||||||
exclude(dependency("io.netty:netty-transport-native-unix-common:.*"))
|
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-transport-native-kqueue:.*"))
|
||||||
exclude(dependency("io.netty:netty-handler:.*"))
|
exclude(dependency("io.netty:netty-handler:.*"))
|
||||||
exclude(dependency("io.netty:netty-common:.*"))
|
exclude(dependency("io.netty:netty-common:.*"))
|
||||||
|
@ -41,7 +41,6 @@ import org.geysermc.geyser.GeyserBootstrap;
|
|||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
import org.geysermc.geyser.GeyserLogger;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
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.GeyserCommand;
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
@ -53,13 +52,16 @@ import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
|||||||
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||||
private static GeyserFabricMod instance;
|
private static GeyserFabricMod instance;
|
||||||
@ -138,33 +140,6 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
public void startGeyser(MinecraftServer server) {
|
public void startGeyser(MinecraftServer server) {
|
||||||
this.server = 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));
|
|
||||||
|
|
||||||
GeyserImpl.start();
|
GeyserImpl.start();
|
||||||
|
|
||||||
this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
|
this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
|
||||||
@ -242,6 +217,27 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
return this.server.getServerVersion();
|
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 testFloodgatePluginPresent() {
|
||||||
|
Optional<ModContainer> floodgate = FabricLoader.getInstance().getModContainer("floodgate");
|
||||||
|
if (floodgate.isPresent()) {
|
||||||
|
geyserConfig.loadFloodgate(this, floodgate.orElse(null));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public InputStream getResourceOrNull(String resource) {
|
public InputStream getResourceOrNull(String resource) {
|
||||||
|
@ -26,10 +26,6 @@
|
|||||||
package org.geysermc.geyser.platform.fabric.world;
|
package org.geysermc.geyser.platform.fabric.world;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
|
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 me.lucko.fabric.api.permissions.v0.Permissions;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.*;
|
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.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.LecternBlockEntity;
|
import net.minecraft.world.level.block.entity.LecternBlockEntity;
|
||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
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.erosion.util.LecternUtils;
|
||||||
import org.geysermc.geyser.level.GeyserWorldManager;
|
import org.geysermc.geyser.level.GeyserWorldManager;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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("net.kyori", "net.kyori.adventure.text.logger.slf4j.ComponentLogger")
|
||||||
platformRelocate("org.objectweb.asm")
|
platformRelocate("org.objectweb.asm")
|
||||||
platformRelocate("me.lucko.commodore")
|
platformRelocate("me.lucko.commodore")
|
||||||
platformRelocate("io.netty.channel.kqueue")
|
|
||||||
|
|
||||||
// These dependencies are already present on the platform
|
// These dependencies are already present on the platform
|
||||||
provided(libs.viaversion)
|
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-classes-epoll:.*"))
|
||||||
exclude(dependency("io.netty:netty-transport-native-epoll:.*"))
|
exclude(dependency("io.netty:netty-transport-native-epoll:.*"))
|
||||||
exclude(dependency("io.netty:netty-transport-native-unix-common:.*"))
|
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-transport-native-kqueue:.*"))
|
||||||
exclude(dependency("io.netty:netty-handler:.*"))
|
exclude(dependency("io.netty:netty-handler:.*"))
|
||||||
exclude(dependency("io.netty:netty-common:.*"))
|
exclude(dependency("io.netty:netty-common:.*"))
|
||||||
|
@ -49,7 +49,6 @@ import org.geysermc.geyser.GeyserImpl;
|
|||||||
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
@ -62,9 +61,12 @@ import org.geysermc.geyser.platform.spigot.command.GeyserSpigotCommandExecutor;
|
|||||||
import org.geysermc.geyser.platform.spigot.command.GeyserSpigotCommandManager;
|
import org.geysermc.geyser.platform.spigot.command.GeyserSpigotCommandManager;
|
||||||
import org.geysermc.geyser.platform.spigot.world.GeyserPistonListener;
|
import org.geysermc.geyser.platform.spigot.world.GeyserPistonListener;
|
||||||
import org.geysermc.geyser.platform.spigot.world.GeyserSpigotBlockPlaceListener;
|
import org.geysermc.geyser.platform.spigot.world.GeyserSpigotBlockPlaceListener;
|
||||||
import org.geysermc.geyser.platform.spigot.world.manager.*;
|
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotLegacyNativeWorldManager;
|
||||||
|
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotNativeWorldManager;
|
||||||
|
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotWorldManager;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -170,31 +172,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||||||
return;
|
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);
|
this.geyserCommandManager = new GeyserSpigotCommandManager(geyser);
|
||||||
this.geyserCommandManager.init();
|
this.geyserCommandManager.init();
|
||||||
|
|
||||||
@ -431,40 +408,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||||||
return this.geyserInjector.getServerSocketAddress();
|
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
|
* @return the server version before ViaVersion finishes initializing
|
||||||
*/
|
*/
|
||||||
@ -494,4 +437,24 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||||||
// All mapping data is null, which means client and server block states are the same
|
// All mapping data is null, which means client and server block states are the same
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getServerBindAddress() {
|
||||||
|
return Bukkit.getIp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getServerPort() {
|
||||||
|
return Bukkit.getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean testFloodgatePluginPresent() {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("floodgate") != null) {
|
||||||
|
geyserConfig.loadFloodgate(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.geyser.platform.spigot.world;
|
package org.geysermc.geyser.platform.spigot.world;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType;
|
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.Object2IntArrayMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.platform.spigot.world;
|
package org.geysermc.geyser.platform.spigot.world;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -59,7 +59,7 @@ public class GeyserSpigotBlockPlaceListener implements Listener {
|
|||||||
event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ())));
|
event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ())));
|
||||||
} else {
|
} else {
|
||||||
String javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
|
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(":");
|
placeBlockSoundPacket.setIdentifier(":");
|
||||||
session.sendUpstreamPacket(placeBlockSoundPacket);
|
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.mc.protocol.data.game.level.block.BlockEntityInfo;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.nukkitx.nbt.NbtMap;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.geysermc.erosion.bukkit.BukkitLecterns;
|
import org.geysermc.erosion.bukkit.BukkitLecterns;
|
||||||
import org.geysermc.erosion.bukkit.BukkitUtils;
|
import org.geysermc.erosion.bukkit.BukkitUtils;
|
||||||
import org.geysermc.erosion.bukkit.PickBlockUtils;
|
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.
|
// Terrible behavior, but this is basically what's always been happening behind the scenes anyway.
|
||||||
CompletableFuture<String> blockData = new CompletableFuture<>();
|
CompletableFuture<String> blockData = new CompletableFuture<>();
|
||||||
Bukkit.getRegionScheduler().execute(this.plugin, block.getLocation(), () -> blockData.complete(block.getBlockData().getAsString()));
|
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
|
@Override
|
||||||
|
@ -41,6 +41,7 @@ import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandManager;
|
|||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandExecutor;
|
import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandExecutor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.api.Server;
|
import org.spongepowered.api.Server;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.config.ConfigDir;
|
import org.spongepowered.api.config.ConfigDir;
|
||||||
@ -179,24 +180,6 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||||||
return;
|
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();
|
GeyserImpl.start();
|
||||||
|
|
||||||
if (geyserConfig.isLegacyPingPassthrough()) {
|
if (geyserConfig.isLegacyPingPassthrough()) {
|
||||||
@ -245,4 +228,20 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||||||
public String getMinecraftServerVersion() {
|
public String getMinecraftServerVersion() {
|
||||||
return Sponge.platform().minecraftVersion().name();
|
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 testFloodgatePluginPresent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,3 +27,10 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
|||||||
|
|
||||||
transform(Log4j2PluginsCacheFileTransformer())
|
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.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
import org.geysermc.geyser.util.LoopbackUtil;
|
import org.geysermc.geyser.util.LoopbackUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -291,6 +292,22 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||||||
return new GeyserStandaloneDumpInfo(this);
|
return new GeyserStandaloneDumpInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getServerBindAddress() {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getServerPort() {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean testFloodgatePluginPresent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link BeanPropertyDefinition}s for the given class
|
* Get the {@link BeanPropertyDefinition}s for the given class
|
||||||
*
|
*
|
||||||
|
@ -41,7 +41,6 @@ import org.geysermc.geyser.GeyserBootstrap;
|
|||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
@ -50,12 +49,12 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
|||||||
import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor;
|
import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -111,22 +110,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||||||
return;
|
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());
|
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||||
|
|
||||||
@ -141,19 +124,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||||||
return;
|
return;
|
||||||
} catch (ClassNotFoundException ignored) {
|
} 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() {
|
private void postStartup() {
|
||||||
@ -247,4 +217,25 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||||||
public SocketAddress getSocketAddress() {
|
public SocketAddress getSocketAddress() {
|
||||||
return this.geyserInjector.getServerSocketAddress();
|
return this.geyserInjector.getServerSocketAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getServerBindAddress() {
|
||||||
|
return proxyServer.getBoundAddress().getHostString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getServerPort() {
|
||||||
|
return proxyServer.getBoundAddress().getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean testFloodgatePluginPresent() {
|
||||||
|
var floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
|
||||||
|
if (floodgate.isPresent()) {
|
||||||
|
geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,12 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(16))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val platforms = setOf(
|
val platforms = setOf(
|
||||||
projects.fabric,
|
projects.fabric,
|
||||||
projects.bungeecord,
|
projects.bungeecord,
|
||||||
|
@ -20,9 +20,7 @@ dependencies {
|
|||||||
// Network libraries
|
// Network libraries
|
||||||
implementation(libs.websocket)
|
implementation(libs.websocket)
|
||||||
|
|
||||||
api(libs.protocol) {
|
api(libs.bundles.protocol)
|
||||||
exclude("com.nukkitx.network", "raknet")
|
|
||||||
}
|
|
||||||
|
|
||||||
api(libs.mcauthlib)
|
api(libs.mcauthlib)
|
||||||
api(libs.mcprotocollib) {
|
api(libs.mcprotocollib) {
|
||||||
@ -60,12 +58,18 @@ dependencies {
|
|||||||
compileOnly(projects.ap)
|
compileOnly(projects.ap)
|
||||||
|
|
||||||
annotationProcessor(projects.ap)
|
annotationProcessor(projects.ap)
|
||||||
|
|
||||||
|
api(libs.events)
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.api {
|
configurations.api {
|
||||||
// This is still experimental - additionally, it could only really benefit standalone
|
// This is still experimental - additionally, it could only really benefit standalone
|
||||||
exclude(group = "io.netty.incubator", module = "netty-incubator-transport-native-io_uring")
|
exclude(group = "io.netty.incubator", module = "netty-incubator-transport-native-io_uring")
|
||||||
}
|
}
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_14
|
||||||
|
targetCompatibility = JavaVersion.VERSION_14
|
||||||
|
}
|
||||||
|
|
||||||
tasks.processResources {
|
tasks.processResources {
|
||||||
// This is solely for backwards compatibility for other programs that used this file before the switch to gradle.
|
// 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;
|
package org.geysermc.connector;
|
||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
|
||||||
import org.geysermc.api.Geyser;
|
import org.geysermc.api.Geyser;
|
||||||
import org.geysermc.common.PlatformType;
|
import org.geysermc.common.PlatformType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -52,10 +51,6 @@ public class GeyserConnector {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BedrockServer getBedrockServer() {
|
|
||||||
return GeyserImpl.getInstance().getBedrockServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShuttingDown() {
|
public boolean isShuttingDown() {
|
||||||
return GeyserImpl.getInstance().isShuttingDown();
|
return GeyserImpl.getInstance().isShuttingDown();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.connector.network.session;
|
package org.geysermc.connector.network.session;
|
||||||
|
|
||||||
import com.github.steveice10.packetlib.packet.Packet;
|
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;
|
import org.geysermc.connector.network.session.auth.AuthData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser;
|
package org.geysermc.geyser;
|
||||||
|
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
|
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
|
||||||
@ -34,10 +33,6 @@ import java.nio.file.Path;
|
|||||||
|
|
||||||
public class FloodgateKeyLoader {
|
public class FloodgateKeyLoader {
|
||||||
public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
|
public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
|
||||||
if (config.getRemote().authType() != AuthType.FLOODGATE) {
|
|
||||||
return geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always prioritize Floodgate's key, if it is installed.
|
// Always prioritize Floodgate's key, if it is installed.
|
||||||
// This mostly prevents people from trying to copy the key and corrupting it in the process
|
// This mostly prevents people from trying to copy the key and corrupting it in the process
|
||||||
if (floodgateDataFolder != null) {
|
if (floodgateDataFolder != null) {
|
||||||
|
@ -158,4 +158,20 @@ public interface GeyserBootstrap {
|
|||||||
}
|
}
|
||||||
return stream;
|
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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if Floodgate is installed, loads the Floodgate key if so, and returns the result of Floodgate installed.
|
||||||
|
*/
|
||||||
|
boolean testFloodgatePluginPresent();
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.github.steveice10.packetlib.tcp.TcpSession;
|
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.epoll.Epoll;
|
||||||
import io.netty.channel.kqueue.KQueue;
|
|
||||||
import io.netty.util.NettyRuntime;
|
import io.netty.util.NettyRuntime;
|
||||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||||
import io.netty.util.internal.SystemPropertyUtil;
|
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.event.GeyserEventBus;
|
||||||
import org.geysermc.geyser.extension.GeyserExtensionManager;
|
import org.geysermc.geyser.extension.GeyserExtensionManager;
|
||||||
import org.geysermc.geyser.level.WorldManager;
|
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.pack.ResourcePack;
|
||||||
import org.geysermc.geyser.registry.BlockRegistries;
|
import org.geysermc.geyser.registry.BlockRegistries;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
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.skin.SkinProvider;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.text.MinecraftLocale;
|
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.translator.text.MessageTranslator;
|
||||||
import org.geysermc.geyser.util.*;
|
import org.geysermc.geyser.util.*;
|
||||||
|
|
||||||
@ -148,7 +143,7 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
|
|
||||||
private ScheduledExecutorService scheduledThread;
|
private ScheduledExecutorService scheduledThread;
|
||||||
|
|
||||||
private BedrockServer bedrockServer;
|
private GeyserServer geyserServer;
|
||||||
private final PlatformType platformType;
|
private final PlatformType platformType;
|
||||||
private final GeyserBootstrap bootstrap;
|
private final GeyserBootstrap bootstrap;
|
||||||
|
|
||||||
@ -199,7 +194,6 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
|
|
||||||
/* Initialize translators */
|
/* Initialize translators */
|
||||||
EntityDefinitions.init();
|
EntityDefinitions.init();
|
||||||
ItemTranslator.init();
|
|
||||||
MessageTranslator.init();
|
MessageTranslator.init();
|
||||||
|
|
||||||
// Download the latest asset list and cache it
|
// Download the latest asset list and cache it
|
||||||
@ -266,7 +260,22 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
|
|
||||||
ResourcePack.loadPacks();
|
ResourcePack.loadPacks();
|
||||||
|
|
||||||
if (platformType != PlatformType.STANDALONE && config.getRemote().address().equals("auto")) {
|
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
|
// Set the remote address to localhost since that is where we are always connecting
|
||||||
try {
|
try {
|
||||||
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
|
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
|
||||||
@ -278,6 +287,55 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean floodgatePresent = bootstrap.testFloodgatePluginPresent();
|
||||||
|
if (config.getRemote().authType() == AuthType.FLOODGATE && !floodgatePresent) {
|
||||||
|
logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||||
|
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||||
|
return;
|
||||||
|
} else if (config.isAutoconfiguredRemote() && floodgatePresent) {
|
||||||
|
// 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();
|
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.
|
// 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")) {
|
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
|
||||||
@ -308,40 +366,16 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
||||||
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
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");
|
Integer bedrockThreadCount = Integer.getInteger("Geyser.BedrockNetworkThreads");
|
||||||
if (bedrockThreadCount == null) {
|
if (bedrockThreadCount == null) {
|
||||||
// Copy the code from Netty's default thread count fallback
|
// Copy the code from Netty's default thread count fallback
|
||||||
bedrockThreadCount = Math.max(1, SystemPropertyUtil.getInt("io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2));
|
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) {
|
if (shouldStartListener) {
|
||||||
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
this.geyserServer = new GeyserServer(this, bedrockThreadCount);
|
||||||
|
this.geyserServer.bind(new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()))
|
||||||
|
.whenComplete((avoid, throwable) -> {
|
||||||
if (throwable == null) {
|
if (throwable == null) {
|
||||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
|
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
|
||||||
String.valueOf(config.getBedrock().port())));
|
String.valueOf(config.getBedrock().port())));
|
||||||
@ -575,7 +609,7 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scheduledThread.shutdown();
|
scheduledThread.shutdown();
|
||||||
bedrockServer.close();
|
geyserServer.shutdown();
|
||||||
if (skinUploader != null) {
|
if (skinUploader != null) {
|
||||||
skinUploader.close();
|
skinUploader.close();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.command.defaults;
|
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.common.PlatformType;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.command.GeyserCommand;
|
import org.geysermc.geyser.command.GeyserCommand;
|
||||||
@ -54,7 +54,7 @@ public class VersionCommand extends GeyserCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(GeyserSession session, GeyserCommandSource sender, String[] args) {
|
public void execute(GeyserSession session, GeyserCommandSource sender, String[] args) {
|
||||||
String bedrockVersions;
|
String bedrockVersions;
|
||||||
List<BedrockPacketCodec> supportedCodecs = GameProtocol.SUPPORTED_BEDROCK_CODECS;
|
List<BedrockCodec> supportedCodecs = GameProtocol.SUPPORTED_BEDROCK_CODECS;
|
||||||
if (supportedCodecs.size() > 1) {
|
if (supportedCodecs.size() > 1) {
|
||||||
bedrockVersions = supportedCodecs.get(0).getMinecraftVersion() + " - " + supportedCodecs.get(supportedCodecs.size() - 1).getMinecraftVersion();
|
bedrockVersions = supportedCodecs.get(0).getMinecraftVersion() + " - " + supportedCodecs.get(supportedCodecs.size() - 1).getMinecraftVersion();
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.configuration;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
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.BedrockListener;
|
||||||
import org.geysermc.geyser.api.network.RemoteServer;
|
import org.geysermc.geyser.api.network.RemoteServer;
|
||||||
import org.geysermc.geyser.network.CIDRMatcher;
|
import org.geysermc.geyser.network.CIDRMatcher;
|
||||||
@ -38,6 +39,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface GeyserConfiguration {
|
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
|
// Modify this when you introduce breaking changes into the config
|
||||||
int CURRENT_CONFIG_VERSION = 4;
|
int CURRENT_CONFIG_VERSION = 4;
|
||||||
@ -115,7 +120,12 @@ public interface GeyserConfiguration {
|
|||||||
|
|
||||||
int getPendingAuthenticationTimeout();
|
int getPendingAuthenticationTimeout();
|
||||||
|
|
||||||
|
boolean isAutoconfiguredRemote();
|
||||||
|
|
||||||
interface IBedrockConfiguration extends BedrockListener {
|
interface IBedrockConfiguration extends BedrockListener {
|
||||||
|
void setAddress(String address);
|
||||||
|
|
||||||
|
void setPort(int port);
|
||||||
|
|
||||||
boolean isCloneRemotePort();
|
boolean isCloneRemotePort();
|
||||||
|
|
||||||
@ -150,6 +160,8 @@ public interface GeyserConfiguration {
|
|||||||
default int protocolVersion() {
|
default int protocolVersion() {
|
||||||
return GameProtocol.getJavaProtocolVersion();
|
return GameProtocol.getJavaProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setAuthType(AuthType authType);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IUserAuthenticationInfo {
|
interface IUserAuthenticationInfo {
|
||||||
|
@ -53,9 +53,6 @@ import java.util.stream.Collectors;
|
|||||||
@SuppressWarnings("FieldMayBeFinal") // Jackson requires that the fields are not final
|
@SuppressWarnings("FieldMayBeFinal") // Jackson requires that the fields are not final
|
||||||
public abstract class GeyserJacksonConfiguration implements GeyserConfiguration {
|
public abstract class GeyserJacksonConfiguration implements GeyserConfiguration {
|
||||||
|
|
||||||
/**
|
|
||||||
* If the config was originally 'auto' before the values changed
|
|
||||||
*/
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean autoconfiguredRemote = false;
|
private boolean autoconfiguredRemote = false;
|
||||||
|
|
||||||
@ -163,6 +160,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||||||
public static class BedrockConfiguration implements IBedrockConfiguration {
|
public static class BedrockConfiguration implements IBedrockConfiguration {
|
||||||
@AsteriskSerializer.Asterisk(isIp = true)
|
@AsteriskSerializer.Asterisk(isIp = true)
|
||||||
@JsonProperty("address")
|
@JsonProperty("address")
|
||||||
|
@Setter
|
||||||
private String address = "0.0.0.0";
|
private String address = "0.0.0.0";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,11 +31,11 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
import com.google.common.io.Files;
|
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.Object2IntMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||||
import org.geysermc.floodgate.util.DeviceOs;
|
import org.geysermc.floodgate.util.DeviceOs;
|
||||||
import org.geysermc.floodgate.util.FloodgateInfoHolder;
|
import org.geysermc.floodgate.util.FloodgateInfoHolder;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
@ -57,7 +57,12 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.file.Paths;
|
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;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -219,8 +224,8 @@ public class DumpInfo {
|
|||||||
private final int javaProtocol;
|
private final int javaProtocol;
|
||||||
|
|
||||||
MCInfo() {
|
MCInfo() {
|
||||||
this.bedrockVersions = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getMinecraftVersion).toList();
|
this.bedrockVersions = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockCodec::getMinecraftVersion).toList();
|
||||||
this.bedrockProtocols = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getProtocolVersion).toList();
|
this.bedrockProtocols = GameProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockCodec::getProtocolVersion).toList();
|
||||||
this.defaultBedrockProtocol = GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion();
|
this.defaultBedrockProtocol = GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion();
|
||||||
this.javaVersions = GameProtocol.getJavaVersions();
|
this.javaVersions = GameProtocol.getJavaVersions();
|
||||||
this.javaProtocol = GameProtocol.getJavaProtocolVersion();
|
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.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
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.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.type.*;
|
import org.geysermc.geyser.entity.type.*;
|
||||||
import org.geysermc.geyser.entity.type.living.*;
|
import org.geysermc.geyser.entity.type.living.*;
|
||||||
import org.geysermc.geyser.entity.type.living.animal.*;
|
import org.geysermc.geyser.entity.type.living.animal.*;
|
||||||
@ -198,7 +198,7 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.AREA_EFFECT_CLOUD)
|
.type(EntityType.AREA_EFFECT_CLOUD)
|
||||||
.height(0.5f).width(1.0f)
|
.height(0.5f).width(1.0f)
|
||||||
.addTranslator(MetadataType.FLOAT, AreaEffectCloudEntity::setRadius)
|
.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(null) // Waiting
|
||||||
.addTranslator(MetadataType.PARTICLE, AreaEffectCloudEntity::setParticle)
|
.addTranslator(MetadataType.PARTICLE, AreaEffectCloudEntity::setParticle)
|
||||||
.build();
|
.build();
|
||||||
@ -206,15 +206,15 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.BOAT)
|
.type(EntityType.BOAT)
|
||||||
.height(0.6f).width(1.6f)
|
.height(0.6f).width(1.6f)
|
||||||
.offset(0.35f)
|
.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(EntityDataTypes.HURT_TICKS, 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_DIRECTION, entityMetadata.getValue())) // Rocking direction
|
||||||
.addTranslator(MetadataType.FLOAT, (boatEntity, entityMetadata) ->
|
.addTranslator(MetadataType.FLOAT, (boatEntity, entityMetadata) ->
|
||||||
// 'Health' in Bedrock, damage taken in Java - it makes motion in Bedrock
|
// '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.INT, BoatEntity::setVariant)
|
||||||
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingLeft)
|
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingLeft)
|
||||||
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight)
|
.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();
|
.build();
|
||||||
CHEST_BOAT = EntityDefinition.inherited(ChestBoatEntity::new, BOAT)
|
CHEST_BOAT = EntityDefinition.inherited(ChestBoatEntity::new, BOAT)
|
||||||
.type(EntityType.CHEST_BOAT)
|
.type(EntityType.CHEST_BOAT)
|
||||||
@ -391,11 +391,11 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.MINECART)
|
.type(EntityType.MINECART)
|
||||||
.height(0.7f).width(0.98f)
|
.height(0.7f).width(0.98f)
|
||||||
.offset(0.35f)
|
.offset(0.35f)
|
||||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityData.HEALTH, entityMetadata.getValue()))
|
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityDataTypes.STRUCTURAL_INTEGRITY, 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.HURT_DIRECTION, entityMetadata.getValue())) // Direction in which the minecart is shaking
|
||||||
.addTranslator(MetadataType.FLOAT, (minecartEntity, entityMetadata) ->
|
.addTranslator(MetadataType.FLOAT, (minecartEntity, entityMetadata) ->
|
||||||
// Power in Java, time in Bedrock
|
// Power in Java, hurt ticks in Bedrock
|
||||||
minecartEntity.getDirtyMetadata().put(EntityData.HURT_TIME, Math.min((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue(), 15)))
|
minecartEntity.getDirtyMetadata().put(EntityDataTypes.HURT_TICKS, Math.min((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue(), 15)))
|
||||||
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlock)
|
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlock)
|
||||||
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlockOffset)
|
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlockOffset)
|
||||||
.addTranslator(MetadataType.BOOLEAN, MinecartEntity::setShowCustomBlock)
|
.addTranslator(MetadataType.BOOLEAN, MinecartEntity::setShowCustomBlock)
|
||||||
@ -405,8 +405,8 @@ public final class EntityDefinitions {
|
|||||||
.build();
|
.build();
|
||||||
COMMAND_BLOCK_MINECART = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART)
|
COMMAND_BLOCK_MINECART = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART)
|
||||||
.type(EntityType.COMMAND_BLOCK_MINECART)
|
.type(EntityType.COMMAND_BLOCK_MINECART)
|
||||||
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_COMMAND, entityMetadata.getValue()))
|
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.COMMAND_BLOCK_NAME, entityMetadata.getValue()))
|
||||||
.addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
|
.addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
|
||||||
.build();
|
.build();
|
||||||
FURNACE_MINECART = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
|
FURNACE_MINECART = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
|
||||||
.type(EntityType.FURNACE_MINECART)
|
.type(EntityType.FURNACE_MINECART)
|
||||||
@ -437,9 +437,9 @@ public final class EntityDefinitions {
|
|||||||
.addTranslator(MetadataType.BYTE, LivingEntity::setLivingEntityFlags)
|
.addTranslator(MetadataType.BYTE, LivingEntity::setLivingEntityFlags)
|
||||||
.addTranslator(MetadataType.FLOAT, LivingEntity::setHealth)
|
.addTranslator(MetadataType.FLOAT, LivingEntity::setHealth)
|
||||||
.addTranslator(MetadataType.INT,
|
.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,
|
.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) // Arrow count
|
||||||
.addTranslator(null) // Stinger count
|
.addTranslator(null) // Stinger count
|
||||||
.addTranslator(MetadataType.OPTIONAL_POSITION, LivingEntity::setBedPosition)
|
.addTranslator(MetadataType.OPTIONAL_POSITION, LivingEntity::setBedPosition)
|
||||||
@ -916,9 +916,9 @@ public final class EntityDefinitions {
|
|||||||
LLAMA = EntityDefinition.inherited(LlamaEntity::new, chestedHorseEntityBase)
|
LLAMA = EntityDefinition.inherited(LlamaEntity::new, chestedHorseEntityBase)
|
||||||
.type(EntityType.LLAMA)
|
.type(EntityType.LLAMA)
|
||||||
.height(1.87f).width(0.9f)
|
.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, 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();
|
.build();
|
||||||
TRADER_LLAMA = EntityDefinition.inherited(TraderLlamaEntity::new, LLAMA)
|
TRADER_LLAMA = EntityDefinition.inherited(TraderLlamaEntity::new, LLAMA)
|
||||||
.type(EntityType.TRADER_LLAMA)
|
.type(EntityType.TRADER_LLAMA)
|
||||||
@ -941,7 +941,7 @@ public final class EntityDefinitions {
|
|||||||
PARROT = EntityDefinition.inherited(ParrotEntity::new, tameableEntityBase)
|
PARROT = EntityDefinition.inherited(ParrotEntity::new, tameableEntityBase)
|
||||||
.type(EntityType.PARROT)
|
.type(EntityType.PARROT)
|
||||||
.height(0.9f).width(0.5f)
|
.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();
|
.build();
|
||||||
WOLF = EntityDefinition.inherited(WolfEntity::new, tameableEntityBase)
|
WOLF = EntityDefinition.inherited(WolfEntity::new, tameableEntityBase)
|
||||||
.type(EntityType.WOLF)
|
.type(EntityType.WOLF)
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity;
|
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 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;
|
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.
|
* A write-only wrapper for temporarily storing entity metadata that will be sent to Bedrock.
|
||||||
*/
|
*/
|
||||||
public final class GeyserDirtyMetadata {
|
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);
|
metadata.put(entityData, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.attribute;
|
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.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.factory;
|
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.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.metadata.type.ByteEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.EntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
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.github.steveice10.mc.protocol.data.game.level.particle.Particle;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.ParticleType;
|
||||||
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.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
import org.geysermc.geyser.registry.Registries;
|
||||||
|
import org.geysermc.geyser.registry.type.ParticleMapping;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -47,12 +49,12 @@ public class AreaEffectCloudEntity extends Entity {
|
|||||||
protected void initializeMetadata() {
|
protected void initializeMetadata() {
|
||||||
super.initializeMetadata();
|
super.initializeMetadata();
|
||||||
// Without this the cloud doesn't appear,
|
// 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
|
// This disabled client side shrink of the cloud
|
||||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS, 0.0f);
|
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_RADIUS, 0.0f);
|
||||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_CHANGE_RATE, Float.MIN_VALUE);
|
dirtyMetadata.put(EntityDataTypes.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_CHANGE_ON_PICKUP, Float.MIN_VALUE);
|
||||||
|
|
||||||
setFlag(EntityFlag.FIRE_IMMUNE, true);
|
setFlag(EntityFlag.FIRE_IMMUNE, true);
|
||||||
}
|
}
|
||||||
@ -60,15 +62,13 @@ public class AreaEffectCloudEntity extends Entity {
|
|||||||
public void setRadius(FloatEntityMetadata entityMetadata) {
|
public void setRadius(FloatEntityMetadata entityMetadata) {
|
||||||
// Anything less than 0.5 will cause the cloud to despawn
|
// Anything less than 0.5 will cause the cloud to despawn
|
||||||
float value = Math.max(entityMetadata.getPrimitiveValue(), 0.5f);
|
float value = Math.max(entityMetadata.getPrimitiveValue(), 0.5f);
|
||||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS, value);
|
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_RADIUS, value);
|
||||||
dirtyMetadata.put(EntityData.BOUNDING_BOX_WIDTH, 2.0f * value);
|
dirtyMetadata.put(EntityDataTypes.WIDTH, 2.0f * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParticle(EntityMetadata<Particle, ?> entityMetadata) {
|
public void setParticle(EntityMetadata<Particle, ?> entityMetadata) {
|
||||||
Particle particle = entityMetadata.getValue();
|
Particle particle = entityMetadata.getValue();
|
||||||
int particleId = Registries.PARTICLES.map(particle.getType(), mapping -> mapping.getParticleId(this.session)).orElse(-1);
|
Registries.PARTICLES.map(particle.getType(), p -> p.levelEventType() instanceof ParticleType particleType ? particleType : null).ifPresent(type ->
|
||||||
if (particleId != -1) {
|
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_PARTICLE, type));
|
||||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_PARTICLE_ID, particleId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
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.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AnimatePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
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);
|
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+
|
// 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(EntityDataTypes.IS_BUOYANT, true);
|
||||||
dirtyMetadata.put(EntityData.BUOYANCY_DATA, BUOYANCY_DATA);
|
dirtyMetadata.put(EntityDataTypes.BUOYANCY_DATA, BUOYANCY_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,7 +124,7 @@ public class BoatEntity extends Entity {
|
|||||||
|
|
||||||
public void setVariant(IntEntityMetadata entityMetadata) {
|
public void setVariant(IntEntityMetadata entityMetadata) {
|
||||||
variant = entityMetadata.getPrimitiveValue();
|
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 6, 7 -> variant - 1; // Dark oak and mangrove
|
||||||
case 5, 8 -> 0; // TODO temp until 1.20. Cherry and bamboo
|
case 5, 8 -> 0; // TODO temp until 1.20. Cherry and bamboo
|
||||||
default -> variant;
|
default -> variant;
|
||||||
@ -146,7 +146,7 @@ public class BoatEntity extends Entity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Indicate that the row position should be reset
|
// 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 {
|
} 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;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
|
@ -26,11 +26,11 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType;
|
||||||
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.ContainerOpenPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
@ -48,10 +48,10 @@ public class CommandBlockMinecartEntity extends DefaultBlockMinecartEntity {
|
|||||||
protected void initializeMetadata() {
|
protected void initializeMetadata() {
|
||||||
super.initializeMetadata();
|
super.initializeMetadata();
|
||||||
// Required, or else the GUI will not open
|
// Required, or else the GUI will not open
|
||||||
dirtyMetadata.put(EntityData.CONTAINER_TYPE, (byte) 16);
|
dirtyMetadata.put(EntityDataTypes.CONTAINER_TYPE, (byte) 16);
|
||||||
dirtyMetadata.put(EntityData.CONTAINER_BASE_SIZE, 1);
|
dirtyMetadata.put(EntityDataTypes.CONTAINER_SIZE, 1);
|
||||||
// Required, or else the client does not bother to send a packet back with the new information
|
// 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
|
@Override
|
||||||
public void updateDefaultBlockMetadata() {
|
public void updateDefaultBlockMetadata() {
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getCommandBlockRuntimeId());
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getCommandBlock());
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, 6);
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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) {
|
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);
|
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
|
@Override
|
||||||
@ -60,7 +60,7 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||||||
customBlock = entityMetadata.getPrimitiveValue();
|
customBlock = entityMetadata.getPrimitiveValue();
|
||||||
|
|
||||||
if (showCustomBlock) {
|
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();
|
customBlockOffset = entityMetadata.getPrimitiveValue();
|
||||||
|
|
||||||
if (showCustomBlock) {
|
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) {
|
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
||||||
if (entityMetadata.getPrimitiveValue()) {
|
if (entityMetadata.getPrimitiveValue()) {
|
||||||
showCustomBlock = true;
|
showCustomBlock = true;
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(customBlock));
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(customBlock));
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, customBlockOffset);
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, customBlockOffset);
|
||||||
} else {
|
} else {
|
||||||
showCustomBlock = false;
|
showCustomBlock = false;
|
||||||
updateDefaultBlockMetadata();
|
updateDefaultBlockMetadata();
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
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.EntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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
|
// Usually performed client-side on Bedrock except for Ender Dragon respawn event
|
||||||
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
||||||
if (optionalPos.isPresent()) {
|
if (optionalPos.isPresent()) {
|
||||||
dirtyMetadata.put(EntityData.BLOCK_TARGET, optionalPos.get());
|
dirtyMetadata.put(EntityDataTypes.BLOCK_TARGET_POS, optionalPos.get());
|
||||||
} else {
|
} 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.metadata.type.IntEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
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.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.kyori.adventure.text.Component;
|
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.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -52,13 +57,14 @@ import org.geysermc.geyser.util.InteractiveTag;
|
|||||||
import org.geysermc.geyser.util.MathUtils;
|
import org.geysermc.geyser.util.MathUtils;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class Entity {
|
public class Entity implements GeyserEntity {
|
||||||
protected final GeyserSession session;
|
protected final GeyserSession session;
|
||||||
|
|
||||||
protected int entityId;
|
protected int entityId;
|
||||||
@ -110,7 +116,7 @@ public class Entity {
|
|||||||
* think they are set to false.
|
* think they are set to false.
|
||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.NONE)
|
@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.
|
* 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.
|
* Called on entity spawn. Used to populate the entity metadata and flags with default values.
|
||||||
*/
|
*/
|
||||||
protected void initializeMetadata() {
|
protected void initializeMetadata() {
|
||||||
dirtyMetadata.put(EntityData.SCALE, 1f);
|
dirtyMetadata.put(EntityDataTypes.SCALE, 1f);
|
||||||
dirtyMetadata.put(EntityData.COLOR, (byte) 0);
|
dirtyMetadata.put(EntityDataTypes.COLOR, (byte) 0);
|
||||||
dirtyMetadata.put(EntityData.MAX_AIR_SUPPLY, getMaxAir());
|
dirtyMetadata.put(EntityDataTypes.AIR_SUPPLY_MAX, getMaxAir());
|
||||||
setDimensions(Pose.STANDING);
|
setDimensions(Pose.STANDING);
|
||||||
setFlag(EntityFlag.HAS_GRAVITY, true);
|
setFlag(EntityFlag.HAS_GRAVITY, true);
|
||||||
setFlag(EntityFlag.HAS_COLLISION, true);
|
setFlag(EntityFlag.HAS_COLLISION, true);
|
||||||
@ -165,7 +171,7 @@ public class Entity {
|
|||||||
addEntityPacket.setUniqueEntityId(geyserId);
|
addEntityPacket.setUniqueEntityId(geyserId);
|
||||||
addEntityPacket.setPosition(position);
|
addEntityPacket.setPosition(position);
|
||||||
addEntityPacket.setMotion(motion);
|
addEntityPacket.setMotion(motion);
|
||||||
addEntityPacket.setRotation(getBedrockRotation());
|
addEntityPacket.setRotation(getBedrockRotation().toVector2(false)); // TODO: Check this
|
||||||
addEntityPacket.getMetadata().putFlags(flags);
|
addEntityPacket.getMetadata().putFlags(flags);
|
||||||
dirtyMetadata.apply(addEntityPacket.getMetadata());
|
dirtyMetadata.apply(addEntityPacket.getMetadata());
|
||||||
addAdditionalSpawnData(addEntityPacket);
|
addAdditionalSpawnData(addEntityPacket);
|
||||||
@ -320,14 +326,14 @@ public class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean getFlag(EntityFlag flag) {
|
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.
|
* Updates a flag value and determines if the flags would need synced with the Bedrock client.
|
||||||
*/
|
*/
|
||||||
public final void setFlag(EntityFlag flag, boolean value) {
|
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) {
|
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() {
|
protected short getMaxAir() {
|
||||||
@ -390,15 +396,15 @@ public class Entity {
|
|||||||
Optional<Component> name = entityMetadata.getValue();
|
Optional<Component> name = entityMetadata.getValue();
|
||||||
if (name.isPresent()) {
|
if (name.isPresent()) {
|
||||||
nametag = MessageTranslator.convertMessage(name.get(), session.locale());
|
nametag = MessageTranslator.convertMessage(name.get(), session.locale());
|
||||||
dirtyMetadata.put(EntityData.NAMETAG, nametag);
|
dirtyMetadata.put(EntityDataTypes.NAME, nametag);
|
||||||
} else if (!nametag.isEmpty()) {
|
} else if (!nametag.isEmpty()) {
|
||||||
// Clear nametag
|
// Clear nametag
|
||||||
dirtyMetadata.put(EntityData.NAMETAG, "");
|
dirtyMetadata.put(EntityDataTypes.NAME, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplayNameVisible(BooleanEntityMetadata entityMetadata) {
|
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) {
|
public final void setSilent(BooleanEntityMetadata entityMetadata) {
|
||||||
@ -431,7 +437,7 @@ public class Entity {
|
|||||||
public boolean setBoundingBoxHeight(float height) {
|
public boolean setBoundingBoxHeight(float height) {
|
||||||
if (height != boundingBoxHeight) {
|
if (height != boundingBoxHeight) {
|
||||||
boundingBoxHeight = height;
|
boundingBoxHeight = height;
|
||||||
dirtyMetadata.put(EntityData.BOUNDING_BOX_HEIGHT, boundingBoxHeight);
|
dirtyMetadata.put(EntityDataTypes.HEIGHT, boundingBoxHeight);
|
||||||
|
|
||||||
updatePassengerOffsets();
|
updatePassengerOffsets();
|
||||||
return true;
|
return true;
|
||||||
@ -442,7 +448,7 @@ public class Entity {
|
|||||||
public void setBoundingBoxWidth(float width) {
|
public void setBoundingBoxWidth(float width) {
|
||||||
if (width != boundingBoxWidth) {
|
if (width != boundingBoxWidth) {
|
||||||
boundingBoxWidth = width;
|
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
|
// The Java client caps its freezing tick percentage at 140
|
||||||
int freezingTicks = Math.min(entityMetadata.getPrimitiveValue(), 140);
|
int freezingTicks = Math.min(entityMetadata.getPrimitiveValue(), 140);
|
||||||
float freezingPercentage = freezingTicks / 140f;
|
float freezingPercentage = freezingTicks / 140f;
|
||||||
dirtyMetadata.put(EntityData.FREEZING_EFFECT_STRENGTH, freezingPercentage);
|
dirtyMetadata.put(EntityDataTypes.FREEZING_EFFECT_STRENGTH, freezingPercentage);
|
||||||
return freezingPercentage;
|
return freezingPercentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRiderSeatPosition(Vector3f position) {
|
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() {
|
public boolean isAlive() {
|
||||||
return this.valid;
|
return this.valid;
|
||||||
}
|
}
|
||||||
@ -519,7 +530,7 @@ public class Entity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.getPlayerEntity().getDirtyMetadata().put(EntityData.INTERACTIVE_TAG, tag.getValue());
|
session.getPlayerEntity().getDirtyMetadata().put(EntityDataTypes.INTERACT_TEXT, tag.getValue());
|
||||||
session.getPlayerEntity().updateBedrockMetadata();
|
session.getPlayerEntity().updateBedrockMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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);
|
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
|
// As of 1.18.2 Bedrock, this line is required for the entity to be visible
|
||||||
// 22 is the starting number on Java Edition
|
// 22 is the starting number on Java Edition
|
||||||
dirtyMetadata.put(EntityData.LIMITED_LIFE, this.limitedLife);
|
dirtyMetadata.put(EntityDataTypes.DATA_LIFETIME_TICKS, this.limitedLife);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (attackStarted) {
|
if (attackStarted) {
|
||||||
if (--this.limitedLife > 0 && this.limitedLife % 2 == 0) { // Matches Bedrock behavior
|
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();
|
updateBedrockMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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) {
|
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);
|
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;
|
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.BooleanEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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) {
|
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);
|
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
|
@Override
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import com.nukkitx.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
import com.nukkitx.nbt.NbtType;
|
import org.cloudburstmc.nbt.NbtType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.packet.SetEntityMotionPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SetEntityMotionPacket;
|
||||||
import org.geysermc.floodgate.util.DeviceOs;
|
import org.geysermc.floodgate.util.DeviceOs;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||||
@ -133,7 +133,7 @@ public class FireworkEntity extends Entity {
|
|||||||
|
|
||||||
NbtMapBuilder builder = NbtMap.builder();
|
NbtMapBuilder builder = NbtMap.builder();
|
||||||
builder.put("Fireworks", fireworksBuilder.build());
|
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) {
|
public void setPlayerGliding(EntityMetadata<OptionalInt, ?> entityMetadata) {
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.erosion.util.BlockPositionIterator;
|
import org.geysermc.erosion.util.BlockPositionIterator;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
@ -65,7 +65,7 @@ public class FishingHookEntity extends ThrowableEntity {
|
|||||||
setBoundingBoxHeight(128);
|
setBoundingBoxHeight(128);
|
||||||
|
|
||||||
this.bedrockOwnerId = owner.getGeyserId();
|
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) {
|
public void setHookedEntity(IntEntityMetadata entityMetadata) {
|
||||||
@ -73,7 +73,7 @@ public class FishingHookEntity extends ThrowableEntity {
|
|||||||
Entity entity = session.getEntityCache().getEntityByJavaId(hookedEntityId);
|
Entity entity = session.getEntityCache().getEntityByJavaId(hookedEntityId);
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
bedrockTargetId = entity.getGeyserId();
|
bedrockTargetId = entity.getGeyserId();
|
||||||
dirtyMetadata.put(EntityData.TARGET_EID, bedrockTargetId);
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, bedrockTargetId);
|
||||||
hooked = true;
|
hooked = true;
|
||||||
} else {
|
} else {
|
||||||
hooked = false;
|
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.metadata.type.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -51,8 +51,8 @@ public class FurnaceMinecartEntity extends DefaultBlockMinecartEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDefaultBlockMetadata() {
|
public void updateDefaultBlockMetadata() {
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(hasFuel ? BlockStateValues.JAVA_FURNACE_LIT_ID : BlockStateValues.JAVA_FURNACE_ID));
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(hasFuel ? BlockStateValues.JAVA_FURNACE_LIT_ID : BlockStateValues.JAVA_FURNACE_ID));
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, 6);
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.EntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AddItemEntityPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AddItemEntityPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.object.Direction;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import com.nukkitx.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import com.nukkitx.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
import org.cloudburstmc.protocol.bedrock.data.defintions.BlockDefinition;
|
||||||
import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.BlockEntityDataPacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -59,7 +60,7 @@ public class ItemFrameEntity extends Entity {
|
|||||||
/**
|
/**
|
||||||
* Specific block 'state' we are emulating in Bedrock.
|
* Specific block 'state' we are emulating in Bedrock.
|
||||||
*/
|
*/
|
||||||
private final int bedrockRuntimeId;
|
private final BlockDefinition blockDefinition;
|
||||||
/**
|
/**
|
||||||
* Rotation of item in frame.
|
* Rotation of item in frame.
|
||||||
*/
|
*/
|
||||||
@ -90,7 +91,7 @@ public class ItemFrameEntity extends Entity {
|
|||||||
.putByte("item_frame_photo_bit", (byte) 0);
|
.putByte("item_frame_photo_bit", (byte) 0);
|
||||||
blockBuilder.put("states", statesBuilder.build());
|
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());
|
bedrockPosition = Vector3i.from(position.getFloorX(), position.getFloorY(), position.getFloorZ());
|
||||||
|
|
||||||
session.getItemFrameCache().put(bedrockPosition, this);
|
session.getItemFrameCache().put(bedrockPosition, this);
|
||||||
@ -114,7 +115,7 @@ public class ItemFrameEntity extends Entity {
|
|||||||
this.heldItem = entityMetadata.getValue();
|
this.heldItem = entityMetadata.getValue();
|
||||||
ItemData itemData = ItemTranslator.translateToBedrock(session, heldItem);
|
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();
|
NbtMapBuilder builder = NbtMap.builder();
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ public class ItemFrameEntity extends Entity {
|
|||||||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||||
updateBlockPacket.setDataLayer(0);
|
updateBlockPacket.setDataLayer(0);
|
||||||
updateBlockPacket.setBlockPosition(bedrockPosition);
|
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.PRIORITY);
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
|
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||||
@ -190,7 +191,7 @@ public class ItemFrameEntity extends Entity {
|
|||||||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||||
updateBlockPacket.setDataLayer(0);
|
updateBlockPacket.setDataLayer(0);
|
||||||
updateBlockPacket.setBlockPosition(bedrockPosition);
|
updateBlockPacket.setBlockPosition(bedrockPosition);
|
||||||
updateBlockPacket.setRuntimeId(bedrockRuntimeId);
|
updateBlockPacket.setDefinition(blockDefinition);
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
|
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NETWORK);
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
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.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
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.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
|
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.AttributeUtils;
|
import org.geysermc.geyser.util.AttributeUtils;
|
||||||
import org.geysermc.geyser.util.ChunkUtils;
|
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -88,7 +89,7 @@ public class LivingEntity extends Entity {
|
|||||||
protected void initializeMetadata() {
|
protected void initializeMetadata() {
|
||||||
super.initializeMetadata();
|
super.initializeMetadata();
|
||||||
// Matches Bedrock behavior; is always set to this
|
// Matches Bedrock behavior; is always set to this
|
||||||
dirtyMetadata.put(EntityData.HEALTH, 1);
|
dirtyMetadata.put(EntityDataTypes.STRUCTURAL_INTEGRITY, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLivingEntityFlags(ByteEntityMetadata entityMetadata) {
|
public void setLivingEntityFlags(ByteEntityMetadata entityMetadata) {
|
||||||
@ -97,8 +98,7 @@ public class LivingEntity extends Entity {
|
|||||||
boolean isUsingItem = (xd & 0x01) == 0x01;
|
boolean isUsingItem = (xd & 0x01) == 0x01;
|
||||||
boolean isUsingOffhand = (xd & 0x02) == 0x02;
|
boolean isUsingOffhand = (xd & 0x02) == 0x02;
|
||||||
|
|
||||||
ItemMapping shield = session.getItemMappings().getStoredItems().shield();
|
boolean isUsingShield = hasShield(isUsingOffhand);
|
||||||
boolean isUsingShield = hasShield(isUsingOffhand, shield);
|
|
||||||
|
|
||||||
setFlag(EntityFlag.USING_ITEM, isUsingItem && !isUsingShield);
|
setFlag(EntityFlag.USING_ITEM, isUsingItem && !isUsingShield);
|
||||||
// Override the blocking
|
// Override the blocking
|
||||||
@ -125,27 +125,19 @@ public class LivingEntity extends Entity {
|
|||||||
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
||||||
if (optionalPos.isPresent()) {
|
if (optionalPos.isPresent()) {
|
||||||
Vector3i bedPosition = optionalPos.get();
|
Vector3i bedPosition = optionalPos.get();
|
||||||
dirtyMetadata.put(EntityData.BED_POSITION, bedPosition);
|
dirtyMetadata.put(EntityDataTypes.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);
|
|
||||||
return bedPosition;
|
return bedPosition;
|
||||||
} else {
|
} else {
|
||||||
// Player is no longer sleeping
|
|
||||||
dirtyMetadata.put(EntityData.PLAYER_FLAGS, (byte) 0);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasShield(boolean offhand, ItemMapping shieldMapping) {
|
protected boolean hasShield(boolean offhand) {
|
||||||
|
ItemMapping shieldMapping = session.getItemMappings().getStoredItems().shield();
|
||||||
if (offhand) {
|
if (offhand) {
|
||||||
return offHand.getId() == shieldMapping.getBedrockId();
|
return offHand.getDefinition().equals(shieldMapping.getBedrockDefinition());
|
||||||
} else {
|
} else {
|
||||||
return hand.getId() == shieldMapping.getBedrockId();
|
return hand.getDefinition().equals(shieldMapping.getBedrockDefinition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +181,7 @@ public class LivingEntity extends Entity {
|
|||||||
@Override
|
@Override
|
||||||
public InteractionResult interact(Hand hand) {
|
public InteractionResult interact(Hand hand) {
|
||||||
GeyserItemStack itemStack = session.getPlayerInventory().getItemInHand(hand);
|
GeyserItemStack itemStack = session.getPlayerInventory().getItemInHand(hand);
|
||||||
if (itemStack.getJavaId() == session.getItemMappings().getStoredItems().nameTag()) {
|
if (itemStack.asItem() == Items.NAME_TAG) {
|
||||||
InteractionResult result = checkInteractWithNameTag(itemStack);
|
InteractionResult result = checkInteractWithNameTag(itemStack);
|
||||||
if (result.consumesAction()) {
|
if (result.consumesAction()) {
|
||||||
return result;
|
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
|
// 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
|
// But don't overwrite the chestplate if it isn't empty
|
||||||
ItemMapping banner = session.getItemMappings().getStoredItems().banner();
|
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;
|
chestplate = this.helmet;
|
||||||
helmet = ItemData.AIR;
|
helmet = ItemData.AIR;
|
||||||
} else if (chestplate.getId() == banner.getBedrockId()) {
|
} else if (chestplate.getDefinition().equals(banner)) {
|
||||||
// Prevent chestplate banners from showing erroneously
|
// Prevent chestplate banners from showing erroneously
|
||||||
chestplate = ItemData.AIR;
|
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.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
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.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -45,17 +45,17 @@ public class MinecartEntity extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomBlock(IntEntityMetadata entityMetadata) {
|
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) {
|
public void setCustomBlockOffset(IntEntityMetadata entityMetadata) {
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getPrimitiveValue());
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, entityMetadata.getPrimitiveValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
||||||
// If the custom block should be enabled
|
// If the custom block should be enabled
|
||||||
// Needs a byte based off of Java's boolean
|
// 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
|
@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.metadata.type.ObjectEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AddPaintingPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AddPaintingPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.level.PaintingType;
|
import org.geysermc.geyser.level.PaintingType;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -41,7 +41,7 @@ public class SpawnerMinecartEntity extends DefaultBlockMinecartEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDefaultBlockMetadata() {
|
public void updateDefaultBlockMetadata() {
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(BlockStateValues.JAVA_SPAWNER_ID));
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_BLOCK_STATE, session.getBlockMappings().getBedrockBlock(BlockStateValues.JAVA_SPAWNER_ID));
|
||||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, 6);
|
dirtyMetadata.put(EntityDataTypes.DISPLAY_OFFSET, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
@ -43,9 +43,9 @@ public class TNTEntity extends Entity implements Tickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFuseLength(IntEntityMetadata entityMetadata) {
|
public void setFuseLength(IntEntityMetadata entityMetadata) {
|
||||||
currentTick = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
currentTick = entityMetadata.getPrimitiveValue();
|
||||||
setFlag(EntityFlag.IGNITED, true);
|
setFlag(EntityFlag.IGNITED, true);
|
||||||
dirtyMetadata.put(EntityData.FUSE_LENGTH, currentTick);
|
dirtyMetadata.put(EntityDataTypes.FUSE_TIME, currentTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,11 +56,11 @@ public class TNTEntity extends Entity implements Tickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentTick % 5 == 0) {
|
if (currentTick % 5 == 0) {
|
||||||
dirtyMetadata.put(EntityData.FUSE_LENGTH, currentTick);
|
dirtyMetadata.put(EntityDataTypes.FUSE_TIME, currentTick);
|
||||||
|
|
||||||
SetEntityDataPacket packet = new SetEntityDataPacket();
|
SetEntityDataPacket packet = new SetEntityDataPacket();
|
||||||
packet.setRuntimeEntityId(geyserId);
|
packet.setRuntimeEntityId(geyserId);
|
||||||
packet.getMetadata().put(EntityData.FUSE_LENGTH, currentTick);
|
packet.getMetadata().put(EntityDataTypes.FUSE_TIME, currentTick);
|
||||||
session.sendUpstreamPacket(packet);
|
session.sendUpstreamPacket(packet);
|
||||||
}
|
}
|
||||||
currentTick--;
|
currentTick--;
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
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.EntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
|
||||||
import net.kyori.adventure.text.Component;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
@ -45,11 +45,11 @@ public class TextDisplayEntity extends Entity {
|
|||||||
protected void initializeMetadata() {
|
protected void initializeMetadata() {
|
||||||
super.initializeMetadata();
|
super.initializeMetadata();
|
||||||
// Remove armor stand body
|
// Remove armor stand body
|
||||||
this.dirtyMetadata.put(EntityData.SCALE, 0f);
|
this.dirtyMetadata.put(EntityDataTypes.SCALE, 0f);
|
||||||
this.dirtyMetadata.put(EntityData.NAMETAG_ALWAYS_SHOW, (byte) 1);
|
this.dirtyMetadata.put(EntityDataTypes.NAMETAG_ALWAYS_SHOW, (byte) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(EntityMetadata<Component, ?> entityMetadata) {
|
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;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -174,7 +174,7 @@ public class ThrowableEntity extends Entity implements Tickable {
|
|||||||
public boolean despawnEntity() {
|
public boolean despawnEntity() {
|
||||||
if (definition.entityType() == EntityType.ENDER_PEARL) {
|
if (definition.entityType() == EntityType.ENDER_PEARL) {
|
||||||
LevelEventPacket particlePacket = new LevelEventPacket();
|
LevelEventPacket particlePacket = new LevelEventPacket();
|
||||||
particlePacket.setType(LevelEventType.PARTICLE_TELEPORT);
|
particlePacket.setType(LevelEvent.PARTICLE_TELEPORT);
|
||||||
particlePacket.setPosition(position);
|
particlePacket.setPosition(position);
|
||||||
session.sendUpstreamPacket(particlePacket);
|
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.EntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.item.Potion;
|
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 org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@ -52,25 +53,25 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
|
|||||||
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
|
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||||
ItemStack itemStack = entityMetadata.getValue();
|
ItemStack itemStack = entityMetadata.getValue();
|
||||||
if (itemStack == null) {
|
if (itemStack == null) {
|
||||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
|
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
|
||||||
setFlag(EntityFlag.ENCHANTED, false);
|
setFlag(EntityFlag.ENCHANTED, false);
|
||||||
setFlag(EntityFlag.LINGERING, false);
|
setFlag(EntityFlag.LINGERING, false);
|
||||||
} else {
|
} else {
|
||||||
ItemMapping mapping = session.getItemMappings().getMapping(itemStack);
|
// As of Java 1.19.3, the server/client doesn't seem to care of the item is actually a potion?
|
||||||
if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) {
|
if (itemStack.getNbt() != null) {
|
||||||
Tag potionTag = itemStack.getNbt().get("Potion");
|
Tag potionTag = itemStack.getNbt().get("Potion");
|
||||||
if (potionTag instanceof StringTag) {
|
if (potionTag instanceof StringTag) {
|
||||||
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
||||||
if (potion != null) {
|
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));
|
setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion));
|
||||||
} else {
|
} else {
|
||||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
|
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
|
||||||
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionTag.getValue());
|
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);
|
setFlag(EntityFlag.LINGERING, isLingering);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.item.TippedArrowPotion;
|
import org.geysermc.geyser.inventory.item.TippedArrowPotion;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -47,13 +47,13 @@ public class TippedArrowEntity extends AbstractArrowEntity {
|
|||||||
int potionColor = entityMetadata.getPrimitiveValue();
|
int potionColor = entityMetadata.getPrimitiveValue();
|
||||||
// -1 means no color
|
// -1 means no color
|
||||||
if (potionColor == -1) {
|
if (potionColor == -1) {
|
||||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, 0);
|
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) 0);
|
||||||
} else {
|
} else {
|
||||||
TippedArrowPotion potion = TippedArrowPotion.getByJavaColor(potionColor);
|
TippedArrowPotion potion = TippedArrowPotion.getByJavaColor(potionColor);
|
||||||
if (potion != null && potion.getJavaColor() != -1) {
|
if (potion != null && potion.getJavaColor() != -1) {
|
||||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, (byte) potion.getBedrockId());
|
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) potion.getBedrockId());
|
||||||
} else {
|
} else {
|
||||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, 0);
|
dirtyMetadata.put(EntityDataTypes.CUSTOM_DISPLAY, (byte) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type;
|
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.BooleanEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -51,7 +51,7 @@ public class AbstractFishEntity extends WaterEntity {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (EntityUtils.attemptToBucket(session, itemInHand)) {
|
if (EntityUtils.attemptToBucket(itemInHand)) {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return super.mobInteract(hand, itemInHand);
|
return super.mobInteract(hand, itemInHand);
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
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.metadata.type.BooleanEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
@ -44,12 +44,12 @@ public class AgeableEntity extends CreatureEntity {
|
|||||||
protected void initializeMetadata() {
|
protected void initializeMetadata() {
|
||||||
super.initializeMetadata();
|
super.initializeMetadata();
|
||||||
// Required as of 1.19.3 Java
|
// Required as of 1.19.3 Java
|
||||||
dirtyMetadata.put(EntityData.SCALE, getAdultSize());
|
dirtyMetadata.put(EntityDataTypes.SCALE, getAdultSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||||
boolean isBaby = entityMetadata.getPrimitiveValue();
|
boolean isBaby = entityMetadata.getPrimitiveValue();
|
||||||
dirtyMetadata.put(EntityData.SCALE, isBaby ? getBabySize() : getAdultSize());
|
dirtyMetadata.put(EntityDataTypes.SCALE, isBaby ? getBabySize() : getAdultSize());
|
||||||
setFlag(EntityFlag.BABY, isBaby);
|
setFlag(EntityFlag.BABY, isBaby);
|
||||||
|
|
||||||
setBoundingBoxHeight(definition.height() * (isBaby ? getBabySize() : getAdultSize()));
|
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.metadata.type.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -87,6 +88,6 @@ public class AllayEntity extends MobEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDuplicationItem(GeyserItemStack itemStack) {
|
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;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
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.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
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.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 lombok.Getter;
|
||||||
import net.kyori.adventure.text.Component;
|
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.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.entity.type.LivingEntity;
|
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.MathUtils;
|
import org.geysermc.geyser.util.MathUtils;
|
||||||
@ -171,27 +173,27 @@ public class ArmorStandEntity extends LivingEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHeadRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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 negativeZToggle the flag to set true if the Z value of rotation is negative
|
||||||
* @param rotation the Java rotation value
|
* @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
|
// Indicate that rotation should be checked
|
||||||
setFlag(EntityFlag.BRIBED, true);
|
setFlag(EntityFlag.BRIBED, true);
|
||||||
|
|
||||||
@ -246,7 +248,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult interactAt(Hand hand) {
|
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
|
// Java Edition returns SUCCESS if in spectator mode, but this is overrided with an earlier check on the client
|
||||||
return InteractionResult.CONSUME;
|
return InteractionResult.CONSUME;
|
||||||
} else {
|
} else {
|
||||||
@ -308,7 +310,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||||||
if (!isInvisible) {
|
if (!isInvisible) {
|
||||||
// The armor stand isn't invisible. We good.
|
// The armor stand isn't invisible. We good.
|
||||||
setFlag(EntityFlag.INVISIBLE, false);
|
setFlag(EntityFlag.INVISIBLE, false);
|
||||||
dirtyMetadata.put(EntityData.SCALE, getScale());
|
dirtyMetadata.put(EntityDataTypes.SCALE, getScale());
|
||||||
updateOffsetRequirement(false);
|
updateOffsetRequirement(false);
|
||||||
|
|
||||||
if (secondEntity != null) {
|
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)
|
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))) {
|
|| !boots.equals(ItemData.AIR) || !hand.equals(ItemData.AIR) || !offHand.equals(ItemData.AIR))) {
|
||||||
// Reset scale of the proper armor stand
|
// 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
|
// Set the proper armor stand to invisible to show armor
|
||||||
setFlag(EntityFlag.INVISIBLE, true);
|
setFlag(EntityFlag.INVISIBLE, true);
|
||||||
// Update the position of the armor stand
|
// Update the position of the armor stand
|
||||||
@ -341,23 +343,23 @@ public class ArmorStandEntity extends LivingEntity {
|
|||||||
secondEntity.isSmall = isSmall;
|
secondEntity.isSmall = isSmall;
|
||||||
secondEntity.isMarker = isMarker;
|
secondEntity.isMarker = isMarker;
|
||||||
secondEntity.positionRequiresOffset = true; // Offset should always be applied
|
secondEntity.positionRequiresOffset = true; // Offset should always be applied
|
||||||
secondEntity.getDirtyMetadata().put(EntityData.NAMETAG, nametag);
|
secondEntity.getDirtyMetadata().put(EntityDataTypes.NAME, nametag);
|
||||||
secondEntity.getDirtyMetadata().put(EntityData.NAMETAG_ALWAYS_SHOW, isNameTagVisible ? (byte) 1 : (byte) 0);
|
secondEntity.getDirtyMetadata().put(EntityDataTypes.NAMETAG_ALWAYS_SHOW, isNameTagVisible ? (byte) 1 : (byte) 0);
|
||||||
secondEntity.flags.merge(this.flags);
|
secondEntity.flags.addAll(this.flags);
|
||||||
// Guarantee this copy is NOT invisible
|
// Guarantee this copy is NOT invisible
|
||||||
secondEntity.setFlag(EntityFlag.INVISIBLE, false);
|
secondEntity.setFlag(EntityFlag.INVISIBLE, false);
|
||||||
// Scale to 0 to show nametag
|
// 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
|
// 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(EntityDataTypes.WIDTH, 0.0f);
|
||||||
secondEntity.getDirtyMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f);
|
secondEntity.getDirtyMetadata().put(EntityDataTypes.HEIGHT, 0.0f);
|
||||||
if (!secondEntity.valid) { // Spawn the entity once
|
if (!secondEntity.valid) { // Spawn the entity once
|
||||||
secondEntity.spawnEntity();
|
secondEntity.spawnEntity();
|
||||||
}
|
}
|
||||||
} else if (isNametagEmpty) {
|
} else if (isNametagEmpty) {
|
||||||
// We can just make an invisible entity
|
// We can just make an invisible entity
|
||||||
// Reset scale of the proper armor stand
|
// 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
|
// Set the proper armor stand to invisible to show armor
|
||||||
setFlag(EntityFlag.INVISIBLE, true);
|
setFlag(EntityFlag.INVISIBLE, true);
|
||||||
// Update offset
|
// Update offset
|
||||||
@ -371,7 +373,7 @@ public class ArmorStandEntity extends LivingEntity {
|
|||||||
// Nametag is not empty and there is no armor
|
// Nametag is not empty and there is no armor
|
||||||
// We don't need to make a new entity
|
// We don't need to make a new entity
|
||||||
setFlag(EntityFlag.INVISIBLE, false);
|
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
|
// As the above is applied, we need an offset
|
||||||
updateOffsetRequirement(!isMarker);
|
updateOffsetRequirement(!isMarker);
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
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.metadata.type.ByteEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
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
|
// Indicate that we should show cracks through a resource pack
|
||||||
setFlag(EntityFlag.BRIBED, true);
|
setFlag(EntityFlag.BRIBED, true);
|
||||||
// Required, or else the overlay is black
|
// 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
|
// Default max health. Ensures correct cracked texture is used
|
||||||
// Bug reproducible in 1.19.0 JE vanilla/fabric when spawning a new iron golem
|
// Bug reproducible in 1.19.0 JE vanilla/fabric when spawning a new iron golem
|
||||||
maxHealth = 100f;
|
maxHealth = 100f;
|
||||||
@ -52,8 +53,8 @@ public class IronGolemEntity extends GolemEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().ironIngot()) {
|
if (itemInHand.asItem() == Items.IRON_INGOT) {
|
||||||
if (health < maxHealth) {
|
if (health < maxHealth) {
|
||||||
// Healing the iron golem
|
// Healing the iron golem
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class MagmaCubeEntity extends SlimeEntity {
|
|||||||
public void updateJump(boolean newOnGround) {
|
public void updateJump(boolean newOnGround) {
|
||||||
if (newOnGround != onGround) {
|
if (newOnGround != onGround) {
|
||||||
// Add the jumping effect to the magma cube
|
// 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();
|
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.metadata.type.ByteEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
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 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.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.LivingEntity;
|
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
import org.geysermc.geyser.item.type.SpawnEggItem;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -67,7 +67,7 @@ public class MobEntity extends LivingEntity {
|
|||||||
|
|
||||||
public void setLeashHolderBedrockId(long bedrockId) {
|
public void setLeashHolderBedrockId(long bedrockId) {
|
||||||
this.leashHolderBedrockId = bedrockId;
|
this.leashHolderBedrockId = bedrockId;
|
||||||
dirtyMetadata.put(EntityData.LEASH_HOLDER_EID, bedrockId);
|
dirtyMetadata.put(EntityDataTypes.LEASH_HOLDER, bedrockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,11 +79,10 @@ public class MobEntity extends LivingEntity {
|
|||||||
return InteractiveTag.REMOVE_LEASH;
|
return InteractiveTag.REMOVE_LEASH;
|
||||||
} else {
|
} else {
|
||||||
GeyserItemStack itemStack = session.getPlayerInventory().getItemInHand(hand);
|
GeyserItemStack itemStack = session.getPlayerInventory().getItemInHand(hand);
|
||||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
if (itemStack.asItem() == Items.LEAD && canBeLeashed()) {
|
||||||
if (itemStack.getJavaId() == storedItems.lead() && canBeLeashed()) {
|
|
||||||
// We shall leash
|
// We shall leash
|
||||||
return InteractiveTag.LEASH;
|
return InteractiveTag.LEASH;
|
||||||
} else if (itemStack.getJavaId() == storedItems.nameTag()) {
|
} else if (itemStack.asItem() == Items.NAME_TAG) {
|
||||||
InteractionResult result = checkInteractWithNameTag(itemStack);
|
InteractionResult result = checkInteractWithNameTag(itemStack);
|
||||||
if (result.consumesAction()) {
|
if (result.consumesAction()) {
|
||||||
return InteractiveTag.NAME;
|
return InteractiveTag.NAME;
|
||||||
@ -116,18 +115,16 @@ public class MobEntity extends LivingEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private InteractionResult checkPriorityInteractions(GeyserItemStack itemInHand) {
|
private InteractionResult checkPriorityInteractions(GeyserItemStack itemInHand) {
|
||||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
if (itemInHand.asItem() == Items.LEAD && canBeLeashed()) {
|
||||||
if (itemInHand.getJavaId() == storedItems.lead() && canBeLeashed()) {
|
|
||||||
// We shall leash
|
// We shall leash
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else if (itemInHand.getJavaId() == storedItems.nameTag()) {
|
} else if (itemInHand.asItem() == Items.NAME_TAG) {
|
||||||
InteractionResult result = checkInteractWithNameTag(itemInHand);
|
InteractionResult result = checkInteractWithNameTag(itemInHand);
|
||||||
if (result.consumesAction()) {
|
if (result.consumesAction()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemMapping mapping = itemInHand.getMapping(session);
|
if (itemInHand.asItem() instanceof SpawnEggItem) {
|
||||||
if (mapping.getJavaIdentifier().endsWith("_spawn_egg")) {
|
|
||||||
// Using the spawn egg on this entity to create a child
|
// Using the spawn egg on this entity to create a child
|
||||||
return InteractionResult.CONSUME;
|
return InteractionResult.CONSUME;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class SlimeEntity extends MobEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setScale(IntEntityMetadata entityMetadata) {
|
public void setScale(IntEntityMetadata entityMetadata) {
|
||||||
dirtyMetadata.put(EntityData.SCALE, 0.10f + entityMetadata.getPrimitiveValue());
|
dirtyMetadata.put(EntityDataTypes.SCALE, 0.10f + entityMetadata.getPrimitiveValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.metadata.type.ByteEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -52,8 +53,8 @@ public class SnowGolemEntity extends GolemEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (session.getItemMappings().getStoredItems().shears() == itemInHand.getJavaId() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
||||||
// Shearing the snow golem
|
// Shearing the snow golem
|
||||||
return InteractiveTag.SHEAR;
|
return InteractiveTag.SHEAR;
|
||||||
}
|
}
|
||||||
@ -62,8 +63,8 @@ public class SnowGolemEntity extends GolemEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (session.getItemMappings().getStoredItems().shears() == itemInHand.getJavaId() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
|
||||||
// Shearing the snow golem
|
// Shearing the snow golem
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.Tickable;
|
import org.geysermc.geyser.entity.type.Tickable;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
|
@ -26,9 +26,10 @@
|
|||||||
package org.geysermc.geyser.entity.type.living;
|
package org.geysermc.geyser.entity.type.living;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -61,6 +62,6 @@ public class TadpoleEntity extends AbstractFishEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFood(GeyserItemStack itemStack) {
|
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;
|
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.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -26,13 +26,14 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.living.AgeableEntity;
|
import org.geysermc.geyser.entity.type.living.AgeableEntity;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -47,24 +48,20 @@ public class AnimalEntity extends AgeableEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean canEat(GeyserItemStack itemStack) {
|
public final boolean canEat(GeyserItemStack itemStack) {
|
||||||
ItemMapping mapping = itemStack.getMapping(session);
|
return canEat(itemStack.asItem());
|
||||||
String handIdentifier = mapping.getJavaIdentifier();
|
|
||||||
return canEat(handIdentifier.replace("minecraft:", ""), mapping);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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.
|
* @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.
|
// This is what it defaults to. OK.
|
||||||
return javaIdentifierStripped.equals("wheat");
|
return item == Items.WHEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (canEat(itemInHand)) {
|
if (canEat(itemInHand)) {
|
||||||
return InteractiveTag.FEED;
|
return InteractiveTag.FEED;
|
||||||
}
|
}
|
||||||
@ -73,7 +70,7 @@ public class AnimalEntity extends AgeableEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (canEat(itemInHand)) {
|
if (canEat(itemInHand)) {
|
||||||
// FEED
|
// FEED
|
||||||
if (getFlag(EntityFlag.BABY)) {
|
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.BooleanEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
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.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.EntityUtils;
|
import org.geysermc.geyser.util.EntityUtils;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
@ -52,7 +52,7 @@ public class AxolotlEntity extends AnimalEntity {
|
|||||||
case 1 -> variant = 3; // Java - "Wild" (brown)
|
case 1 -> variant = 3; // Java - "Wild" (brown)
|
||||||
case 3 -> variant = 1; // Java - cyan
|
case 3 -> variant = 1; // Java - cyan
|
||||||
}
|
}
|
||||||
dirtyMetadata.put(EntityData.VARIANT, variant);
|
dirtyMetadata.put(EntityDataTypes.VARIANT, variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayingDead(BooleanEntityMetadata entityMetadata) {
|
public void setPlayingDead(BooleanEntityMetadata entityMetadata) {
|
||||||
@ -60,8 +60,8 @@ public class AxolotlEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return session.getTagCache().isAxolotlTemptItem(mapping);
|
return session.getTagCache().isAxolotlTemptItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,8 +76,8 @@ public class AxolotlEntity extends AnimalEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (EntityUtils.attemptToBucket(session, itemInHand)) {
|
if (EntityUtils.attemptToBucket(itemInHand)) {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return super.mobInteract(hand, itemInHand);
|
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.ByteEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
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 org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -55,7 +55,7 @@ public class BeeEntity extends AnimalEntity {
|
|||||||
session.sendUpstreamPacket(packet);
|
session.sendUpstreamPacket(packet);
|
||||||
}
|
}
|
||||||
// If the bee has stung
|
// 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
|
// If the bee has nectar or not
|
||||||
setFlag(EntityFlag.POWERED, (xd & 0x08) == 0x08);
|
setFlag(EntityFlag.POWERED, (xd & 0x08) == 0x08);
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public class BeeEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return session.getTagCache().isFlower(mapping);
|
return session.getTagCache().isFlower(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,21 +25,24 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
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.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 org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ChickenEntity extends AnimalEntity {
|
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) {
|
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);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return javaIdentifierStripped.contains("seeds");
|
return VALID_FOOD.contains(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -45,8 +46,8 @@ public class CowEntity extends AnimalEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (getFlag(EntityFlag.BABY) || !itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) {
|
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
|
||||||
return super.testMobInteraction(hand, itemInHand);
|
return super.testMobInteraction(hand, itemInHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +56,8 @@ public class CowEntity extends AnimalEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (getFlag(EntityFlag.BABY) || !itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) {
|
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
|
||||||
return super.mobInteract(hand, itemInHand);
|
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.ByteEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
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 org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -43,7 +43,7 @@ public class FoxEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFoxVariant(IntEntityMetadata entityMetadata) {
|
public void setFoxVariant(IntEntityMetadata entityMetadata) {
|
||||||
dirtyMetadata.put(EntityData.VARIANT, entityMetadata.getPrimitiveValue());
|
dirtyMetadata.put(EntityDataTypes.VARIANT, entityMetadata.getPrimitiveValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFoxFlags(ByteEntityMetadata entityMetadata) {
|
public void setFoxFlags(ByteEntityMetadata entityMetadata) {
|
||||||
@ -55,7 +55,7 @@ public class FoxEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return session.getTagCache().isFoxFood(mapping);
|
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.Pose;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
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.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
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 org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
@ -55,7 +56,7 @@ public class FrogEntity extends AnimalEntity {
|
|||||||
|
|
||||||
public void setFrogVariant(IntEntityMetadata entityMetadata) {
|
public void setFrogVariant(IntEntityMetadata entityMetadata) {
|
||||||
int variant = entityMetadata.getPrimitiveValue();
|
int variant = entityMetadata.getPrimitiveValue();
|
||||||
dirtyMetadata.put(EntityData.VARIANT, switch (variant) {
|
dirtyMetadata.put(EntityDataTypes.VARIANT, switch (variant) {
|
||||||
case 1 -> 2; // White
|
case 1 -> 2; // White
|
||||||
case 2 -> 1; // Green
|
case 2 -> 1; // Green
|
||||||
default -> variant;
|
default -> variant;
|
||||||
@ -67,15 +68,15 @@ public class FrogEntity extends AnimalEntity {
|
|||||||
if (entityId.isPresent()) {
|
if (entityId.isPresent()) {
|
||||||
Entity entity = session.getEntityCache().getEntityByJavaId(entityId.getAsInt());
|
Entity entity = session.getEntityCache().getEntityByJavaId(entityId.getAsInt());
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
dirtyMetadata.put(EntityData.TARGET_EID, entity.getGeyserId());
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, entity.getGeyserId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dirtyMetadata.put(EntityData.TARGET_EID, 0L);
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, 0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return mapping.getJavaId() == session.getItemMappings().getStoredItems().slimeBall();
|
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.Pose;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
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.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
|
|
||||||
@ -67,10 +68,12 @@ public class GoatEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO testMobInteraction?
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (!getFlag(EntityFlag.BABY) && itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) {
|
if (!getFlag(EntityFlag.BABY) && itemInHand.asItem() == Items.BUCKET) {
|
||||||
session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position);
|
session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
@ -89,6 +92,6 @@ public class GoatEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setHornCount() {
|
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;
|
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.BooleanEntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
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 org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -53,8 +54,8 @@ public class HoglinEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return javaIdentifierStripped.equals("crimson_fungus");
|
return item == Items.CRIMSON_FUNGUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.metadata.type.ObjectEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -48,18 +49,17 @@ public class MooshroomEntity extends AnimalEntity {
|
|||||||
|
|
||||||
public void setVariant(ObjectEntityMetadata<String> entityMetadata) {
|
public void setVariant(ObjectEntityMetadata<String> entityMetadata) {
|
||||||
isBrown = entityMetadata.getValue().equals("brown");
|
isBrown = entityMetadata.getValue().equals("brown");
|
||||||
dirtyMetadata.put(EntityData.VARIANT, isBrown ? 1 : 0);
|
dirtyMetadata.put(EntityDataTypes.VARIANT, isBrown ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
|
||||||
if (!isBaby()) {
|
if (!isBaby()) {
|
||||||
if (itemInHand.getJavaId() == storedItems.bowl()) {
|
if (itemInHand.asItem() == Items.BOWL) {
|
||||||
// Stew
|
// Stew
|
||||||
return InteractiveTag.MOOSHROOM_MILK_STEW;
|
return InteractiveTag.MOOSHROOM_MILK_STEW;
|
||||||
} else if (isAlive() && itemInHand.getJavaId() == storedItems.shears()) {
|
} else if (isAlive() && itemInHand.asItem() == Items.SHEARS) {
|
||||||
// Shear items
|
// Shear items
|
||||||
return InteractiveTag.MOOSHROOM_SHEAR;
|
return InteractiveTag.MOOSHROOM_SHEAR;
|
||||||
}
|
}
|
||||||
@ -69,16 +69,15 @@ public class MooshroomEntity extends AnimalEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
StoredItemMappings storedItems = session.getItemMappings().getStoredItems();
|
|
||||||
boolean isBaby = isBaby();
|
boolean isBaby = isBaby();
|
||||||
if (!isBaby && itemInHand.getJavaId() == storedItems.bowl()) {
|
if (!isBaby && itemInHand.asItem() == Items.BOWL) {
|
||||||
// Stew
|
// Stew
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else if (!isBaby && isAlive() && itemInHand.getJavaId() == storedItems.shears()) {
|
} else if (!isBaby && isAlive() && itemInHand.asItem() == Items.SHEARS) {
|
||||||
// Shear items
|
// Shear items
|
||||||
return InteractionResult.SUCCESS;
|
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;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -45,8 +46,8 @@ public class OcelotEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return javaIdentifierStripped.equals("cod") || javaIdentifierStripped.equals("salmon");
|
return item == Items.COD || item == Items.SALMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@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.ByteEntityMetadata;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
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.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -55,13 +56,13 @@ public class PandaEntity extends AnimalEntity {
|
|||||||
public void setEatingCounter(IntEntityMetadata entityMetadata) {
|
public void setEatingCounter(IntEntityMetadata entityMetadata) {
|
||||||
int count = entityMetadata.getPrimitiveValue();
|
int count = entityMetadata.getPrimitiveValue();
|
||||||
setFlag(EntityFlag.EATING, count > 0);
|
setFlag(EntityFlag.EATING, count > 0);
|
||||||
dirtyMetadata.put(EntityData.EATING_COUNTER, count);
|
dirtyMetadata.put(EntityDataTypes.EATING_COUNTER, count);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
// Particles and sound
|
// Particles and sound
|
||||||
EntityEventPacket packet = new EntityEventPacket();
|
EntityEventPacket packet = new EntityEventPacket();
|
||||||
packet.setRuntimeEntityId(geyserId);
|
packet.setRuntimeEntityId(geyserId);
|
||||||
packet.setType(EntityEventType.EATING_ITEM);
|
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);
|
session.sendUpstreamPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,19 +83,19 @@ public class PandaEntity extends AnimalEntity {
|
|||||||
setFlag(EntityFlag.ROLLING, (xd & 0x04) == 0x04);
|
setFlag(EntityFlag.ROLLING, (xd & 0x04) == 0x04);
|
||||||
setFlag(EntityFlag.SITTING, (xd & 0x08) == 0x08);
|
setFlag(EntityFlag.SITTING, (xd & 0x08) == 0x08);
|
||||||
// Required to put these both for sitting to actually show
|
// Required to put these both for sitting to actually show
|
||||||
dirtyMetadata.put(EntityData.SITTING_AMOUNT, (xd & 0x08) == 0x08 ? 1f : 0f);
|
dirtyMetadata.put(EntityDataTypes.SITTING_AMOUNT, (xd & 0x08) == 0x08 ? 1f : 0f);
|
||||||
dirtyMetadata.put(EntityData.SITTING_AMOUNT_PREVIOUS, (xd & 0x08) == 0x08 ? 1f : 0f);
|
dirtyMetadata.put(EntityDataTypes.SITTING_AMOUNT_PREVIOUS, (xd & 0x08) == 0x08 ? 1f : 0f);
|
||||||
setFlag(EntityFlag.LAYING_DOWN, (xd & 0x10) == 0x10);
|
setFlag(EntityFlag.LAYING_DOWN, (xd & 0x10) == 0x10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return javaIdentifierStripped.equals("bamboo");
|
return item == Items.BAMBOO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (mainGene == Gene.WORRIED && session.isThunder()) {
|
if (mainGene == Gene.WORRIED && session.isThunder()) {
|
||||||
return InteractiveTag.NONE;
|
return InteractiveTag.NONE;
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ public class PandaEntity extends AnimalEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||||
if (mainGene == Gene.WORRIED && session.isThunder()) {
|
if (mainGene == Gene.WORRIED && session.isThunder()) {
|
||||||
// Huh!
|
// Huh!
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
@ -133,14 +134,14 @@ public class PandaEntity extends AnimalEntity {
|
|||||||
if (mainGene.isRecessive) {
|
if (mainGene.isRecessive) {
|
||||||
if (mainGene == hiddenGene) {
|
if (mainGene == hiddenGene) {
|
||||||
// Main and hidden genes match; this is what the panda looks like.
|
// 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 {
|
} else {
|
||||||
// Genes have no effect on appearance
|
// Genes have no effect on appearance
|
||||||
dirtyMetadata.put(EntityData.VARIANT, Gene.NORMAL.ordinal());
|
dirtyMetadata.put(EntityDataTypes.VARIANT, Gene.NORMAL.ordinal());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No need to worry about hidden gene
|
// 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;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.EntityUtils;
|
import org.geysermc.geyser.util.EntityUtils;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
@ -46,13 +47,13 @@ public class PigEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) {
|
public boolean canEat(Item item) {
|
||||||
return javaIdentifierStripped.equals("carrot") || javaIdentifierStripped.equals("potato") || javaIdentifierStripped.equals("beetroot");
|
return item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@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()) {
|
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
|
||||||
// Mount
|
// Mount
|
||||||
return InteractiveTag.MOUNT;
|
return InteractiveTag.MOUNT;
|
||||||
@ -61,7 +62,7 @@ public class PigEntity extends AnimalEntity {
|
|||||||
if (superTag != InteractiveTag.NONE) {
|
if (superTag != InteractiveTag.NONE) {
|
||||||
return superTag;
|
return superTag;
|
||||||
} else {
|
} else {
|
||||||
return EntityUtils.attemptToSaddle(session, this, itemInHand).consumesAction()
|
return EntityUtils.attemptToSaddle(this, itemInHand).consumesAction()
|
||||||
? InteractiveTag.SADDLE : InteractiveTag.NONE;
|
? InteractiveTag.SADDLE : InteractiveTag.NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ public class PigEntity extends AnimalEntity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@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()) {
|
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
|
||||||
// Mount
|
// Mount
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
@ -78,7 +79,7 @@ public class PigEntity extends AnimalEntity {
|
|||||||
if (superResult.consumesAction()) {
|
if (superResult.consumesAction()) {
|
||||||
return superResult;
|
return superResult;
|
||||||
} else {
|
} else {
|
||||||
return EntityUtils.attemptToSaddle(session, this, itemInHand);
|
return EntityUtils.attemptToSaddle(this, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren