Project wide syntax/annotation cleanup (#4238)

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
This commit is contained in:
chris 2023-12-06 00:54:42 +01:00 committed by GitHub
parent 998caee156
commit 95d65350e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
270 changed files with 891 additions and 977 deletions

View file

@ -152,7 +152,7 @@ public interface GeyserBootstrap {
* @param resource Resource to get
* @return InputStream of the given resource
*/
default @NonNull InputStream getResource(String resource) {
default @NonNull InputStream getResourceOrThrow(@NonNull String resource) {
InputStream stream = getResourceOrNull(resource);
if (stream == null) {
throw new AssertionError("Unable to find resource: " + resource);

View file

@ -71,6 +71,7 @@ import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.network.netty.GeyserServer;
import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.provider.ProviderSupplier;
import org.geysermc.geyser.scoreboard.ScoreboardUpdater;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
@ -622,7 +623,7 @@ public class GeyserImpl implements GeyserApi {
*/
public boolean isProductionEnvironment() {
// First is if Blossom runs, second is if Blossom doesn't run
// noinspection ConstantConditions - changes in production
//noinspection ConstantConditions,MismatchedStringCase - changes in production
return !("git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION) || "${gitVersion}".equals(GeyserImpl.GIT_VERSION));
}
@ -638,8 +639,13 @@ public class GeyserImpl implements GeyserApi {
}
@Override
@SuppressWarnings("unchecked")
public <R extends T, T> @NonNull R provider(@NonNull Class<T> apiClass, @Nullable Object... args) {
return (R) Registries.PROVIDERS.get(apiClass).create(args);
ProviderSupplier provider = Registries.PROVIDERS.get(apiClass);
if (provider == null) {
throw new IllegalArgumentException("No provider found for " + apiClass);
}
return (R) provider.create(args);
}
@Override

View file

@ -26,9 +26,10 @@
package org.geysermc.geyser;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.command.GeyserCommandSource;
import javax.annotation.Nullable;
public interface GeyserLogger extends GeyserCommandSource {
@ -119,7 +120,7 @@ public interface GeyserLogger extends GeyserCommandSource {
}
@Override
default void sendMessage(String message) {
default void sendMessage(@NonNull String message) {
info(message);
}

View file

@ -30,6 +30,7 @@ import java.io.InputStream;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Objects;
import java.util.Scanner;
public class GeyserMain {
@ -61,8 +62,8 @@ public class GeyserMain {
helpStream = GeyserMain.class.getClassLoader().getResourceAsStream("languages/run-help/en_US.txt");
}
Scanner help = new Scanner(helpStream, StandardCharsets.UTF_8).useDelimiter("\\Z");
String line = "";
Scanner help = new Scanner(Objects.requireNonNull(helpStream), StandardCharsets.UTF_8).useDelimiter("\\Z");
String line;
while (help.hasNext()) {
line = help.next();

View file

@ -29,10 +29,10 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.session.GeyserSession;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
@ -73,15 +73,6 @@ public abstract class GeyserCommand implements Command {
return Collections.emptyList();
}
/**
* Shortcut to {@link #subCommands()} ()}{@code .isEmpty()}.
*
* @return true if there are subcommand present for this command.
*/
public boolean hasSubCommands() {
return !this.subCommands().isEmpty();
}
public void setAliases(List<String> aliases) {
this.aliases = aliases;
}

View file

@ -26,11 +26,11 @@
package org.geysermc.geyser.command;
import lombok.AllArgsConstructor;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.session.GeyserSession;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

View file

@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command;
@ -53,8 +54,6 @@ import org.geysermc.geyser.event.type.GeyserDefineCommandsEventImpl;
import org.geysermc.geyser.extension.command.GeyserExtensionCommand;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashMap;
@ -136,12 +135,12 @@ public class GeyserCommandManager {
}
}
@NotNull
@NonNull
public Map<String, Command> commands() {
return Collections.unmodifiableMap(this.commands);
}
@NotNull
@NonNull
public Map<Extension, Map<String, Command>> extensionCommands() {
return Collections.unmodifiableMap(this.extensionCommands);
}

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.command.defaults;
import com.fasterxml.jackson.databind.JsonNode;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommand;
@ -34,7 +35,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.LoopbackUtil;
import org.geysermc.geyser.util.WebUtils;
import org.jetbrains.annotations.Nullable;
import java.util.Random;
import java.util.concurrent.CompletableFuture;

View file

@ -98,7 +98,7 @@ public class DumpCommand extends GeyserCommand {
return;
}
String uploadedDumpUrl = "";
String uploadedDumpUrl;
if (offlineDump) {
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.writing", sender.locale()));

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.command.defaults;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.extension.Extension;
import org.geysermc.geyser.command.GeyserCommand;
@ -32,7 +33,6 @@ import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.GeyserLocale;
import org.jetbrains.annotations.Nullable;
import java.util.Comparator;
import java.util.List;

View file

@ -27,8 +27,8 @@ package org.geysermc.geyser.command.defaults;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.geysermc.geyser.Constants;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.network.GameProtocol;
@ -37,7 +37,6 @@ import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.WebUtils;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
@ -77,7 +76,7 @@ public class VersionCommand extends GeyserCommand {
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.checking", sender.locale()));
try {
String buildXML = WebUtils.getBody("https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/" +
URLEncoder.encode(GeyserImpl.BRANCH, StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
URLEncoder.encode(GeyserImpl.BRANCH, StandardCharsets.UTF_8) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
if (buildXML.startsWith("<buildNumber>")) {
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
int buildNum = this.geyser.buildNumber();
@ -90,7 +89,7 @@ public class VersionCommand extends GeyserCommand {
} else {
throw new AssertionError("buildNumber missing");
}
} catch (IOException e) {
} catch (Exception e) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e);
sender.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.version.failed", sender.locale()));
}

View file

@ -52,6 +52,7 @@ public interface GeyserConfiguration {
List<String> getSavedUserLogins();
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isCommandSuggestions();
@JsonIgnore
@ -93,6 +94,7 @@ public interface GeyserConfiguration {
boolean isForceResourcePacks();
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isXboxAchievementsEnabled();
int getCacheImages();

View file

@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Getter;
import lombok.Setter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.network.CIDRMatcher;
@ -158,7 +159,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
private String address = "0.0.0.0";
@Override
public String address() {
public @NonNull String address() {
return address;
}
@ -260,7 +261,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
private AuthType authType = AuthType.ONLINE;
@Override
public AuthType authType() {
public @NonNull AuthType authType() {
return authType;
}

View file

@ -33,7 +33,6 @@ import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.geysermc.floodgate.util.DeviceOs;
@ -106,8 +105,8 @@ public class DumpInfo {
// https://stackoverflow.com/questions/304268/getting-a-files-md5-checksum-in-java
File file = new File(DumpInfo.class.getProtectionDomain().getCodeSource().getLocation().toURI());
ByteSource byteSource = Files.asByteSource(file);
// Jenkins uses MD5 for its hash
//noinspection UnstableApiUsage
// Jenkins uses MD5 for its hash - TODO remove
//noinspection UnstableApiUsage,deprecation
md5Hash = byteSource.hash(Hashing.md5()).toString();
//noinspection UnstableApiUsage
sha256Hash = byteSource.hash(Hashing.sha256()).toString();
@ -118,7 +117,7 @@ public class DumpInfo {
}
this.hashInfo = new HashInfo(md5Hash, sha256Hash);
this.ramInfo = new DumpInfo.RamInfo();
this.ramInfo = new RamInfo();
if (addLog) {
this.logsInfo = new LogsInfo();
@ -202,7 +201,7 @@ public class DumpInfo {
private boolean checkDockerBasic() {
try {
String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) {
if (OS.contains("nix") || OS.contains("nux") || OS.indexOf("aix") > 0) {
String output = new String(java.nio.file.Files.readAllBytes(Paths.get("/proc/1/cgroup")));
if (output.contains("docker")) {
@ -259,60 +258,30 @@ public class DumpInfo {
}
}
@AllArgsConstructor
@Getter
public static class HashInfo {
private final String md5Hash;
private final String sha256Hash;
public record HashInfo(String md5Hash, String sha256Hash) {
}
@Getter
public static class RamInfo {
private final long free;
private final long total;
private final long max;
RamInfo() {
this.free = Runtime.getRuntime().freeMemory() / MEGABYTE;
this.total = Runtime.getRuntime().totalMemory() / MEGABYTE;
this.max = Runtime.getRuntime().maxMemory() / MEGABYTE;
public record RamInfo(long free, long total, long max) {
public RamInfo() {
this(Runtime.getRuntime().freeMemory() / MEGABYTE,
Runtime.getRuntime().totalMemory() / MEGABYTE,
Runtime.getRuntime().maxMemory() / MEGABYTE);
}
}
/**
* E.G. `-Xmx1024M` - all runtime JVM flags on this machine
*/
@Getter
public static class FlagsInfo {
private final List<String> flags;
FlagsInfo() {
this.flags = ManagementFactory.getRuntimeMXBean().getInputArguments();
public record FlagsInfo(List<String> flags) {
public FlagsInfo() {
this(ManagementFactory.getRuntimeMXBean().getInputArguments());
}
}
@Getter
@AllArgsConstructor
public static class ExtensionInfo {
public boolean enabled;
public String name;
public String version;
public String apiVersion;
public String main;
public List<String> authors;
public record ExtensionInfo(boolean enabled, String name, String version, String apiVersion, String main, List<String> authors) {
}
@Getter
@AllArgsConstructor
public static class GitInfo {
private final String buildNumber;
@JsonProperty("git.commit.id.abbrev")
private final String commitHashAbbrev;
@JsonProperty("git.commit.id")
private final String commitHash;
@JsonProperty("git.branch")
private final String branchName;
@JsonProperty("git.remote.origin.url")
private final String originUrl;
public record GitInfo(String buildNumber, @JsonProperty("git.commit.id.abbrev") String commitHashAbbrev, @JsonProperty("git.commit.id") String commitHash,
@JsonProperty("git.branch") String branchName, @JsonProperty("git.remote.origin.url") String originUrl) {
}
}

View file

@ -59,6 +59,7 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
return new Builder<>(factory);
}
@SuppressWarnings("unchecked")
public <M> void translateMetadata(T entity, EntityMetadata<M, ? extends MetadataType<M>> metadata) {
EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>> translator = (EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>>) this.translators.get(metadata.getId());
if (translator == null) {

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.entity.attribute;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -69,7 +70,7 @@ public enum GeyserAttributeType {
return getAttribute(value, maximum);
}
public AttributeData getAttribute(float value, float maximum) {
public @Nullable AttributeData getAttribute(float value, float maximum) {
if (bedrockIdentifier == null) {
return null;
}

View file

@ -34,7 +34,6 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ParticleMapping;
import org.geysermc.geyser.session.GeyserSession;
import java.util.UUID;

View file

@ -36,6 +36,7 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector2f;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
@ -580,7 +581,7 @@ public class Entity implements GeyserEntity {
}
@SuppressWarnings("unchecked")
public <I extends Entity> I as(Class<I> entityClass) {
public <I extends Entity> @Nullable I as(Class<I> entityClass) {
return entityClass.isInstance(this) ? (I) this : null;
}
}

View file

@ -38,6 +38,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
@ -120,7 +121,7 @@ public class LivingEntity extends Entity {
session.sendUpstreamPacket(attributesPacket);
}
public Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
public @Nullable Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
Optional<Vector3i> optionalPos = entityMetadata.getValue();
if (optionalPos.isPresent()) {
Vector3i bedPosition = optionalPos.get();

View file

@ -51,7 +51,6 @@ public class ThrowableEntity extends Entity implements Tickable {
/**
* Updates the position for the Bedrock client.
*
* Java clients assume the next positions of moving items. Bedrock needs to be explicitly told positions
*/
@Override

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -34,7 +35,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID;
public class AbstractFishEntity extends WaterEntity {
@ -48,9 +48,9 @@ public class AbstractFishEntity extends WaterEntity {
setFlag(EntityFlag.HAS_GRAVITY, false);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (EntityUtils.attemptToBucket(itemInHand)) {
return InteractionResult.SUCCESS;
} else {

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class AllayEntity extends MobEntity {
@ -54,9 +54,9 @@ public class AllayEntity extends MobEntity {
this.canDuplicate = entityMetadata.getPrimitiveValue();
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) {
// Maybe better as another tag?
return InteractiveTag.GIVE_ITEM_TO_ALLAY;
@ -70,9 +70,9 @@ public class AllayEntity extends MobEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) {
//TOCHECK sound
return InteractionResult.SUCCESS;

View file

@ -70,7 +70,7 @@ public class ArmorStandEntity extends LivingEntity {
private boolean primaryEntity = true;
/**
* Whether the entity's position must be updated to included the offset.
*
* <p>
* This should be true when the Java server marks the armor stand as invisible, but we shrink the entity
* to allow the nametag to appear. Basically:
* - Is visible: this is irrelevant (false)
@ -207,7 +207,7 @@ public class ArmorStandEntity extends LivingEntity {
* @param negativeZToggle the flag to set true if the Z value of rotation is negative
* @param rotation the Java rotation value
*/
private void onRotationUpdate(EntityDataType dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) {
private void onRotationUpdate(EntityDataType<Integer> dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) {
// Indicate that rotation should be checked
setFlag(EntityFlag.BRIBED, true);

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
@ -33,7 +34,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class DolphinEntity extends WaterEntity {
@ -46,18 +46,18 @@ public class DolphinEntity extends WaterEntity {
return true;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) {
return InteractiveTag.FEED;
}
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) {
// Feed
return InteractionResult.SUCCESS;

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -35,7 +36,6 @@ import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID;
public class IronGolemEntity extends GolemEntity {
@ -51,9 +51,9 @@ public class IronGolemEntity extends GolemEntity {
maxHealth = 100f;
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.IRON_INGOT) {
if (health < maxHealth) {
// Healing the iron golem

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -40,7 +41,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class MobEntity extends LivingEntity {
@ -133,13 +133,13 @@ public class MobEntity extends LivingEntity {
return InteractionResult.PASS;
}
@Nonnull
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
@NonNull
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return InteractiveTag.NONE;
}
@Nonnull
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
@NonNull
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return InteractionResult.PASS;
}

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class SnowGolemEntity extends GolemEntity {
@ -51,9 +51,9 @@ public class SnowGolemEntity extends GolemEntity {
setFlag(EntityFlag.SHEARED, (xd & 0x10) != 0x10);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
// Shearing the snow golem
return InteractiveTag.SHEAR;
@ -61,9 +61,9 @@ public class SnowGolemEntity extends GolemEntity {
return InteractiveTag.NONE;
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
// Shearing the snow golem
return InteractionResult.SUCCESS;

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
@ -34,7 +35,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class TadpoleEntity extends AbstractFishEntity {
@ -42,18 +42,18 @@ public class TadpoleEntity extends AbstractFishEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (isFood(itemInHand)) {
return InteractiveTag.FEED;
}
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (isFood(itemInHand)) {
//TODO particles
return InteractionResult.SUCCESS;

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -38,7 +39,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class AnimalEntity extends AgeableEntity {
@ -59,18 +59,18 @@ public class AnimalEntity extends AgeableEntity {
return item == Items.WHEAT;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (canEat(itemInHand)) {
return InteractiveTag.FEED;
}
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (canEat(itemInHand)) {
// FEED
if (getFlag(EntityFlag.BABY)) {

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -38,7 +39,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID;
public class AxolotlEntity extends AnimalEntity {
@ -74,9 +74,9 @@ public class AxolotlEntity extends AnimalEntity {
return true;
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (EntityUtils.attemptToBucket(itemInHand)) {
return InteractionResult.SUCCESS;
} else {

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class CowEntity extends AnimalEntity {
@ -44,9 +44,9 @@ public class CowEntity extends AnimalEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
return super.testMobInteraction(hand, itemInHand);
}
@ -54,9 +54,9 @@ public class CowEntity extends AnimalEntity {
return InteractiveTag.MILK;
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
return super.mobInteract(hand, itemInHand);
}

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
@ -38,7 +39,6 @@ import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID;
public class GoatEntity extends AnimalEntity {
@ -70,9 +70,9 @@ public class GoatEntity extends AnimalEntity {
// TODO testMobInteraction?
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.BABY) && itemInHand.asItem() == Items.BUCKET) {
session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position);
return InteractionResult.SUCCESS;

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.geysermc.geyser.entity.EntityDefinition;
@ -37,7 +38,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class MooshroomEntity extends AnimalEntity {
@ -52,9 +52,9 @@ public class MooshroomEntity extends AnimalEntity {
dirtyMetadata.put(EntityDataTypes.VARIANT, isBrown ? 1 : 0);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!isBaby()) {
if (itemInHand.asItem() == Items.BOWL) {
// Stew
@ -67,9 +67,9 @@ public class MooshroomEntity extends AnimalEntity {
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean isBaby = isBaby();
if (!isBaby && itemInHand.asItem() == Items.BOWL) {
// Stew

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class OcelotEntity extends AnimalEntity {
@ -50,9 +50,9 @@ public class OcelotEntity extends AnimalEntity {
return item == Items.COD || item == Items.SALMON;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) {
// Attempt to feed
return InteractiveTag.FEED;
@ -61,9 +61,9 @@ public class OcelotEntity extends AnimalEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) {
// Attempt to feed
return InteractionResult.SUCCESS;

View file

@ -28,6 +28,8 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
@ -41,8 +43,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.UUID;
public class PandaEntity extends AnimalEntity {
@ -93,18 +93,18 @@ public class PandaEntity extends AnimalEntity {
return item == Items.BAMBOO;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (mainGene == Gene.WORRIED && session.isThunder()) {
return InteractiveTag.NONE;
}
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (mainGene == Gene.WORRIED && session.isThunder()) {
// Huh!
return InteractionResult.PASS;

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -37,7 +38,6 @@ import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class PigEntity extends AnimalEntity {
@ -51,9 +51,9 @@ public class PigEntity extends AnimalEntity {
return item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
// Mount
return InteractiveTag.MOUNT;
@ -68,9 +68,9 @@ public class PigEntity extends AnimalEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
// Mount
return InteractionResult.SUCCESS;

View file

@ -27,6 +27,7 @@ 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.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -38,7 +39,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class SheepEntity extends AnimalEntity {
@ -55,9 +55,9 @@ public class SheepEntity extends AnimalEntity {
dirtyMetadata.put(EntityDataTypes.COLOR, (byte) color);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.SHEARS) {
return InteractiveTag.SHEAR;
} else {
@ -73,9 +73,9 @@ public class SheepEntity extends AnimalEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.SHEARS) {
return InteractionResult.CONSUME;
} else {

View file

@ -27,6 +27,7 @@ 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.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -39,7 +40,6 @@ import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class StriderEntity extends AnimalEntity {
@ -98,9 +98,9 @@ public class StriderEntity extends AnimalEntity {
return item == Items.WARPED_FUNGUS;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
// Mount Strider
return InteractiveTag.RIDE_STRIDER;
@ -115,9 +115,9 @@ public class StriderEntity extends AnimalEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
// Mount Strider
return InteractionResult.SUCCESS;

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal.horse;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
@ -44,7 +45,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.Set;
import java.util.UUID;
@ -128,14 +128,14 @@ public class AbstractHorseEntity extends AnimalEntity {
return DONKEY_AND_HORSE_FOODS.contains(item);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return testHorseInteraction(hand, itemInHand);
}
@Nonnull
protected final InteractiveTag testHorseInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
@NonNull
protected final InteractiveTag testHorseInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean isBaby = isBaby();
if (!isBaby) {
if (getFlag(EntityFlag.TAMED) && session.isSneaking()) {
@ -178,14 +178,14 @@ public class AbstractHorseEntity extends AnimalEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return mobHorseInteract(hand, itemInHand);
}
@Nonnull
protected final InteractionResult mobHorseInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
@NonNull
protected final InteractionResult mobHorseInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean isBaby = isBaby();
if (!isBaby) {
if (getFlag(EntityFlag.TAMED) && session.isSneaking()) {
@ -236,21 +236,21 @@ public class AbstractHorseEntity extends AnimalEntity {
}
}
protected boolean testSaddle(@Nonnull GeyserItemStack itemInHand) {
protected boolean testSaddle(@NonNull GeyserItemStack itemInHand) {
return isAlive() && !getFlag(EntityFlag.BABY) && getFlag(EntityFlag.TAMED);
}
protected boolean testForChest(@Nonnull GeyserItemStack itemInHand) {
protected boolean testForChest(@NonNull GeyserItemStack itemInHand) {
return false;
}
protected boolean additionalTestForInventoryOpen(@Nonnull GeyserItemStack itemInHand) {
protected boolean additionalTestForInventoryOpen(@NonNull GeyserItemStack itemInHand) {
return itemInHand.asItem().javaIdentifier().endsWith("_horse_armor");
}
/* Just a place to stuff common code for the undead variants without having duplicate code */
protected final InteractiveTag testUndeadHorseInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected final InteractiveTag testUndeadHorseInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.TAMED)) {
return InteractiveTag.NONE;
} else if (isBaby()) {
@ -272,7 +272,7 @@ public class AbstractHorseEntity extends AnimalEntity {
}
}
protected final InteractionResult undeadHorseInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected final InteractionResult undeadHorseInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.TAMED)) {
return InteractionResult.PASS;
} else if (isBaby()) {

View file

@ -111,6 +111,5 @@ public class CamelEntity extends AbstractHorseEntity {
}
public void setDashing(BooleanEntityMetadata entityMetadata) {
}
}

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.entity.type.living.animal.horse;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -32,7 +33,6 @@ import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import javax.annotation.Nonnull;
import java.util.UUID;
public class ChestedHorseEntity extends AbstractHorseEntity {
@ -47,18 +47,18 @@ public class ChestedHorseEntity extends AbstractHorseEntity {
}
@Override
protected boolean testSaddle(@Nonnull GeyserItemStack itemInHand) {
protected boolean testSaddle(@NonNull GeyserItemStack itemInHand) {
// Not checked here
return false;
}
@Override
protected boolean testForChest(@Nonnull GeyserItemStack itemInHand) {
protected boolean testForChest(@NonNull GeyserItemStack itemInHand) {
return itemInHand.asItem() == Items.CHEST && !getFlag(EntityFlag.CHESTED);
}
@Override
protected boolean additionalTestForInventoryOpen(@Nonnull GeyserItemStack itemInHand) {
protected boolean additionalTestForInventoryOpen(@NonNull GeyserItemStack itemInHand) {
// Armor won't work on these
return false;
}

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal.horse;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
@ -33,7 +34,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class SkeletonHorseEntity extends AbstractHorseEntity {
@ -41,15 +41,15 @@ public class SkeletonHorseEntity extends AbstractHorseEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return testUndeadHorseInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return undeadHorseInteract(hand, itemInHand);
}
}

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal.horse;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
@ -33,7 +34,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class ZombieHorseEntity extends AbstractHorseEntity {
@ -41,15 +41,15 @@ public class ZombieHorseEntity extends AbstractHorseEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return testUndeadHorseInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return undeadHorseInteract(hand, itemInHand);
}
}

View file

@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanE
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -40,7 +41,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class CatEntity extends TameableEntity {
@ -112,9 +112,9 @@ public class CatEntity extends TameableEntity {
return item == Items.COD || item == Items.SALMON;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean tamed = getFlag(EntityFlag.TAMED);
if (tamed && ownerBedrockId == session.getPlayerEntity().getGeyserId()) {
// Toggle sitting
@ -124,9 +124,9 @@ public class CatEntity extends TameableEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean tamed = getFlag(EntityFlag.TAMED);
if (tamed && ownerBedrockId == session.getPlayerEntity().getGeyserId()) {
return InteractionResult.SUCCESS;

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal.tameable;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.Set;
import java.util.UUID;
@ -61,9 +61,9 @@ public class ParrotEntity extends TameableEntity {
return item == Items.COOKIE;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean tame = getFlag(EntityFlag.TAMED);
if (!tame && isTameFood(itemInHand.asItem())) {
return InteractiveTag.FEED;
@ -76,9 +76,9 @@ public class ParrotEntity extends TameableEntity {
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean tame = getFlag(EntityFlag.TAMED);
if (!tame && isTameFood(itemInHand.asItem())) {
return InteractionResult.SUCCESS;

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.animal.tameable;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -40,7 +41,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.Set;
import java.util.UUID;
@ -103,9 +103,9 @@ public class WolfEntity extends TameableEntity {
return !getFlag(EntityFlag.ANGRY) && super.canBeLeashed();
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (getFlag(EntityFlag.ANGRY)) {
return InteractiveTag.NONE;
}
@ -126,9 +126,9 @@ public class WolfEntity extends TameableEntity {
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (ownerBedrockId == session.getPlayerEntity().getGeyserId() || getFlag(EntityFlag.TAMED)
|| itemInHand.asItem() == Items.BONE && !getFlag(EntityFlag.ANGRY)) {
// Sitting toggle or feeding; not angry

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.merchant;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
@ -37,7 +38,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class AbstractMerchantEntity extends AgeableEntity {
@ -51,9 +51,9 @@ public class AbstractMerchantEntity extends AgeableEntity {
return false;
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() != Items.VILLAGER_SPAWN_EGG
&& (definition != EntityDefinitions.VILLAGER || !getFlag(EntityFlag.SLEEPING) && ((VillagerEntity) this).isCanTradeWith())) {
// An additional check we know cannot work
@ -64,9 +64,9 @@ public class AbstractMerchantEntity extends AgeableEntity {
return super.testMobInteraction(hand, itemInHand);
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() != Items.VILLAGER_SPAWN_EGG
&& (definition != EntityDefinitions.VILLAGER || !getFlag(EntityFlag.SLEEPING))
&& (definition != EntityDefinitions.WANDERING_TRADER || !getFlag(EntityFlag.BABY))) {

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.merchant;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.VillagerData;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
@ -78,6 +79,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
VILLAGER_REGIONS[6] = 6;
}
@Nullable
private Vector3i bedPosition;
/**
* Used in the interactive tag manager
@ -103,7 +105,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
}
@Override
public Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
public @Nullable Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
return bedPosition = super.setBedPosition(entityMetadata);
}

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.monster;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -37,7 +38,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class CreeperEntity extends MonsterEntity {
@ -62,9 +62,9 @@ public class CreeperEntity extends MonsterEntity {
setFlag(EntityFlag.IGNITED, ignitedByFlintAndSteel);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (session.getTagCache().isCreeperIgniter(itemInHand.asItem())) {
return InteractiveTag.IGNITE_CREEPER;
} else {
@ -72,9 +72,9 @@ public class CreeperEntity extends MonsterEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (session.getTagCache().isCreeperIgniter(itemInHand.asItem())) {
// Ignite creeper - as of 1.19.3
session.playSoundEvent(SoundEvent.IGNITE, position);

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.monster;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -37,7 +38,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class PiglinEntity extends BasePiglinEntity {
@ -71,9 +71,9 @@ public class PiglinEntity extends BasePiglinEntity {
super.updateOffHand(session);
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
InteractiveTag tag = super.testMobInteraction(hand, itemInHand);
if (tag != InteractiveTag.NONE) {
return tag;
@ -82,9 +82,9 @@ public class PiglinEntity extends BasePiglinEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
InteractionResult superResult = super.mobInteract(hand, itemInHand);
if (superResult.consumesAction()) {
return superResult;
@ -93,7 +93,7 @@ public class PiglinEntity extends BasePiglinEntity {
}
}
private boolean canGiveGoldTo(@Nonnull GeyserItemStack itemInHand) {
private boolean canGiveGoldTo(@NonNull GeyserItemStack itemInHand) {
return !getFlag(EntityFlag.BABY) && itemInHand.asItem() == Items.GOLD_INGOT && !getFlag(EntityFlag.ADMIRING);
}
}

View file

@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat
import com.github.steveice10.mc.protocol.data.game.entity.metadata.VillagerData;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -40,7 +41,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID;
public class ZombieVillagerEntity extends ZombieEntity {
@ -67,9 +67,9 @@ public class ZombieVillagerEntity extends ZombieEntity {
return getFlag(EntityFlag.IS_TRANSFORMING) || super.isShaking();
}
@Nonnull
@NonNull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.GOLDEN_APPLE) {
return InteractiveTag.CURE;
} else {
@ -77,9 +77,9 @@ public class ZombieVillagerEntity extends ZombieEntity {
}
}
@Nonnull
@NonNull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.GOLDEN_APPLE) {
// The client doesn't know if the entity has weakness as that's not usually sent over the network
return InteractionResult.CONSUME;

View file

@ -36,6 +36,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.*;
@ -57,7 +58,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.ChunkUtils;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@ -86,6 +86,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
@Nullable
private String texturesProperty;
@Nullable
private Vector3i bedPosition;
/**
@ -240,7 +241,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
}
@Override
public Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
public @Nullable Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
bedPosition = super.setBedPosition(entityMetadata);
if (bedPosition != null) {
// Required to sync position of entity to bed

View file

@ -33,6 +33,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEnti
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
@ -44,7 +45,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.AttributeUtils;
import org.geysermc.geyser.util.DimensionUtils;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -112,7 +112,7 @@ public class SessionPlayerEntity extends PlayerEntity {
/**
* Sending any updated flags (sprinting, onFire, etc.) to the client while in spectator is not needed
* Also "fixes" https://github.com/GeyserMC/Geyser/issues/3318
* Also "fixes" <a href="https://github.com/GeyserMC/Geyser/issues/3318">issue 3318</a>
*/
@Override
public void setFlags(ByteEntityMetadata entityMetadata) {
@ -126,7 +126,7 @@ public class SessionPlayerEntity extends PlayerEntity {
/**
* Since 1.19.40, the client must be re-informed of its bounding box on respawn
* See https://github.com/GeyserMC/Geyser/issues/3370
* See <a href="https://github.com/GeyserMC/Geyser/issues/3370">issue 3370</a>
*/
public void updateBoundingBox() {
dirtyMetadata.put(EntityDataTypes.HEIGHT, getBoundingBoxHeight());

View file

@ -25,9 +25,9 @@
package org.geysermc.geyser.erosion;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.erosion.packet.geyserbound.*;
import org.geysermc.geyser.session.GeyserSession;
import org.jetbrains.annotations.Nullable;
public abstract class AbstractGeyserboundPacketHandler implements GeyserboundPacketHandler {
protected final GeyserSession session;

View file

@ -26,11 +26,11 @@
package org.geysermc.geyser.erosion;
import io.netty.channel.Channel;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.erosion.netty.NettyPacketSender;
import org.geysermc.erosion.packet.ErosionPacketHandler;
import org.geysermc.erosion.packet.geyserbound.GeyserboundHandshakePacket;
import org.geysermc.geyser.session.GeyserSession;
import org.jetbrains.annotations.Nullable;
public final class GeyserboundHandshakePacketHandler extends AbstractGeyserboundPacketHandler {
@ -66,7 +66,7 @@ public final class GeyserboundHandshakePacketHandler extends AbstractGeyserbound
}
@Override
public ErosionPacketHandler setChannel(Channel channel) {
public @Nullable ErosionPacketHandler setChannel(Channel channel) {
return null;
}
}

View file

@ -31,6 +31,7 @@ import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollDomainSocketChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.erosion.netty.impl.AbstractUnixSocketListener;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPacketHandler;
@ -49,9 +50,9 @@ public final class UnixSocketClientListener extends AbstractUnixSocketListener {
initializeEventLoopGroup();
(new Bootstrap()
.channel(EpollDomainSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
.handler(new ChannelInitializer<>() {
@Override
protected void initChannel(Channel ch) {
protected void initChannel(@NonNull Channel ch) {
initPipeline(ch, handler);
}
})

View file

@ -34,7 +34,6 @@ import org.geysermc.event.subscribe.Subscribe;
import org.geysermc.geyser.api.event.EventBus;
import org.geysermc.geyser.api.event.EventRegistrar;
import org.geysermc.geyser.api.event.EventSubscriber;
import org.geysermc.geyser.api.extension.Extension;
import java.util.Set;
import java.util.function.BiConsumer;

View file

@ -31,7 +31,6 @@ import org.geysermc.event.PostOrder;
import org.geysermc.event.subscribe.impl.OwnedSubscriberImpl;
import org.geysermc.geyser.api.event.EventRegistrar;
import org.geysermc.geyser.api.event.ExtensionEventSubscriber;
import org.geysermc.geyser.api.extension.Extension;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

View file

@ -26,12 +26,11 @@
package org.geysermc.geyser.event.type;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.BedrockPong;
import org.geysermc.geyser.api.event.connection.GeyserBedrockPingEvent;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.net.InetSocketAddress;
import java.util.Objects;
@ -45,12 +44,12 @@ public class GeyserBedrockPingEventImpl implements GeyserBedrockPingEvent {
}
@Override
public void primaryMotd(@Nonnull String primary) {
public void primaryMotd(@NonNull String primary) {
pong.motd(Objects.requireNonNull(primary, "Primary MOTD cannot be null"));
}
@Override
public void secondaryMotd(@Nonnull String secondary) {
public void secondaryMotd(@NonNull String secondary) {
pong.subMotd(Objects.requireNonNull(secondary, "Secondary MOTD cannot be null"));
}
@ -87,7 +86,7 @@ public class GeyserBedrockPingEventImpl implements GeyserBedrockPingEvent {
}
@Override
public @NotNull InetSocketAddress address() {
public @NonNull InetSocketAddress address() {
return address;
}
}

View file

@ -51,7 +51,7 @@ public abstract class GeyserDefineCustomItemsEventImpl implements GeyserDefineCu
* @return a multimap of all the already registered custom items
*/
@Override
public Map<String, Collection<CustomItemData>> getExistingCustomItems() {
public @NonNull Map<String, Collection<CustomItemData>> getExistingCustomItems() {
return Collections.unmodifiableMap(this.customItems.asMap());
}
@ -61,7 +61,7 @@ public abstract class GeyserDefineCustomItemsEventImpl implements GeyserDefineCu
* @return the list of the already registered non-vanilla custom items
*/
@Override
public List<NonVanillaCustomItemData> getExistingNonVanillaCustomItems() {
public @NonNull List<NonVanillaCustomItemData> getExistingNonVanillaCustomItems() {
return Collections.unmodifiableList(this.nonVanillaCustomItems);
}

View file

@ -29,12 +29,11 @@ import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundRenameItemPacket;
import lombok.Getter;
import lombok.Setter;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.ItemUtils;
import javax.annotation.Nullable;
/**
* Used to determine if rename packets should be sent and stores
* the expected level cost for AnvilInventoryUpdater

View file

@ -27,12 +27,11 @@ package org.geysermc.geyser.inventory;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.InventoryTranslator;
import org.jetbrains.annotations.Range;
import javax.annotation.Nonnull;
/**
* Combination of {@link Inventory} and {@link PlayerInventory}
*/
@ -67,7 +66,7 @@ public class Container extends Inventory {
}
@Override
public void setItem(int slot, @Nonnull GeyserItemStack newItem, GeyserSession session) {
public void setItem(int slot, @NonNull GeyserItemStack newItem, GeyserSession session) {
if (slot < this.size) {
super.setItem(slot, newItem, session);
} else {

View file

@ -33,7 +33,7 @@ import org.geysermc.geyser.translator.inventory.Generic3X3InventoryTranslator;
public class Generic3X3Container extends Container {
/**
* Whether we need to set the container type as {@link org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType#DROPPER}.
*
* <p>
* Used at {@link Generic3X3InventoryTranslator#openInventory(GeyserSession, Inventory)}
*/
@Getter

View file

@ -40,7 +40,7 @@ import java.util.List;
public class GeyserEnchantOption {
private static final List<EnchantData> EMPTY = Collections.emptyList();
/**
* This: https://cdn.discordapp.com/attachments/613168850925649981/791030657169227816/unknown.png
* This <a href="https://cdn.discordapp.com/attachments/613168850925649981/791030657169227816/unknown.png">text</a>
* is controlled by the server.
* So, of course, we have to throw in some easter eggs. ;)
*/

View file

@ -28,18 +28,18 @@ package org.geysermc.geyser.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import lombok.Data;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
import javax.annotation.Nonnull;
@Data
public class GeyserItemStack {
public static final GeyserItemStack EMPTY = new GeyserItemStack(0, 0, null);
@ -64,7 +64,7 @@ public class GeyserItemStack {
this.netId = netId;
}
public static @Nonnull GeyserItemStack from(ItemStack itemStack) {
public static @NonNull GeyserItemStack from(ItemStack itemStack) {
return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getNbt());
}
@ -76,7 +76,7 @@ public class GeyserItemStack {
return isEmpty() ? 0 : amount;
}
public CompoundTag getNbt() {
public @Nullable CompoundTag getNbt() {
return isEmpty() ? null : nbt;
}
@ -96,7 +96,7 @@ public class GeyserItemStack {
return getItemStack(amount);
}
public ItemStack getItemStack(int newAmount) {
public @Nullable ItemStack getItemStack(int newAmount) {
return isEmpty() ? null : new ItemStack(javaId, newAmount, nbt);
}

View file

@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3i;
import lombok.Getter;
import lombok.Setter;
@ -40,7 +41,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
import org.jetbrains.annotations.Range;
import javax.annotation.Nonnull;
import java.util.Arrays;
@ToString
@ -126,7 +126,7 @@ public abstract class Inventory {
public abstract int getOffsetForHotbar(@Range(from = 0, to = 8) int slot);
public void setItem(int slot, @Nonnull GeyserItemStack newItem, GeyserSession session) {
public void setItem(int slot, @NonNull GeyserItemStack newItem, GeyserSession session) {
if (slot > this.size) {
session.getGeyser().getLogger().debug("Tried to set an item out of bounds! " + this);
return;

View file

@ -28,12 +28,11 @@ package org.geysermc.geyser.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import lombok.Getter;
import lombok.Setter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.session.GeyserSession;
import org.jetbrains.annotations.Range;
import javax.annotation.Nonnull;
public class PlayerInventory extends Inventory {
/**
* Stores the held item slot, starting at index 0.
@ -44,7 +43,7 @@ public class PlayerInventory extends Inventory {
private int heldItemSlot;
@Getter
@Nonnull
@NonNull
private GeyserItemStack cursor = GeyserItemStack.EMPTY;
public PlayerInventory() {
@ -57,12 +56,12 @@ public class PlayerInventory extends Inventory {
return slot + 36;
}
public void setCursor(@Nonnull GeyserItemStack newCursor, GeyserSession session) {
public void setCursor(@NonNull GeyserItemStack newCursor, GeyserSession session) {
updateItemNetId(cursor, newCursor, session);
cursor = newCursor;
}
public GeyserItemStack getItemInHand(@Nonnull Hand hand) {
public GeyserItemStack getItemInHand(@NonNull Hand hand) {
return hand == Hand.OFF_HAND ? getOffhand() : getItemInHand();
}
@ -74,7 +73,7 @@ public class PlayerInventory extends Inventory {
return items[36 + heldItemSlot];
}
public void setItemInHand(@Nonnull GeyserItemStack item) {
public void setItemInHand(@NonNull GeyserItemStack item) {
if (36 + heldItemSlot > this.size) {
GeyserImpl.getInstance().getLogger().debug("Held item slot was larger than expected!");
return;

View file

@ -27,8 +27,8 @@ package org.geysermc.geyser.inventory;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.session.GeyserSession;
public class StonecutterContainer extends Container {

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.inventory.item;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Locale;
@ -78,7 +79,7 @@ public enum Enchantment {
this.javaIdentifier = "minecraft:" + this.name().toLowerCase(Locale.ENGLISH);
}
public static Enchantment getByJavaIdentifier(String javaIdentifier) {
public static @Nullable Enchantment getByJavaIdentifier(String javaIdentifier) {
for (Enchantment enchantment : VALUES) {
if (enchantment.javaIdentifier.equals(javaIdentifier) || enchantment.name().toLowerCase(Locale.ENGLISH).equalsIgnoreCase(javaIdentifier)) {
return enchantment;
@ -87,7 +88,7 @@ public enum Enchantment {
return null;
}
public static Enchantment getByBedrockId(int bedrockId) {
public static @Nullable Enchantment getByBedrockId(int bedrockId) {
if (bedrockId >= 0 && bedrockId < VALUES.length) {
return VALUES[bedrockId];
}
@ -149,7 +150,7 @@ public enum Enchantment {
*/
public static final String[] ALL_JAVA_IDENTIFIERS;
public static JavaEnchantment getByJavaIdentifier(String javaIdentifier) {
public static @Nullable JavaEnchantment getByJavaIdentifier(String javaIdentifier) {
if (!javaIdentifier.startsWith("minecraft:")) {
javaIdentifier = "minecraft:" + javaIdentifier;
}

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.inventory.item;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Locale;
@ -84,7 +85,7 @@ public enum Potion {
this.bedrockId = (short) bedrockId;
}
public static Potion getByJavaIdentifier(String javaIdentifier) {
public static @Nullable Potion getByJavaIdentifier(String javaIdentifier) {
for (Potion potion : VALUES) {
if (potion.javaIdentifier.equals(javaIdentifier)) {
return potion;
@ -93,7 +94,7 @@ public enum Potion {
return null;
}
public static Potion getByBedrockId(int bedrockId) {
public static @Nullable Potion getByBedrockId(int bedrockId) {
for (Potion potion : VALUES) {
if (potion.bedrockId == bedrockId) {
return potion;

View file

@ -27,11 +27,11 @@ package org.geysermc.geyser.inventory.item;
import lombok.Getter;
import lombok.experimental.Accessors;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.type.ItemMapping;
import javax.annotation.Nonnull;
import java.util.Map;
/**
@ -70,7 +70,7 @@ public class StoredItemMappings {
this.writableBook = load(itemMappings, Items.WRITABLE_BOOK);
}
@Nonnull
@NonNull
private ItemMapping load(Map<Item, ItemMapping> itemMappings, Item item) {
ItemMapping mapping = itemMappings.get(item);
if (mapping == null) {

View file

@ -26,12 +26,13 @@
package org.geysermc.geyser.inventory.item;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Locale;
/**
* Potion identifiers and their respective Bedrock IDs used with arrows.
* https://minecraft.wiki/w/Arrow#Data_values
* <a href="https://minecraft.wiki/w/Arrow#Data_values">See here</a>
*/
@Getter
public enum TippedArrowPotion {
@ -93,7 +94,7 @@ public enum TippedArrowPotion {
this.javaColor = arrowParticleColor.getColor();
}
public static TippedArrowPotion getByJavaIdentifier(String javaIdentifier) {
public static @Nullable TippedArrowPotion getByJavaIdentifier(String javaIdentifier) {
for (TippedArrowPotion potion : VALUES) {
if (potion.javaIdentifier.equals(javaIdentifier)) {
return potion;
@ -102,7 +103,7 @@ public enum TippedArrowPotion {
return null;
}
public static TippedArrowPotion getByBedrockId(int bedrockId) {
public static @Nullable TippedArrowPotion getByBedrockId(int bedrockId) {
for (TippedArrowPotion potion : VALUES) {
if (potion.bedrockId == bedrockId) {
return potion;
@ -115,7 +116,7 @@ public enum TippedArrowPotion {
* @param color the potion color to look up
* @return the tipped arrow potion that most closely resembles that color.
*/
public static TippedArrowPotion getByJavaColor(int color) {
public static @Nullable TippedArrowPotion getByJavaColor(int color) {
for (TippedArrowPotion potion : VALUES) {
if (potion.javaColor == color) {
return potion;

View file

@ -64,7 +64,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
super.updateInventory(translator, session, inventory);
AnvilContainer anvilContainer = (AnvilContainer) inventory;
updateInventoryState(session, anvilContainer);
int targetSlot = getTargetSlot(session, anvilContainer);
int targetSlot = getTargetSlot(anvilContainer);
for (int i = 0; i < translator.size; i++) {
final int bedrockSlot = translator.javaSlotToBedrock(i);
if (bedrockSlot == 50)
@ -89,7 +89,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
updateInventoryState(session, anvilContainer);
int lastTargetSlot = anvilContainer.getLastTargetSlot();
int targetSlot = getTargetSlot(session, anvilContainer);
int targetSlot = getTargetSlot(anvilContainer);
if (targetSlot != javaSlot) {
// Update the requested slot
InventorySlotPacket slotPacket = new InventorySlotPacket();
@ -136,7 +136,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
* @param anvilContainer the anvil inventory
* @return the slot to change the repair cost
*/
private int getTargetSlot(GeyserSession session, AnvilContainer anvilContainer) {
private int getTargetSlot(AnvilContainer anvilContainer) {
GeyserItemStack input = anvilContainer.getInput();
GeyserItemStack material = anvilContainer.getMaterial();
@ -433,6 +433,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
return !Objects.equals(originalName, ItemUtils.getCustomName(anvilContainer.getResult().getNbt()));
}
@SuppressWarnings("SameParameterValue")
private int getTagIntValueOr(GeyserItemStack itemStack, String tagName, int defaultValue) {
if (itemStack.getNbt() != null) {
Tag tag = itemStack.getNbt().get(tagName);

View file

@ -30,15 +30,13 @@ import org.geysermc.geyser.api.util.TriState;
import java.util.OptionalInt;
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public record GeyserCustomItemOptions(TriState unbreakable,
OptionalInt customModelData,
OptionalInt damagePredicate,
boolean defaultItem) implements CustomItemOptions {
public GeyserCustomItemOptions(TriState unbreakable, OptionalInt customModelData, OptionalInt damagePredicate) {
this(unbreakable, customModelData, damagePredicate, false);
}
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public static class CustomItemOptionsBuilder implements CustomItemOptions.Builder {
private TriState unbreakable = TriState.NOT_SET;
private OptionalInt customModelData = OptionalInt.empty();

View file

@ -27,7 +27,6 @@ package org.geysermc.geyser.item;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.cloudburstmc.protocol.bedrock.data.inventory.ComponentItemData;
import org.cloudburstmc.protocol.bedrock.packet.StartGamePacket;
public record GeyserCustomMappingData(ComponentItemData componentItemData, ItemDefinition itemDefinition, String stringId, int integerId) {
}

View file

@ -32,11 +32,11 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.item.custom.CustomItemOptions;
import org.geysermc.geyser.api.item.custom.CustomRenderOffsets;
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
import org.jetbrains.annotations.NotNull;
import java.util.OptionalInt;
import java.util.Set;
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
@EqualsAndHashCode(callSuper = true)
@ToString
public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData implements NonVanillaCustomItemData {
@ -84,7 +84,7 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
}
@Override
public @NotNull String identifier() {
public @NonNull String identifier() {
return identifier;
}
@ -134,7 +134,7 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
}
@Override
public @NotNull OptionalInt creativeCategory() {
public @NonNull OptionalInt creativeCategory() {
return creativeCategory;
}

View file

@ -26,7 +26,6 @@
package org.geysermc.geyser.item.components;
import com.google.common.base.Suppliers;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item;
@ -66,14 +65,4 @@ public enum ToolTier {
public String toString() {
return this.name().toLowerCase(Locale.ROOT);
}
public static ToolTier getByName(@NonNull String name) {
String upperCase = name.toUpperCase(Locale.ROOT);
for (ToolTier tier : VALUES) {
if (tier.name().equals(upperCase)) {
return tier;
}
}
return null;
}
}

View file

@ -25,16 +25,14 @@
package org.geysermc.geyser.item.exception;
import java.io.Serial;
public class InvalidCustomMappingsFileException extends Exception {
public InvalidCustomMappingsFileException(Throwable cause) {
super(cause);
}
@Serial
private static final long serialVersionUID = 1L;
public InvalidCustomMappingsFileException(String message) {
super(message);
}
public InvalidCustomMappingsFileException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.inventory.item.TippedArrowPotion;
import org.geysermc.geyser.item.Items;
@ -38,7 +39,8 @@ public class ArrowItem extends Item {
super(javaIdentifier, builder);
}
public ItemStack translateToJava(ItemData itemData, ItemMapping mapping, ItemMappings mappings) {
@Override
public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
TippedArrowPotion tippedArrowPotion = TippedArrowPotion.getByBedrockId(itemData.getDamage());
ItemStack itemStack = super.translateToJava(itemData, mapping, mappings);
if (tippedArrowPotion != null) {

View file

@ -28,9 +28,9 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.MinecraftLocale;
import org.jetbrains.annotations.NotNull;
public class AxolotlBucketItem extends Item {
public AxolotlBucketItem(String javaIdentifier, Builder builder) {
@ -38,7 +38,7 @@ public class AxolotlBucketItem extends Item {
}
@Override
public void translateNbtToBedrock(@NotNull GeyserSession session, @NotNull CompoundTag tag) {
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
super.translateNbtToBedrock(session, tag);
// Bedrock Edition displays the properties of the axolotl. Java does not.

View file

@ -29,14 +29,13 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtList;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtType;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
@ -45,7 +44,7 @@ import static org.geysermc.erosion.util.BannerUtils.getJavaPatternTag;
public class BannerItem extends BlockItem {
/**
* Holds what a Java ominous banner pattern looks like.
*
* <p>
* Translating the patterns over to Bedrock does not work effectively, but Bedrock has a dedicated type for
* ominous banners that we set instead. This variable is used to detect Java ominous banner patterns, and apply
* the correct ominous banner pattern if Bedrock pulls the item from creative.
@ -86,7 +85,7 @@ public class BannerItem extends BlockItem {
* @param pattern Java edition pattern nbt
* @return The Bedrock edition format pattern nbt
*/
@Nonnull
@NonNull
private static NbtMap getBedrockBannerPattern(CompoundTag pattern) {
return NbtMap.builder()
.putInt("Color", 15 - (int) pattern.get("Color").getValue())
@ -121,7 +120,7 @@ public class BannerItem extends BlockItem {
}
@Override
public void translateNbtToBedrock(@NotNull GeyserSession session, @NotNull CompoundTag tag) {
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
super.translateNbtToBedrock(session, tag);
CompoundTag blockEntityTag = tag.remove("BlockEntityTag");
@ -137,7 +136,7 @@ public class BannerItem extends BlockItem {
}
@Override
public void translateNbtToJava(@NotNull CompoundTag tag, @NotNull ItemMapping mapping) {
public void translateNbtToJava(@NonNull CompoundTag tag, @NonNull ItemMapping mapping) {
super.translateNbtToJava(tag, mapping);
if (tag.get("Type") instanceof IntTag type && type.getValue() == 1) {

View file

@ -30,6 +30,7 @@ import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings;
@ -57,7 +58,7 @@ public class CompassItem extends Item {
}
@Override
public void translateNbtToBedrock(GeyserSession session, CompoundTag tag) {
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
super.translateNbtToBedrock(session, tag);
Tag lodestoneTag = tag.get("LodestoneTracked");
@ -77,7 +78,7 @@ public class CompassItem extends Item {
}
@Override
public ItemStack translateToJava(ItemData itemData, ItemMapping mapping, ItemMappings mappings) {
public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
if (mapping.getBedrockIdentifier().equals("minecraft:lodestone_compass")) {
// Revert the entry back to the compass
mapping = mappings.getStoredItems().compass();

View file

@ -28,11 +28,11 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
import org.jetbrains.annotations.Nullable;
public class CrossbowItem extends Item {
public CrossbowItem(String javaIdentifier, Builder builder) {

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.session.GeyserSession;
import java.util.ArrayList;
@ -39,7 +40,7 @@ public class EnchantedBookItem extends Item {
}
@Override
public void translateNbtToBedrock(GeyserSession session, CompoundTag tag) {
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
super.translateNbtToBedrock(session, tag);
List<Tag> newTags = new ArrayList<>();

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.session.GeyserSession;
public class FishingRodItem extends Item {
@ -36,7 +37,7 @@ public class FishingRodItem extends Item {
}
@Override
public void translateNbtToBedrock(GeyserSession session, CompoundTag tag) {
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
super.translateNbtToBedrock(session, tag);
// Fix damage inconsistency

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.registry.type.ItemMapping;
@ -71,7 +72,7 @@ public class GoatHornItem extends Item {
}
@Override
public ItemStack translateToJava(ItemData itemData, ItemMapping mapping, ItemMappings mappings) {
public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
ItemStack itemStack = super.translateToJava(itemData, mapping, mappings);
int damage = itemData.getDamage();

View file

@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.Identifier;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.inventory.item.Enchantment;
@ -99,8 +100,7 @@ public class Item {
return builder;
}
public ItemStack translateToJava(ItemData itemData, ItemMapping mapping, ItemMappings mappings) {
if (itemData == null) return null;
public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
if (itemData.getTag() == null) {
return new ItemStack(javaId, itemData.getCount(), new CompoundTag(""));
}
@ -206,7 +206,7 @@ public class Item {
}
}
protected final CompoundTag remapEnchantment(GeyserSession session, CompoundTag tag, CompoundTag rootTag) {
protected final @Nullable CompoundTag remapEnchantment(GeyserSession session, CompoundTag tag, CompoundTag rootTag) {
Tag javaEnchId = tag.get("id");
if (!(javaEnchId instanceof StringTag))
return null;

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession;
@ -35,7 +36,7 @@ public class MapItem extends Item {
}
@Override
public void translateNbtToBedrock(GeyserSession session, CompoundTag tag) {
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
super.translateNbtToBedrock(session, tag);
Tag mapId = tag.remove("map");
@ -49,7 +50,7 @@ public class MapItem extends Item {
}
@Override
public void translateNbtToJava(CompoundTag tag, ItemMapping mapping) {
public void translateNbtToJava(@NonNull CompoundTag tag, @NonNull ItemMapping mapping) {
super.translateNbtToJava(tag, mapping);
IntTag mapNameIndex = tag.remove("map_name_index");

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.GeyserImpl;
@ -69,7 +70,7 @@ public class PotionItem extends Item {
}
@Override
public ItemStack translateToJava(ItemData itemData, ItemMapping mapping, ItemMappings mappings) {
public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
Potion potion = Potion.getByBedrockId(itemData.getDamage());
ItemStack itemStack = super.translateToJava(itemData, mapping, mappings);
if (potion != null) {

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.level;
import com.github.steveice10.mc.protocol.data.game.level.map.MapIconType;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum BedrockMapIcon {
ICON_WHITE_ARROW(MapIconType.WHITE_ARROW, 0),
@ -87,7 +88,7 @@ public enum BedrockMapIcon {
* @param iconType A MapIconType
* @return The mapping for a BedrockMapIcon
*/
public static BedrockMapIcon fromType(MapIconType iconType) {
public static @Nullable BedrockMapIcon fromType(MapIconType iconType) {
for (BedrockMapIcon icon : VALUES) {
if (icon.iconType.equals(iconType)) {
return icon;

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.level;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.util.HSVLike;
import org.checkerframework.checker.nullness.qual.NonNull;
public enum FireworkColor {
BLACK(1973019),
@ -75,7 +76,7 @@ public enum FireworkColor {
* @return nearest named color. will always return a value
* @since 4.0.0
*/
private static FireworkColor nearestTo(final HSVLike any) {
private static @NonNull FireworkColor nearestTo(final HSVLike any) {
float matchedDistance = Float.MAX_VALUE;
FireworkColor match = VALUES[0];
for (final FireworkColor potential : VALUES) {

View file

@ -26,7 +26,7 @@
package org.geysermc.geyser.level;
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.session.cache.AdvancementsCache;
import org.geysermc.geyser.text.ChatColor;
@ -73,7 +73,7 @@ public class GeyserAdvancement {
return displayData != null && displayData.getFrameType() == Advancement.DisplayData.FrameType.CHALLENGE ? ChatColor.LIGHT_PURPLE : ChatColor.GREEN;
}
public String getRootId(AdvancementsCache advancementsCache) {
public @NonNull String getRootId(AdvancementsCache advancementsCache) {
if (rootId == null) {
if (this.advancement.getParentId() == null) {
// We are the root ID

View file

@ -31,6 +31,8 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
@ -39,9 +41,7 @@ import org.geysermc.erosion.util.BlockPositionIterator;
import org.geysermc.erosion.util.LecternUtils;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.BlockEntityUtils;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@ -99,6 +99,7 @@ public class GeyserWorldManager extends WorldManager {
return;
}
List<Vector3i> vectors = new ObjectArrayList<>(blockEntityInfos.size());
//noinspection ForLoopReplaceableByForEach - avoid constructing iterator
for (int i = 0; i < blockEntityInfos.size(); i++) {
BlockEntityInfo info = blockEntityInfos.get(i);
vectors.add(Vector3i.from(info.getX(), info.getY(), info.getZ()));
@ -171,7 +172,7 @@ public class GeyserWorldManager extends WorldManager {
return false;
}
@Nonnull
@NonNull
@Override
public CompletableFuture<@Nullable CompoundTag> getPickItemNbt(GeyserSession session, int x, int y, int z, boolean addNbtData) {
var erosionHandler = session.getErosionHandler().getAsActive();

View file

@ -29,12 +29,12 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3i;
import org.geysermc.erosion.util.BlockPositionIterator;
import org.geysermc.geyser.session.GeyserSession;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;
@ -107,7 +107,7 @@ public abstract class WorldManager {
*
* We solve this problem by querying all loaded lecterns, where possible, and sending their information in a block entity
* tag.
*
* <p>
* Note that the lectern data may be sent asynchronously.
*
* @param session the session of the player
@ -210,8 +210,7 @@ public abstract class WorldManager {
/**
* Returns a list of biome identifiers available on the server.
*/
@Nullable
public String[] getBiomeIdentifiers(boolean withTags) {
public String @Nullable [] getBiomeIdentifiers(boolean withTags) {
return null;
}
@ -220,7 +219,7 @@ public abstract class WorldManager {
*
* @return expected NBT for this item.
*/
@Nonnull
@NonNull
public CompletableFuture<@Nullable CompoundTag> getPickItemNbt(GeyserSession session, int x, int y, int z, boolean addNbtData) {
return CompletableFuture.completedFuture(null);
}

View file

@ -27,19 +27,14 @@ package org.geysermc.geyser.level.block;
/**
* This stores all values of double chests that are part of the Java block state.
*
* @param isFacingEast If true, then chest is facing east/west; if false, south/north
* @param isDirectionPositive If true, direction is positive (east/south); if false, direction is negative (west/north)
* @param isLeft If true, chest is the left of a pair; if false, chest is the right of a pair.
*/
public record DoubleChestValue(
/**
* If true, then chest is facing east/west; if false, south/north
*/
boolean isFacingEast,
/**
* If true, direction is positive (east/south); if false, direction is negative (west/north)
*/
boolean isDirectionPositive,
/**
* If true, chest is the left of a pair; if false, chest is the right of a pair.
*/
boolean isLeft) {
}

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.level.block;
import it.unimi.dsi.fastutil.objects.*;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.Constants;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.block.custom.CustomBlockData;
@ -37,9 +38,6 @@ import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents;
import org.geysermc.geyser.api.block.custom.property.CustomBlockProperty;
import org.geysermc.geyser.api.block.custom.property.PropertyType;
import org.geysermc.geyser.api.util.CreativeCategory;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
@ -142,7 +140,7 @@ public class GeyserCustomBlockData implements CustomBlockData {
}
@Override
public CustomBlockState.@NotNull Builder blockStateBuilder() {
public CustomBlockState.@NonNull Builder blockStateBuilder() {
return new GeyserCustomBlockState.CustomBlockStateBuilder(this);
}

View file

@ -54,7 +54,7 @@ public class GeyserCustomBlockState implements CustomBlockState {
@SuppressWarnings("unchecked")
@Override
public <T> @NonNull T property(String propertyName) {
public <T> @NonNull T property(@NonNull String propertyName) {
return (T) properties.get(propertyName);
}

View file

@ -52,7 +52,7 @@ public class GeyserJavaBlockState implements JavaBlockState {
}
@Override
public @NonNull boolean waterlogged() {
public boolean waterlogged() {
return waterlogged;
}
@ -62,7 +62,7 @@ public class GeyserJavaBlockState implements JavaBlockState {
}
@Override
public @NonNull boolean canBreakWithHand() {
public boolean canBreakWithHand() {
return canBreakWithHand;
}
@ -77,7 +77,7 @@ public class GeyserJavaBlockState implements JavaBlockState {
}
@Override
public @Nullable boolean hasBlockEntity() {
public boolean hasBlockEntity() {
return hasBlockEntity;
}
@ -118,7 +118,7 @@ public class GeyserJavaBlockState implements JavaBlockState {
}
@Override
public Builder waterlogged(@NonNull boolean waterlogged) {
public Builder waterlogged(boolean waterlogged) {
this.waterlogged = waterlogged;
return this;
}
@ -130,7 +130,7 @@ public class GeyserJavaBlockState implements JavaBlockState {
}
@Override
public Builder canBreakWithHand(@NonNull boolean canBreakWithHand) {
public Builder canBreakWithHand(boolean canBreakWithHand) {
this.canBreakWithHand = canBreakWithHand;
return this;
}
@ -148,7 +148,7 @@ public class GeyserJavaBlockState implements JavaBlockState {
}
@Override
public Builder hasBlockEntity(@Nullable boolean hasBlockEntity) {
public Builder hasBlockEntity(boolean hasBlockEntity) {
this.hasBlockEntity = hasBlockEntity;
return this;
}

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.level.chunk.bitarray;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.util.MathUtils;
public enum BitArrayVersion {
@ -61,7 +62,7 @@ public enum BitArrayVersion {
throw new IllegalArgumentException("Invalid palette version: " + version);
}
public static BitArrayVersion forBitsCeil(int bits) {
public static @Nullable BitArrayVersion forBitsCeil(int bits) {
for (int i = VALUES.length - 1; i >= 0; i--) {
BitArrayVersion version = VALUES[i];
if (version.bits >= bits) {
@ -79,10 +80,6 @@ public enum BitArrayVersion {
return maxEntryValue;
}
public int getWordsForSize(int size) {
return MathUtils.ceil((float) size / entriesPerWord);
}
public BitArrayVersion next() {
return next;
}

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.level.physics;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.GenericMath;
import org.cloudburstmc.math.vector.Vector3d;
import org.cloudburstmc.math.vector.Vector3f;
@ -133,7 +134,7 @@ public class CollisionManager {
* @param teleported whether the Bedrock player has teleported to a new position. If true, movement correction is skipped.
* @return the position to send to the Java server, or null to cancel sending the packet
*/
public Vector3d adjustBedrockPosition(Vector3f bedrockPosition, boolean onGround, boolean teleported) {
public @Nullable Vector3d adjustBedrockPosition(Vector3f bedrockPosition, boolean onGround, boolean teleported) {
PistonCache pistonCache = session.getPistonCache();
// Bedrock clients tend to fall off of honey blocks, so we need to teleport them to the new position
if (pistonCache.isPlayerAttachedToHoney()) {

Some files were not shown because too many files have changed in this diff Show more