From 9784e9f7228fc0aa3ca814e3830dbd81996a3693 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 15 Dec 2020 20:45:35 +0800 Subject: wip Signed-off-by: shedaniel --- .../main/java/me/shedaniel/rei/api/Renderer.java | 23 ++ .../rei/api/entry/AbstractEntryRenderer.java | 23 ++ .../shedaniel/rei/api/entry/AbstractRenderer.java | 23 ++ .../rei/api/entry/BatchEntryRenderer.java | 23 ++ .../shedaniel/rei/api/entry/BuiltinEntryTypes.java | 23 ++ .../shedaniel/rei/api/entry/ComparisonContext.java | 23 ++ .../shedaniel/rei/api/entry/EntryDefinition.java | 23 ++ .../me/shedaniel/rei/api/entry/EntryRenderer.java | 23 ++ .../me/shedaniel/rei/api/entry/EntryStacks.java | 23 ++ .../java/me/shedaniel/rei/api/entry/EntryType.java | 23 ++ .../shedaniel/rei/api/entry/EntryTypeBridge.java | 25 ++ .../shedaniel/rei/api/entry/EntryTypeRegistry.java | 26 ++ .../shedaniel/rei/api/entry/VanillaEntryTypes.java | 23 ++ .../shedaniel/rei/gui/config/AppearanceTheme.java | 1 + .../rei/gui/config/ConfigButtonPosition.java | 1 + .../rei/gui/config/DisplayPanelLocation.java | 1 + .../rei/gui/config/EntryPanelOrdering.java | 1 - .../rei/gui/config/ItemCheatingStyle.java | 3 +- .../rei/utils/EntryStackCompoundList.java | 23 ++ .../me/shedaniel/rei/utils/EntryStackList.java | 20 -- .../me/shedaniel/rei/plugin/DefaultPlugin.java | 12 +- .../plugin/favorites/GameModeFavoriteEntry.java | 13 +- .../rei/plugin/favorites/WeatherFavoriteEntry.java | 323 +++++++++++++++++++++ .../rei/gui/plugin/DefaultRuntimePlugin.java | 11 +- .../rei/gui/plugin/entry/FluidEntryDefinition.java | 23 ++ .../rei/gui/plugin/entry/ItemEntryDefinition.java | 23 ++ .../me/shedaniel/rei/gui/widget/EntryWidget.java | 2 +- .../rei/gui/widget/FavoritesListWidget.java | 84 ++++-- .../me/shedaniel/rei/impl/EntryTypeDeferred.java | 31 +- .../shedaniel/rei/impl/EntryTypeRegistryImpl.java | 25 ++ .../java/me/shedaniel/rei/impl/IssuesDetector.java | 23 ++ .../me/shedaniel/rei/impl/RecipeHelperImpl.java | 2 +- .../me/shedaniel/rei/impl/TypedEntryStack.java | 23 ++ .../rei/impl/entry/EmptyEntryDefinition.java | 31 +- build.gradle | 8 +- gradle.properties | 3 +- .../assets/roughlyenoughitems/lang/en_us.json | 6 +- 37 files changed, 922 insertions(+), 75 deletions(-) delete mode 100644 RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackList.java create mode 100644 RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/WeatherFavoriteEntry.java diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/Renderer.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/Renderer.java index f6a9c39ba..2c1b3d86d 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/Renderer.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/Renderer.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractEntryRenderer.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractEntryRenderer.java index 0fad3333a..bb0a6c556 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractEntryRenderer.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractEntryRenderer.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import net.minecraft.client.gui.GuiComponent; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractRenderer.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractRenderer.java index 23b90db65..a3a4d1a8a 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractRenderer.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/AbstractRenderer.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.rei.api.Renderer; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BatchEntryRenderer.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BatchEntryRenderer.java index 2384c2099..558b92638 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BatchEntryRenderer.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BatchEntryRenderer.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BuiltinEntryTypes.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BuiltinEntryTypes.java index a588bfa9f..d50267573 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BuiltinEntryTypes.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/BuiltinEntryTypes.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.rei.impl.Internals; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/ComparisonContext.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/ComparisonContext.java index 3afebbcba..8c7b7a0c2 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/ComparisonContext.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/ComparisonContext.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; public enum ComparisonContext { diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryDefinition.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryDefinition.java index fcc6085dc..4a97aa8a4 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryDefinition.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryDefinition.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.architectury.utils.Fraction; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryRenderer.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryRenderer.java index 2606f1b8f..8c9bbba58 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryRenderer.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryRenderer.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryStacks.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryStacks.java index f2123aa6e..0dd9ffa3d 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryStacks.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryStacks.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import com.google.common.collect.ImmutableList; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryType.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryType.java index 1bbd98071..0d4ebb2c2 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryType.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryType.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.rei.impl.Internals; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeBridge.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeBridge.java index 2d9ac1e1e..c15f85b4f 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeBridge.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeBridge.java @@ -1,11 +1,36 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.rei.api.EntryStack; import net.minecraft.world.InteractionResultHolder; +import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; @FunctionalInterface public interface EntryTypeBridge { + @NotNull InteractionResultHolder>> bridge(EntryStack object); } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeRegistry.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeRegistry.java index 689c6f99c..931a9a63e 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeRegistry.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeRegistry.java @@ -1,8 +1,32 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.rei.impl.Internals; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface EntryTypeRegistry { @NotNull @@ -18,7 +42,9 @@ public interface EntryTypeRegistry { void registerBridge(EntryType original, EntryType destination, EntryTypeBridge bridge); + @Nullable EntryDefinition get(ResourceLocation id); + @NotNull Iterable> getBridgesFor(EntryType original, EntryType destination); } \ No newline at end of file diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/VanillaEntryTypes.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/VanillaEntryTypes.java index 553698da4..047f33439 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/VanillaEntryTypes.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/entry/VanillaEntryTypes.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.entry; import me.shedaniel.architectury.fluid.FluidStack; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java index 89bd3db97..3fcba4383 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java @@ -37,6 +37,7 @@ public enum AppearanceTheme implements SelectionListEntry.Translatable { DARK; @Override + @NotNull public String getKey() { return I18n.get("config.roughlyenoughitems.theme." + name().toLowerCase(Locale.ROOT)); } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java index 1d82587d9..fe5641165 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java @@ -37,6 +37,7 @@ public enum ConfigButtonPosition implements SelectionListEntry.Translatable { LOWER; @Override + @NotNull public String getKey() { return I18n.get("config.roughlyenoughitems.layout.configButtonLocation." + name().toLowerCase(Locale.ROOT)); } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java index 3245b8533..92cc4cdb6 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java @@ -42,6 +42,7 @@ public enum DisplayPanelLocation implements SelectionListEntry.Translatable { } @Override + @NotNull public String getKey() { return I18n.get("config.roughlyenoughitems.accessibility.displayPanelLocation." + name().toLowerCase(Locale.ROOT)); } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java index 8b8626193..daf237e93 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java @@ -37,5 +37,4 @@ public enum EntryPanelOrdering { public String getNameTranslationKey() { return nameTranslationKey; } - } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ItemCheatingStyle.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ItemCheatingStyle.java index f04bba46a..46fd9db09 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ItemCheatingStyle.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/gui/config/ItemCheatingStyle.java @@ -37,7 +37,8 @@ public enum ItemCheatingStyle implements SelectionListEntry.Translatable { GIVE; @Override - public @NotNull String getKey() { + @NotNull + public String getKey() { return I18n.get("config.roughlyenoughitems.cheatingStyle." + name().toLowerCase(Locale.ROOT)); } } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackCompoundList.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackCompoundList.java index 6e1bd757d..5b09e7ad7 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackCompoundList.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackCompoundList.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.utils; import me.shedaniel.rei.api.EntryStack; diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackList.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackList.java deleted file mode 100644 index 15acbed64..000000000 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/EntryStackList.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.shedaniel.rei.utils; - -import me.shedaniel.rei.api.EntryStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collection; - -public class EntryStackList extends ArrayList> { - public EntryStackList(int initialCapacity) { - super(initialCapacity); - } - - public EntryStackList() { - } - - public EntryStackList(@NotNull Collection> c) { - super(c); - } -} diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java index c8da92e8a..ccb568637 100644 --- a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java @@ -56,6 +56,7 @@ import me.shedaniel.rei.plugin.crafting.DefaultCustomDisplay; import me.shedaniel.rei.plugin.crafting.DefaultShapedDisplay; import me.shedaniel.rei.plugin.crafting.DefaultShapelessDisplay; import me.shedaniel.rei.plugin.favorites.GameModeFavoriteEntry; +import me.shedaniel.rei.plugin.favorites.WeatherFavoriteEntry; import me.shedaniel.rei.plugin.fuel.DefaultFuelCategory; import me.shedaniel.rei.plugin.fuel.DefaultFuelDisplay; import me.shedaniel.rei.plugin.information.DefaultInformationCategory; @@ -423,7 +424,16 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin { FavoriteEntryType.registry().register(GameModeFavoriteEntry.ID, GameModeFavoriteEntry.Type.INSTANCE); FavoriteEntryType.registry().getOrCrateSection(new TranslatableComponent(GameModeFavoriteEntry.TRANSLATION_KEY)) - .add(Arrays.stream(GameType.values()).map(GameModeFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); + .add(Stream.concat( + Arrays.stream(GameType.values()), + Stream.of((GameType) null) + ).map(GameModeFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); + FavoriteEntryType.registry().register(WeatherFavoriteEntry.ID, WeatherFavoriteEntry.Type.INSTANCE); + FavoriteEntryType.registry().getOrCrateSection(new TranslatableComponent(WeatherFavoriteEntry.TRANSLATION_KEY)) + .add(Stream.concat( + Arrays.stream(WeatherFavoriteEntry.Weather.values()), + Stream.of((WeatherFavoriteEntry.Weather) null) + ).map(WeatherFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); } @Override diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/GameModeFavoriteEntry.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/GameModeFavoriteEntry.java index 0693f3753..f308b4614 100644 --- a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/GameModeFavoriteEntry.java +++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/GameModeFavoriteEntry.java @@ -60,7 +60,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry { public static final String TRANSLATION_KEY = "favorite.section.gamemode"; public static final String KEY = "mode"; @Nullable - private GameType gameMode; + private final GameType gameMode; public GameModeFavoriteEntry(@Nullable GameType gameMode) { this.gameMode = gameMode; @@ -120,13 +120,13 @@ public class GameModeFavoriteEntry extends FavoriteEntry { private void renderGameModeText(PoseStack matrices, GameType type, int centerX, int centerY, int color) { Component s = new TranslatableComponent("text.rei.short_gamemode." + type.getName()); Font font = Minecraft.getInstance().font; - font.draw(matrices, s, centerX - font.width(s) / 2 + (type == null ? 0 : 0.5f), centerY - 3.5f, color); + font.draw(matrices, s, centerX - font.width(s) / 2f + 1, centerY - 3.5f, color); } @Override public @Nullable Tooltip getTooltip(Point mouse) { if (gameMode == null) - return Tooltip.create(mouse, new TranslatableComponent("text.rei.gamemode_button.tooltip.all")); + return Tooltip.create(mouse, new TranslatableComponent("text.rei.gamemode_button.tooltip.dropdown")); return Tooltip.create(mouse, new TranslatableComponent("text.rei.gamemode_button.tooltip.entry", gameMode.getLongDisplayName().getString())); } }; @@ -135,10 +135,11 @@ public class GameModeFavoriteEntry extends FavoriteEntry { @Override public boolean doAction(int button) { if (button == 0) { - if (gameMode == null) { - gameMode = GameType.byId(Minecraft.getInstance().gameMode.getPlayerMode().getId() + 1 % 4); + GameType mode = gameMode; + if (mode == null) { + mode = GameType.byId(Minecraft.getInstance().gameMode.getPlayerMode().getId() + 1 % 4); } - Minecraft.getInstance().player.chat(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT))); + Minecraft.getInstance().player.chat(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", mode.name().toLowerCase(Locale.ROOT))); Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); return true; } diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/WeatherFavoriteEntry.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/WeatherFavoriteEntry.java new file mode 100644 index 000000000..f602af25b --- /dev/null +++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/WeatherFavoriteEntry.java @@ -0,0 +1,323 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.plugin.favorites; + +import com.google.gson.JsonObject; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.*; +import com.mojang.math.Matrix4f; +import me.shedaniel.clothconfig2.api.ScissorsHandler; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.ConfigObject; +import me.shedaniel.rei.api.REIHelper; +import me.shedaniel.rei.api.Renderer; +import me.shedaniel.rei.api.entry.AbstractRenderer; +import me.shedaniel.rei.api.favorites.FavoriteEntry; +import me.shedaniel.rei.api.favorites.FavoriteEntryType; +import me.shedaniel.rei.api.favorites.FavoriteMenuEntry; +import me.shedaniel.rei.api.widgets.Tooltip; +import me.shedaniel.rei.utils.CollectionUtils; +import net.minecraft.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.client.resources.sounds.SimpleSoundInstance; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.GsonHelper; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.function.Supplier; + +public class WeatherFavoriteEntry extends FavoriteEntry { + public static final ResourceLocation ID = new ResourceLocation("roughlyenoughitems", "weather"); + public static final String TRANSLATION_KEY = "favorite.section.weather"; + private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); + public static final String KEY = "type"; + @Nullable + private final Weather weather; + + public WeatherFavoriteEntry(@Nullable Weather weather) { + this.weather = weather; + } + + @Override + public boolean isInvalid() { + return false; + } + + @Override + public Renderer getRenderer(boolean showcase) { + return new AbstractRenderer() { + private Animator notSetOffset = new Animator(0); + private Rectangle notSetScissorArea = new Rectangle(); + private long nextSwitch = -1; + + @Override + public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; + if (bounds.width > 4 && bounds.height > 4) { + if (weather == null) { + matrices.pushPose(); + updateAnimator(delta); + notSetScissorArea.setBounds(bounds.x, bounds.y, bounds.width, bounds.height); +// ScissorsHandler.INSTANCE.scissor(notSetScissorArea); + int offset = Math.round(notSetOffset.floatValue() * bounds.getHeight()); + for (int i = 0; i <= 2; i++) { + Weather type = Weather.byId(i); + renderWeatherIcon(matrices, type, bounds.getCenterX(), bounds.getCenterY() + bounds.getHeight() * i - offset, color); + } +// ScissorsHandler.INSTANCE.removeLastScissor(); + matrices.popPose(); + } else { + renderWeatherIcon(matrices, weather, bounds.getCenterX(), bounds.getCenterY(), color); + } + } + } + + private void updateAnimator(float delta) { + notSetOffset.update(delta); + if (showcase) { + if (nextSwitch == -1) { + nextSwitch = Util.getMillis(); + } + if (Util.getMillis() - nextSwitch > 1000) { + nextSwitch = Util.getMillis(); + notSetOffset.setTo(((int) notSetOffset.target() + 1) % 3, 500); + } + } else { + notSetOffset.setTo((Minecraft.getInstance().gameMode.getPlayerMode().getId() + 1) % 3, 500); + } + } + + private void renderWeatherIcon(PoseStack matrices, Weather type, int centerX, int centerY, int color) { + Minecraft.getInstance().getTextureManager().bind(CHEST_GUI_TEXTURE); + Minecraft.getInstance().getTextureManager().bind(TextureAtlas.LOCATION_BLOCKS); + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + Matrix4f matrix = matrices.last().pose(); + float j = centerX - 6.5f; + float i = j + 14; + float k = centerY - 6.5f; + float l = k + 14; + float m = getZ(); + float f = type.getId() * 14 / 256f; + float g = f + 14 / 256f; + float h = 14 / 256f; + float n = h + 14 / 256f; + + BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder(); + bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + bufferBuilder.vertex(matrix, i, l, m).uv(f, n).endVertex(); + bufferBuilder.vertex(matrix, j, l, m).uv(g, n).endVertex(); + bufferBuilder.vertex(matrix, j, k, m).uv(g, h).endVertex(); + bufferBuilder.vertex(matrix, i, k, m).uv(f, h).endVertex(); + bufferBuilder.end(); + RenderSystem.enableAlphaTest(); + BufferUploader.end(bufferBuilder); + } + + @Override + public @Nullable Tooltip getTooltip(Point mouse) { + if (weather == null) + return Tooltip.create(mouse, new TranslatableComponent("text.rei.weather_button.tooltip.dropdown")); + return Tooltip.create(mouse, new TranslatableComponent("text.rei.weather_button.tooltip.entry", new TranslatableComponent(weather.getTranslateKey()))); + } + }; + } + + @Override + public boolean doAction(int button) { + if (button == 0) { + if (weather != null) { + Minecraft.getInstance().player.chat(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT))); + Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + } + return true; + } + return false; + } + + @Override + public @NotNull Optional>> getMenuEntries() { + if (weather == null) + return Optional.of(this::_getMenuEntries); + return Optional.empty(); + } + + private Collection _getMenuEntries() { + return CollectionUtils.map(Weather.values(), WeatherMenuEntry::new); + } + + @Override + public int hashIgnoreAmount() { + return weather == null ? -1 : weather.ordinal(); + } + + @Override + public FavoriteEntry copy() { + return this; + } + + @Override + public ResourceLocation getType() { + return ID; + } + + @Override + public boolean isSame(FavoriteEntry other) { + if (!(other instanceof WeatherFavoriteEntry)) return false; + WeatherFavoriteEntry that = (WeatherFavoriteEntry) other; + return Objects.equals(weather, that.weather); + } + + public enum Type implements FavoriteEntryType { + INSTANCE; + + @Override + public @NotNull WeatherFavoriteEntry fromJson(@NotNull JsonObject object) { + String stringValue = GsonHelper.getAsString(object, KEY); + Weather type = stringValue.equals("NOT_SET") ? null : Weather.valueOf(stringValue); + return new WeatherFavoriteEntry(type); + } + + @Override + public @NotNull WeatherFavoriteEntry fromArgs(Object... args) { + return new WeatherFavoriteEntry((Weather) args[0]); + } + + @Override + public @NotNull JsonObject toJson(@NotNull WeatherFavoriteEntry entry, @NotNull JsonObject object) { + object.addProperty(KEY, entry.weather == null ? "NOT_SET" : entry.weather.name()); + return object; + } + } + + @ApiStatus.Internal + public enum Weather { + CLEAR(0, "text.rei.weather.clear"), + RAIN(1, "text.rei.weather.rain"), + THUNDER(2, "text.rei.weather.thunder"); + + private final int id; + private final String translateKey; + + Weather(int id, String translateKey) { + this.id = id; + this.translateKey = translateKey; + } + + public static Weather byId(int id) { + return byId(id, CLEAR); + } + + public static Weather byId(int id, Weather defaultWeather) { + for (Weather weather : values()) { + if (weather.id == id) + return weather; + } + return defaultWeather; + } + + public int getId() { + return id; + } + + public String getTranslateKey() { + return translateKey; + } + } + + public static class WeatherMenuEntry extends FavoriteMenuEntry { + public final String text; + public final Weather weather; + private int x, y, width; + private boolean selected, containsMouse, rendering; + private int textWidth = -69; + + public WeatherMenuEntry(Weather weather) { + this.text = I18n.get(weather.getTranslateKey()); + this.weather = weather; + } + + private int getTextWidth() { + if (textWidth == -69) { + this.textWidth = Math.max(0, font.width(text)); + } + return this.textWidth; + } + + @Override + public int getEntryWidth() { + return getTextWidth() + 4; + } + + @Override + public int getEntryHeight() { + return 12; + } + + @Override + public List children() { + return Collections.emptyList(); + } + + @Override + public void updateInformation(int xPos, int yPos, boolean selected, boolean containsMouse, boolean rendering, int width) { + this.x = xPos; + this.y = yPos; + this.selected = selected; + this.containsMouse = containsMouse; + this.rendering = rendering; + this.width = width; + } + + @Override + public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + if (selected) { + fill(matrices, x, y, x + width, y + 12, -12237499); + } + if (selected && containsMouse) { + REIHelper.getInstance().queueTooltip(Tooltip.create(new TranslatableComponent("text.rei.weather_button.tooltip.entry", text))); + } + font.draw(matrices, text, x + 2, y + 2, selected ? 16777215 : 8947848); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) { + Minecraft.getInstance().player.chat(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT))); + minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + closeMenu(); + return true; + } + return super.mouseClicked(mouseX, mouseY, button); + } + } +} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java index 6e15e230c..fc0e911a6 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java @@ -30,17 +30,22 @@ import me.shedaniel.architectury.utils.Fraction; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.*; -import me.shedaniel.rei.api.entry.*; +import me.shedaniel.rei.api.entry.ComparisonContext; +import me.shedaniel.rei.api.entry.EntryStacks; +import me.shedaniel.rei.api.entry.EntryTypeRegistry; +import me.shedaniel.rei.api.entry.VanillaEntryTypes; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.fluid.FluidSupportProvider; import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.widgets.Panel; import me.shedaniel.rei.api.widgets.Tooltip; +import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.RecipeViewingScreen; import me.shedaniel.rei.gui.VillagerRecipeViewingScreen; import me.shedaniel.rei.gui.plugin.entry.FluidEntryDefinition; import me.shedaniel.rei.gui.plugin.entry.ItemEntryDefinition; +import me.shedaniel.rei.gui.widget.FavoritesListWidget; import me.shedaniel.rei.impl.ClientHelperImpl; import me.shedaniel.rei.impl.RenderingEntry; import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler; @@ -119,14 +124,14 @@ public class DefaultRuntimePlugin implements REIPluginV0 { return Collections.emptyList(); return Collections.singletonList(widget.getBounds().clone()); }); - /*baseBoundsHandler.registerExclusionZones(Screen.class, () -> { + baseBoundsHandler.registerExclusionZones(Screen.class, () -> { FavoritesListWidget widget = ContainerScreenOverlay.getFavoritesListWidget(); if (widget != null) { if (widget.favoritePanelButton.isVisible()) return Collections.singletonList(widget.favoritePanelButton.bounds); } return Collections.emptyList(); - });*/ + }); displayHelper.registerProvider(new DisplayHelper.DisplayBoundsProvider() { @Override public Rectangle getScreenBounds(RecipeViewingScreen screen) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java index de4658b36..9c7941985 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.gui.plugin.entry; import com.google.common.collect.Lists; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java index a1b8d6b38..4407563f3 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.gui.plugin.entry; import com.google.common.collect.Lists; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java index e345be523..6b236dfe7 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java @@ -283,7 +283,7 @@ public class EntryWidget extends Slot { } protected void drawCurrentEntry(PoseStack matrices, int mouseX, int mouseY, float delta) { - EntryStack entry = getCurrentEntry(); + EntryStack entry = getCurrentEntry(); entry.setZ(100); entry.render(matrices, getInnerBounds(), mouseX, mouseY, delta); } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java index fea93b2d5..04365980f 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -26,9 +26,11 @@ package me.shedaniel.rei.gui.widget; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.objects.ObjectIterator; import me.shedaniel.clothconfig2.ClothConfigInitializer; +import me.shedaniel.clothconfig2.api.LazyResettable; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.api.ScrollingContainer; import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget; @@ -39,6 +41,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; import me.shedaniel.rei.api.entry.BatchEntryRenderer; import me.shedaniel.rei.api.favorites.FavoriteEntry; +import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.favorites.FavoriteMenuEntry; import me.shedaniel.rei.api.widgets.Tooltip; import me.shedaniel.rei.gui.ContainerScreenOverlay; @@ -46,9 +49,14 @@ import me.shedaniel.rei.gui.modules.Menu; import me.shedaniel.rei.gui.modules.MenuEntry; import me.shedaniel.rei.impl.*; import me.shedaniel.rei.utils.CollectionUtils; +import me.shedaniel.rei.utils.ImmutableLiteralText; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.util.Mth; import net.minecraft.util.Tuple; import org.jetbrains.annotations.ApiStatus; @@ -91,9 +99,9 @@ public class FavoritesListWidget extends WidgetWithBounds { private List entriesList = Lists.newArrayList(); private List children = Lists.newArrayList(); private Entry lastTouchedEntry = null; - -// public final AddFavoritePanel favoritePanel = new AddFavoritePanel(this); -// public final ToggleAddFavoritePanelButton favoritePanelButton = new ToggleAddFavoritePanelButton(this); + + public final AddFavoritePanel favoritePanel = new AddFavoritePanel(this); + public final ToggleAddFavoritePanelButton favoritePanelButton = new ToggleAddFavoritePanelButton(this); private static Rectangle updateInnerBounds(Rectangle bounds) { int entrySize = entrySize(); @@ -114,9 +122,9 @@ public class FavoritesListWidget extends WidgetWithBounds { return true; } } else { -// if (favoritePanel.mouseScrolled(double_1, double_2, double_3)) { -// return true; -// } + if (favoritePanel.mouseScrolled(double_1, double_2, double_3)) { + return true; + } scrolling.offset(ClothConfigInitializer.getScrollStep() * -double_3, true); return true; } @@ -191,8 +199,8 @@ public class FavoritesListWidget extends WidgetWithBounds { } private void renderAddFavorite(PoseStack matrices, int mouseX, int mouseY, float delta) { -// this.favoritePanel.render(matrices, mouseX, mouseY, delta); -// this.favoritePanelButton.render(matrices, mouseX, mouseY, delta); + this.favoritePanel.render(matrices, mouseX, mouseY, delta); + this.favoritePanelButton.render(matrices, mouseX, mouseY, delta); } @Override @@ -278,15 +286,17 @@ public class FavoritesListWidget extends WidgetWithBounds { this.entriesList = Stream.concat(entries.values().stream().map(Entry::getWidget), removedEntries.values().stream().map(Entry::getWidget)).collect(Collectors.toList()); this.children = Stream.>of( entries.values().stream().map(Entry::getWidget), - removedEntries.values().stream().map(Entry::getWidget) -// Stream.of(favoritePanelButton, favoritePanel) + removedEntries.values().stream().map(Entry::getWidget), + Stream.of(favoritePanelButton, favoritePanel) ).flatMap(Function.identity()).collect(Collectors.toList()); } public void updateEntriesPosition(Predicate animated) { int entrySize = entrySize(); this.blockedCount = 0; - this.currentBounds.setBounds(this.fullBounds); + if (favoritePanel.getBounds().height > 20) + this.currentBounds.setBounds(this.fullBounds.x, this.fullBounds.y, this.fullBounds.width, this.fullBounds.height - (this.fullBounds.getMaxY() - this.favoritePanel.bounds.y) - 4); + else this.currentBounds.setBounds(this.fullBounds); this.innerBounds = updateInnerBounds(currentBounds); int width = innerBounds.width / entrySize; int currentX = 0; @@ -456,7 +466,7 @@ public class FavoritesListWidget extends WidgetWithBounds { break; } } - } /*else if (favoritePanel.bounds.contains(mouseX, mouseY)) { + } else if (favoritePanel.bounds.contains(mouseX, mouseY)) { back: for (AddFavoritePanel.Row row : favoritePanel.rows.get()) { if (row instanceof AddFavoritePanel.SectionEntriesRow) { @@ -476,7 +486,7 @@ public class FavoritesListWidget extends WidgetWithBounds { } } } - }*/ + } for (Widget widget : children()) if (widget.mouseClicked(mouseX, mouseY, int_1)) return true; @@ -561,6 +571,23 @@ public class FavoritesListWidget extends WidgetWithBounds { } } + private static EntryStack wrapRendererInStack(Renderer renderer) { + if (renderer instanceof EntryStack) { + return (EntryStack) renderer; + } + return new RenderingEntry() { + @Override + public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + renderer.render(matrices, bounds, mouseX, mouseY, delta); + } + + @Override + public @Nullable Tooltip getTooltip(Point mouse) { + return rende