diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-06-27 16:38:33 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-06-27 16:38:33 +0800 |
| commit | c0c2bd8d259b9ccc55d2111d806220753b9d89bd (patch) | |
| tree | 52059a5dd2bcc6320e750a48e1b1e4c22adebbca /default-plugin | |
| parent | f6b10e75179c8237cab172d757238d1404273187 (diff) | |
| download | RoughlyEnoughItems-c0c2bd8d259b9ccc55d2111d806220753b9d89bd.tar.gz RoughlyEnoughItems-c0c2bd8d259b9ccc55d2111d806220753b9d89bd.tar.bz2 RoughlyEnoughItems-c0c2bd8d259b9ccc55d2111d806220753b9d89bd.zip | |
Fix #572 & add getDraggableAcceptingBounds
Diffstat (limited to 'default-plugin')
3 files changed, 21 insertions, 11 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java index cfbfa0da2..ae38726c3 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java @@ -343,13 +343,13 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin Arrays.stream(GameType.values()) .filter(type -> type.getId() >= 0), Stream.of((GameType) null) - ).<FavoriteEntry>map(GameModeFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); + ).<FavoriteEntry>map(GameModeFavoriteEntry::new).toArray(FavoriteEntry[]::new)); registry.register(WeatherFavoriteEntry.ID, WeatherFavoriteEntry.Type.INSTANCE); registry.getOrCrateSection(new TranslatableComponent(WeatherFavoriteEntry.TRANSLATION_KEY)) .add(Stream.concat( Arrays.stream(WeatherFavoriteEntry.Weather.values()), Stream.of((WeatherFavoriteEntry.Weather) null) - ).<FavoriteEntry>map(WeatherFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); + ).<FavoriteEntry>map(WeatherFavoriteEntry::new).toArray(FavoriteEntry[]::new)); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java index c50590376..47d023529 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java @@ -24,6 +24,8 @@ package me.shedaniel.rei.plugin.client.favorites; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.Lifecycle; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; @@ -188,15 +190,18 @@ public class GameModeFavoriteEntry extends FavoriteEntry { INSTANCE; @Override - public GameModeFavoriteEntry read(CompoundTag object) { + public DataResult<GameModeFavoriteEntry> readResult(CompoundTag object) { String stringValue = object.getString(KEY); GameType type = stringValue.equals("NOT_SET") ? null : GameType.valueOf(stringValue); - return new GameModeFavoriteEntry(type); + return DataResult.success(new GameModeFavoriteEntry(type), Lifecycle.stable()); } @Override - public GameModeFavoriteEntry fromArgs(Object... args) { - return new GameModeFavoriteEntry((GameType) args[0]); + public DataResult<GameModeFavoriteEntry> fromArgsResult(Object... args) { + if (args.length == 0) return DataResult.error("Cannot create GameModeFavoriteEntry from empty args!"); + if (!(args[0] instanceof GameType type)) + return DataResult.error("Creation of GameModeFavoriteEntry from args expected GameType as the first argument!"); + return DataResult.success(new GameModeFavoriteEntry(type), Lifecycle.stable()); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java index 08786e341..55483ac53 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java @@ -25,6 +25,8 @@ package me.shedaniel.rei.plugin.client.favorites; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.Lifecycle; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; @@ -195,15 +197,18 @@ public class WeatherFavoriteEntry extends FavoriteEntry { INSTANCE; @Override - public WeatherFavoriteEntry read(CompoundTag object) { + public DataResult<WeatherFavoriteEntry> readResult(CompoundTag object) { String stringValue = object.getString(KEY); - Weather type = stringValue.equals("NOT_SET") ? null : Weather.valueOf(stringValue); - return new WeatherFavoriteEntry(type); + Weather weather = stringValue.equals("NOT_SET") ? null : Weather.valueOf(stringValue); + return DataResult.success(new WeatherFavoriteEntry(weather), Lifecycle.stable()); } @Override - public WeatherFavoriteEntry fromArgs(Object... args) { - return new WeatherFavoriteEntry((Weather) args[0]); + public DataResult<WeatherFavoriteEntry> fromArgsResult(Object... args) { + if (args.length == 0) return DataResult.error("Cannot create WeatherFavoriteEntry from empty args!"); + if (!(args[0] instanceof Weather weather)) + return DataResult.error("Creation of WeatherFavoriteEntry from args expected Weather as the first argument!"); + return DataResult.success(new WeatherFavoriteEntry(weather), Lifecycle.stable()); } @Override |
