From 364ccd53bb3ad3ea3521a00ca2bb48ec5814d31e Mon Sep 17 00:00:00 2001 From: Boy0000 Date: Sun, 11 Aug 2024 16:31:25 +0200 Subject: [PATCH] 1.180.0 (#1480) **[New]** - Add support for 1.21.1 **[Changes]** - Removed Gesture-feature **[Fixes]** - Placement of FIXED DisplayEntity furniture not being correct in some cases * Placed on walls, it would not lock to the wall but allow for 45 degree rotations * When limited_placing was used, would not correctly flip furniture on placed surface * Bad vertical offset when placed on floor - Breaking item with Durability-mechanic not triggering PlayerItemBreakEvent - Explosions destroying custom blocks in cases where they should not - Issues with FoodComponent on 1.20.5+ - Issues with Food-Mechanic on 1.20.4> - Issues with RecipeBuilders - Minor sound issues --- build.gradle.kts | 6 +- .../java/io/th0rgal/oraxen/OraxenPlugin.java | 9 - .../oraxen/commands/CommandsManager.java | 1 - .../oraxen/commands/GestureCommand.java | 56 --- .../oraxen/commands/ReloadCommand.java | 5 - .../oraxen/config/RemovedSettings.java | 1 + .../io/th0rgal/oraxen/config/Settings.java | 3 - .../io/th0rgal/oraxen/gestures/Gesture.java | 16 - .../oraxen/gestures/GestureListener.java | 54 --- .../oraxen/gestures/GestureManager.java | 428 ------------------ .../oraxen/gestures/GesturePaperListener.java | 2 - .../oraxen/gestures/OraxenPlayerModel.java | 52 --- .../th0rgal/oraxen/gestures/QuitMethod.java | 5 - .../io/th0rgal/oraxen/items/ItemBuilder.java | 5 + .../io/th0rgal/oraxen/items/ItemParser.java | 15 +- .../io/th0rgal/oraxen/items/ItemUpdater.java | 1 + .../durability/DurabilityMechanic.java | 13 +- .../durability/DurabilityMechanicManager.java | 7 +- .../gameplay/furniture/FurnitureMechanic.java | 32 +- .../limitedplacing/LimitedPlacing.java | 4 +- .../noteblock/NoteBlockMechanicListener.java | 4 + .../oraxen/pack/generation/ResourcePack.java | 13 - .../listeners/RecipesBuilderEvents.java | 13 +- .../io/th0rgal/oraxen/utils/BlockHelpers.java | 2 +- .../th0rgal/oraxen/utils/InventoryUtils.java | 23 +- .../oraxen/utils/MinecraftVersion.java | 2 + .../io/th0rgal/oraxen/utils/VersionUtil.java | 2 +- core/src/main/resources/settings.yml | 5 - gradle.properties | 2 +- 29 files changed, 85 insertions(+), 696 deletions(-) delete mode 100644 core/src/main/java/io/th0rgal/oraxen/commands/GestureCommand.java delete mode 100644 core/src/main/java/io/th0rgal/oraxen/gestures/Gesture.java delete mode 100644 core/src/main/java/io/th0rgal/oraxen/gestures/GestureListener.java delete mode 100644 core/src/main/java/io/th0rgal/oraxen/gestures/GestureManager.java delete mode 100644 core/src/main/java/io/th0rgal/oraxen/gestures/GesturePaperListener.java delete mode 100644 core/src/main/java/io/th0rgal/oraxen/gestures/OraxenPlayerModel.java delete mode 100644 core/src/main/java/io/th0rgal/oraxen/gestures/QuitMethod.java diff --git a/build.gradle.kts b/build.gradle.kts index dcd57f339..61503158d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,7 +35,7 @@ val devPluginPath = project.findProperty("oraxen_dev_plugin_path")?.toString() val foliaPluginPath = project.findProperty("oraxen_folia_plugin_path")?.toString() val spigotPluginPath = project.findProperty("oraxen_spigot_plugin_path")?.toString() val pluginVersion: String by project -val commandApiVersion = "9.5.1" +val commandApiVersion = "9.5.3" val adventureVersion = "4.17.0" val platformVersion = "4.3.3" val googleGsonVersion = "2.10.1" @@ -101,6 +101,7 @@ allprojects { compileOnly("nl.rutgerkok:blocklocker:1.10.4-SNAPSHOT") compileOnly("org.apache.commons:commons-lang3:$apacheLang3Version") + implementation("team.unnamed:creative-api:1.7.3") { exclude("net.kyori") } implementation("dev.jorel:commandapi-bukkit-shade:$commandApiVersion") implementation("org.bstats:bstats-bukkit:3.0.0") implementation("io.th0rgal:protectionlib:1.6.0") @@ -110,7 +111,6 @@ allprojects { implementation("com.jeff-media:persistent-data-serializer:1.0") implementation("org.jetbrains:annotations:24.1.0") { isTransitive = false } implementation("dev.triumphteam:triumph-gui:3.1.10") { exclude("net.kyori") } - implementation("com.ticxo:PlayerAnimator:R1.2.8") { isChanging = true } implementation("me.gabytm.util:actions-spigot:$actionsVersion") { exclude(group = "com.google.guava") } } @@ -215,8 +215,6 @@ bukkit { "net.kyori:adventure-platform-bukkit:$platformVersion", "com.google.code.gson:gson:$googleGsonVersion", "org.apache.commons:commons-lang3:$apacheLang3Version", - "team.unnamed:creative-api:1.7.3", - "team.unnamed:creative-serializer-minecraft:1.7.3", "gs.mclo:java:2.2.1", ) } diff --git a/core/src/main/java/io/th0rgal/oraxen/OraxenPlugin.java b/core/src/main/java/io/th0rgal/oraxen/OraxenPlugin.java index 66f63e873..521132f9b 100644 --- a/core/src/main/java/io/th0rgal/oraxen/OraxenPlugin.java +++ b/core/src/main/java/io/th0rgal/oraxen/OraxenPlugin.java @@ -1,7 +1,6 @@ package io.th0rgal.oraxen; import com.comphenix.protocol.ProtocolLibrary; -import com.ticxo.playeranimator.PlayerAnimatorImpl; import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPIBukkitConfig; import io.th0rgal.oraxen.api.OraxenItems; @@ -12,7 +11,6 @@ import io.th0rgal.oraxen.font.FontManager; import io.th0rgal.oraxen.font.packets.InventoryPacketListener; import io.th0rgal.oraxen.font.packets.TitlePacketListener; -import io.th0rgal.oraxen.gestures.GestureManager; import io.th0rgal.oraxen.hud.HudManager; import io.th0rgal.oraxen.items.ItemUpdater; import io.th0rgal.oraxen.mechanics.MechanicsManager; @@ -45,7 +43,6 @@ public class OraxenPlugin extends JavaPlugin { private static OraxenPlugin oraxen; - private static GestureManager gestureManager; private ConfigsManager configsManager; private ResourcesManager resourceManager; private BukkitAudiences audience; @@ -84,7 +81,6 @@ public void onLoad() { public void onEnable() { CommandAPI.onEnable(); ProtectionLib.init(this); - if (!VersionUtil.atOrAbove("1.20.3")) PlayerAnimatorImpl.initialize(this); audience = BukkitAudiences.create(this); clickActionManager = new ClickActionManager(this); supportsDisplayEntities = VersionUtil.atOrAbove("1.19.4"); @@ -109,7 +105,6 @@ public void onEnable() { hudManager = new HudManager(configsManager); fontManager = new FontManager(configsManager); soundManager = new SoundManager(configsManager.getSound()); - if (!VersionUtil.atOrAbove("1.20.3")) gestureManager = new GestureManager(); OraxenItems.loadItems(); fontManager.registerEvents(); fontManager.verifyRequired(); // Verify the required glyph is there @@ -155,10 +150,6 @@ public ResourcesManager getResourceManager() { return resourceManager; } - public GestureManager getGesturesManager() { - return gestureManager; - } - public BukkitAudiences getAudience() { return audience; } diff --git a/core/src/main/java/io/th0rgal/oraxen/commands/CommandsManager.java b/core/src/main/java/io/th0rgal/oraxen/commands/CommandsManager.java index e6257bc3c..dc1f74e19 100644 --- a/core/src/main/java/io/th0rgal/oraxen/commands/CommandsManager.java +++ b/core/src/main/java/io/th0rgal/oraxen/commands/CommandsManager.java @@ -37,7 +37,6 @@ public void loadCommands() { (new BlockInfoCommand()).getBlockInfoCommand(), (new HudCommand()).getHudCommand(), (new LogDumpCommand().getLogDumpCommand()), - (new GestureCommand().getGestureCommand()), (new VersionCommand()).getVersionCommand(), (new AdminCommand()).getAdminCommand()) .executes((sender, args) -> { diff --git a/core/src/main/java/io/th0rgal/oraxen/commands/GestureCommand.java b/core/src/main/java/io/th0rgal/oraxen/commands/GestureCommand.java deleted file mode 100644 index 84a7c507c..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/commands/GestureCommand.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.th0rgal.oraxen.commands; - -import dev.jorel.commandapi.CommandAPICommand; -import dev.jorel.commandapi.arguments.ArgumentSuggestions; -import dev.jorel.commandapi.arguments.PlayerArgument; -import dev.jorel.commandapi.arguments.StringArgument; -import io.th0rgal.oraxen.OraxenPlugin; -import io.th0rgal.oraxen.config.Message; -import io.th0rgal.oraxen.config.Settings; -import io.th0rgal.oraxen.gestures.GestureManager; -import io.th0rgal.oraxen.utils.AdventureUtils; -import io.th0rgal.oraxen.utils.VersionUtil; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.entity.Player; - -public class GestureCommand { - - CommandAPICommand getGestureCommand() { - GestureManager gestureManager = OraxenPlugin.get().getGesturesManager(); - - return new CommandAPICommand("gesture") - .withAliases("gestures", "g") - .withPermission("oraxen.command.gesture") - .withArguments( - new StringArgument("gesture").replaceSuggestions(ArgumentSuggestions.strings(GestureManager.getGestures())), - new PlayerArgument("player").setOptional(true) - ) - .executes((sender, args) -> { - if (!Settings.GESTURES_ENABLED.toBool() || VersionUtil.atOrAbove("1.20.3")) { - OraxenPlugin.get().getAudience().sender(sender).sendMessage(AdventureUtils.MINI_MESSAGE.deserialize("Gestures are not enabled!")); - return; - } - String gesture = (String) args.get("gesture"); - if (!GestureManager.gestures.contains(gesture)) { - Message.GESTURE_NO_GESTURE.send(sender); - return; - } - - if (args.count() == 1) { - if (sender instanceof Player player) { - gestureManager.playGesture(player, gesture); - } else if (sender instanceof ConsoleCommandSender console) { - Message.GESTURE_CONSOLE.send(console); - } - } else if (args.count() == 2) { - Player secondPlayer = (Player) args.get("player"); - if (secondPlayer == null) secondPlayer = (Player) sender; - if (secondPlayer != null) { - if (sender.hasPermission("oraxen.command.gesture.others")) { - gestureManager.playGesture(secondPlayer, gesture); - } else Message.GESTURE_OTHERS_DENIED.send(sender); - } else Message.NOT_PLAYER.send(sender); - } - }); - } -} diff --git a/core/src/main/java/io/th0rgal/oraxen/commands/ReloadCommand.java b/core/src/main/java/io/th0rgal/oraxen/commands/ReloadCommand.java index 44dd98111..e7c8e9c39 100644 --- a/core/src/main/java/io/th0rgal/oraxen/commands/ReloadCommand.java +++ b/core/src/main/java/io/th0rgal/oraxen/commands/ReloadCommand.java @@ -71,11 +71,6 @@ public static void reloadHud(@Nullable CommandSender sender) { hudManager.restartTask(); } - public static void reloadGestures(@Nullable CommandSender sender) { - Message.RELOAD.send(sender, AdventureUtils.tagResolver("reloaded", "gestures")); - OraxenPlugin.get().getGesturesManager().reload(); - } - public static void reloadRecipes(@Nullable CommandSender sender) { Message.RELOAD.send(sender, AdventureUtils.tagResolver("reloaded", "recipes")); RecipesManager.reload(); diff --git a/core/src/main/java/io/th0rgal/oraxen/config/RemovedSettings.java b/core/src/main/java/io/th0rgal/oraxen/config/RemovedSettings.java index 755766108..abbf831f8 100644 --- a/core/src/main/java/io/th0rgal/oraxen/config/RemovedSettings.java +++ b/core/src/main/java/io/th0rgal/oraxen/config/RemovedSettings.java @@ -24,6 +24,7 @@ public enum RemovedSettings { NMS_BLOCK_CORRECTION("Plugin.experimental.nms.block_correction"), SPIGOT_CHAT_FORMATTING("Plugin.experimental.spigot_chat_formatting"), ORAXEN_INV_TYPE("oraxen_inventory.main_menu_type"), + GESTURES_ENABLED("Gestures.enabled") ; diff --git a/core/src/main/java/io/th0rgal/oraxen/config/Settings.java b/core/src/main/java/io/th0rgal/oraxen/config/Settings.java index 0fc14568b..1541b7bd5 100644 --- a/core/src/main/java/io/th0rgal/oraxen/config/Settings.java +++ b/core/src/main/java/io/th0rgal/oraxen/config/Settings.java @@ -61,9 +61,6 @@ public enum Settings { CUSTOM_ARMOR_SHADER_GENERATE_CUSTOM_TEXTURES("CustomArmor.shader_settings.generate_custom_armor_textures"), CUSTOM_ARMOR_SHADER_GENERATE_SHADER_COMPATIBLE_ARMOR("CustomArmor.shader_settings.generate_shader_compatible_armor"), - - GESTURES_ENABLED("Gestures.enabled"), - // Custom Blocks BLOCK_CORRECTION("CustomBlocks.block_correction"), LEGACY_NOTEBLOCKS("CustomBlocks.use_legacy_noteblocks"), diff --git a/core/src/main/java/io/th0rgal/oraxen/gestures/Gesture.java b/core/src/main/java/io/th0rgal/oraxen/gestures/Gesture.java deleted file mode 100644 index 1921924b4..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/gestures/Gesture.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.th0rgal.oraxen.gestures; - -public class Gesture { - - private final String key; - private final boolean canLook; - private final boolean canMove; - private final QuitMethod quitMethod; - - public Gesture(String key, boolean canLook, boolean canMove, QuitMethod quitMethod) { - this.key = key; - this.canLook = canLook; - this.canMove = canMove; - this.quitMethod = quitMethod; - } -} diff --git a/core/src/main/java/io/th0rgal/oraxen/gestures/GestureListener.java b/core/src/main/java/io/th0rgal/oraxen/gestures/GestureListener.java deleted file mode 100644 index 54d38e6a6..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/gestures/GestureListener.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.th0rgal.oraxen.gestures; - -import com.destroystokyo.paper.event.player.PlayerJumpEvent; -import io.th0rgal.oraxen.OraxenPlugin; -import io.th0rgal.oraxen.utils.VersionUtil; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; - -public class GestureListener implements Listener { - - private final GestureManager gestureManager; - - public GestureListener(GestureManager gestureManager) { - this.gestureManager = gestureManager; - if (VersionUtil.isPaperServer()) - Bukkit.getPluginManager().registerEvents(new GesturePaperListener(), OraxenPlugin.get()); - } - - public class GesturePaperListener implements Listener { - - @EventHandler - public void onJump(PlayerJumpEvent event) { - quit(event.getPlayer(), QuitMethod.JUMP); - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - //PlayerAnimator.api.injectPlayer(event.getPlayer()); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - //PlayerAnimator.api.removePlayer(event.getPlayer()); - quit(event.getPlayer(), null); - } - - @EventHandler - public void onToggleSneak(PlayerToggleSneakEvent event) { - quit(event.getPlayer(), QuitMethod.SNEAK); - } - - private void quit(Player player, QuitMethod quitMethod) { - if(!gestureManager.isPlayerGesturing(player)) return; - gestureManager.getPlayerModel(player).stopAnimation(quitMethod); - } - - -} diff --git a/core/src/main/java/io/th0rgal/oraxen/gestures/GestureManager.java b/core/src/main/java/io/th0rgal/oraxen/gestures/GestureManager.java deleted file mode 100644 index dc5a95eb4..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/gestures/GestureManager.java +++ /dev/null @@ -1,428 +0,0 @@ -package io.th0rgal.oraxen.gestures; - -import com.ticxo.playeranimator.api.PlayerAnimator; -import com.ticxo.playeranimator.api.animation.pack.AnimationPack; -import io.th0rgal.oraxen.OraxenPlugin; -import io.th0rgal.oraxen.config.Settings; -import io.th0rgal.oraxen.utils.Utils; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.io.File; -import java.util.*; -import java.util.stream.Collectors; - -public class GestureManager { - private final Map gesturingPlayers; - - public GestureManager() { - gesturingPlayers = new HashMap<>(); - if (Settings.GESTURES_ENABLED.toBool()) { - loadGestures(); - Bukkit.getPluginManager().registerEvents(new GestureListener(this), OraxenPlugin.get()); - } - } - - public void playGesture(Player player, String gesture) { - if (isPlayerGesturing(player)) return; - OraxenPlayerModel model = new OraxenPlayerModel(player, QuitMethod.SNEAK, false, false); - addPlayerToGesturing(player, model); - model.playAnimation(gesture); - - } - - public void stopGesture(Player player) { - OraxenPlayerModel model = getPlayerModel(player); - if (model == null) return; - removePlayerFromGesturing(player); - model.despawn(); - } - - public boolean isPlayerGesturing(Player player) { - return gesturingPlayers.containsKey(player); - } - - public OraxenPlayerModel getPlayerModel(Player player) { - return gesturingPlayers.getOrDefault(player, null); - } - - public void addPlayerToGesturing(Player player, OraxenPlayerModel gesture) { - gesturingPlayers.put(player, gesture); - } - - public void removePlayerFromGesturing(Player player) { - gesturingPlayers.remove(player); - } - - public void loadGestures() { - PlayerAnimator.api.getAnimationManager().clearRegistry(); - gestures.clear(); - - File gestureDir = new File(OraxenPlugin.get().getDataFolder().getPath() + "/gestures/"); - if (!gestureDir.exists()) return; - File[] gestureFiles = gestureDir.listFiles(); - if (gestureFiles == null || gestureFiles.length == 0) return; - gestureFiles = Arrays.stream(gestureFiles).filter(f -> f.getPath().endsWith(".bbmodel")).distinct().toArray(File[]::new); - if (gestureFiles.length == 0) return; - for (File animationFile : gestureFiles) { - String animationKey = Utils.removeExtension(animationFile.getName()); - PlayerAnimator.api.getAnimationManager().importAnimations(animationKey, animationFile); - } - for (Map.Entry packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) { - Set animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet()); - gestures.addAll(animationNames); - } - } - - public static Set gestures = new HashSet<>(); - - public static Set getGestures() { - return gestures; - } - - public void reload() { - for (Map.Entry entry : gesturingPlayers.entrySet()) { - stopGesture(entry.getKey()); - gesturingPlayers.remove(entry.getKey()); - } - loadGestures(); - } - - public Map getPlayerHeadJsons() { - return Map.of( - "assets/minecraft/models/required/player/norm/arm.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1,-2,10],\"scale\":[0.46875,0.703125,0.46875]}}}", - "assets/minecraft/models/required/player/norm/left_shoulder.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1.625,-2,11.5],\"scale\":[0.46875,0.703125,0.46875]}}}", - "assets/minecraft/models/required/player/norm/right_shoulder.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-0.375,-2,11.5],\"scale\":[0.46875,0.703125,0.46875]}}}", - "assets/minecraft/models/required/player/slim/arm.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1,-2,10],\"scale\":[0.3515625,0.703125,0.46875]}}}", - "assets/minecraft/models/required/player/slim/left_shoulder.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1.40625,-2,11.5],\"scale\":[0.3515625,0.703125,0.46875]}}}", - "assets/minecraft/models/required/player/slim/right_shoulder.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-0.59375,-2,11.5],\"scale\":[0.3515625,0.703125,0.46875]}}}", - "assets/minecraft/models/required/player/body.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1,-2,13.75],\"scale\":[0.9375,0.46875,0.46875]}}}", - "assets/minecraft/models/required/player/head.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1,-2,17.5],\"scale\":[0.9375,0.9375,0.9375]}}}", - "assets/minecraft/models/required/player/leg.json", "{\"parent\":\"item/player_head\",\"display\":{\"thirdperson_righthand\":{\"rotation\":[90,180,0],\"translation\":[-1,-2,10],\"scale\":[0.46875,0.703125,0.46875]}}}" - ); - } - - public String getSkullJson() { - return """ - { - "parent": "minecraft:item/template_skull", - "overrides": [ - { "predicate": { "custom_model_data": 1 }, "model": "required/player/head" }, - { "predicate": { "custom_model_data": 2 }, "model": "required/player/norm/right_shoulder" }, - { "predicate": { "custom_model_data": 3 }, "model": "required/player/norm/left_shoulder" }, - { "predicate": { "custom_model_data": 4 }, "model": "required/player/norm/arm" }, - { "predicate": { "custom_model_data": 5 }, "model": "required/player/slim/right_shoulder" }, - { "predicate": { "custom_model_data": 6 }, "model": "required/player/slim/left_shoulder" }, - { "predicate": { "custom_model_data": 7 }, "model": "required/player/slim/arm" }, - { "predicate": { "custom_model_data": 8 }, "model": "required/player/body" }, - { "predicate": { "custom_model_data": 9 }, "model": "required/player/leg" } - ] - }"""; - } - - public String getShaderFsh() { - return """ - #version 150 - - #moj_import - - uniform sampler2D Sampler0; - - uniform vec4 ColorModulator; - uniform float FogStart; - uniform float FogEnd; - uniform vec4 FogColor; - - in float vertexDistance; - in vec4 vertexColor; - in vec4 lightMapColor; - in vec4 overlayColor; - in vec2 texCoord0; - in vec2 texCoord1; - in vec4 normal; - - in vec3 a, b; - - out vec4 fragColor; - - vec2 getSize() { - vec2 uv1 = a.xy / a.z; - vec2 uv2 = b.xy / b.z; - return round((max(uv1, uv2) - min(uv1, uv2)) * 64); - } - - void main() { - - if(texCoord0.x < 0) { - discard; - } - - vec2 uv = texCoord0; - if(getSize() != vec2(8, 8)) - uv = texCoord1; - - vec4 color = texture(Sampler0, uv); - if (color.a < 0.1) { - discard; - } - color *= vertexColor * ColorModulator; - color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); - color *= lightMapColor; - fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); - } - """; - } - - public String getShaderVsh() { - return """ - #version 150 - - #moj_import - #moj_import - - in vec3 Position, Normal; - in vec4 Color; - in vec2 UV0; - in ivec2 UV1, UV2; - - uniform sampler2D Sampler0, Sampler1, Sampler2; - - uniform mat4 ModelViewMat, ProjMat; - uniform int FogShape; - - uniform vec3 Light0_Direction, Light1_Direction; - - out float vertexDistance; - out vec4 vertexColor, lightMapColor, overlayColor, normal; - out vec2 texCoord0, texCoord1; - out vec3 a, b; - - vec3 getCubeSize(int cube) { - if(cube >= 2 && cube <= 7) - return vec3(8, 4, 4); - - if(cube >= 8 && cube <= 15) - return vec3(3, 6, 4); - - if(cube >= 16 && cube <= 23) - return vec3(4, 6, 4); - - return vec3(8, 8, 8); - } - - vec2 getBoxUV(int cube) { - switch(cube) { - case 0: // Head - return vec2(0, 0); - case 1: // Hat - return vec2(32, 0); - case 2: // Hip - case 4: // Waist - case 6: // Chest - return vec2(16, 16); - case 3: - case 5: - case 7: // Jacket - return vec2(16, 32); - case 8: - case 10: // Right Arm - return vec2(40, 16); - case 9: - case 11: // Right Sleeve - return vec2(40, 32); - case 12: - case 14: // Left Arm - return vec2(32, 48); - case 13: - case 15: // Left Sleeve - return vec2(48, 48); - case 16: - case 18: // Right Leg - return vec2(0, 16); - case 17: - case 19: // Right Pant - return vec2(0, 32); - case 20: - case 22: // Left Leg - return vec2(16, 48); - case 21: - case 23: // Left Pant - return vec2(0, 48); - - } - return vec2(0, 0); - } - - float getYOffset(int cube) { - float r = 0; - switch(cube) { - case 2: - case 3: - r = 8; - break; - case 4: - case 5: - r = 4; - break; - case 10: // Right Arm - case 11: // Right Sleeve - case 14: // Left Arm - case 15: // Left Sleeve - case 18: // Right Leg - case 19: // Right Pant - case 22: // Left Leg - case 23: // Left Pant - r = 6; - break; - } - return r / 64.; - } - - vec2 getUVOffset(int corner, vec3 cubeSize, float yOffset) { - vec2 offset, uv; - switch(corner / 4) { - case 0: // Up - offset = vec2(cubeSize.z, 0); - uv = vec2(cubeSize.x, cubeSize.z); - break; - case 1: // Down - offset = vec2(cubeSize.z + cubeSize.x, 0); - uv = vec2(cubeSize.x, cubeSize.z); - break; - case 2: // Right - offset = vec2(0, cubeSize.z); - offset.y += yOffset; - uv = vec2(cubeSize.z, cubeSize.y); - break; - case 3: // Front - offset = vec2(cubeSize.z, cubeSize.z); - offset.y += yOffset; - uv = vec2(cubeSize.x, cubeSize.y); - break; - case 4: // Left - offset = vec2(cubeSize.z + cubeSize.x, cubeSize.z); - offset.y += yOffset; - uv = vec2(cubeSize.z, cubeSize.y); - break; - case 5: // Back - offset = vec2(2 * cubeSize.z + cubeSize.x, cubeSize.z); - offset.y += yOffset; - uv = vec2(cubeSize.x, cubeSize.y); - break; - } - - switch(corner % 4) { - case 0: - offset += vec2(uv.x, 0); - break; - case 2: - offset += vec2(0, uv.y); - break; - case 3: - offset += vec2(uv.x, uv.y); - break; - } - - return offset; - } - - bool shouldRender(int cube, int corner) { - if(corner / 8 != 1 || cube % 2 == 0 || cube == 1) - return true; - - if(cube == 5) - return false; - - bool r = false; - switch(cube) { - case 7: - case 9: - case 13: - case 17: - case 21: - r = true; - } - - if(corner / 4 == 3) - r = !r; - - return r; - } - - void main() { - gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); - - a = b = vec3(0); - if(textureSize(Sampler0, 0) == vec2(64, 64) && UV0.y <= 0.25 && (gl_VertexID / 24 != 6 || UV0.x <= 0.5)) { - - switch(gl_VertexID % 4) { - case 0: a = vec3(UV0, 1); break; - case 2: b = vec3(UV0, 1); break; - } - // 1 3 5 9 11 13 15 17 - int cube = (gl_VertexID / 24) % 24; - int corner = gl_VertexID % 24; - if(shouldRender(cube, corner)) { - vec3 cubeSize = getCubeSize(cube) / 64; - vec2 boxUV = getBoxUV(cube) / 64; - vec2 uvOffset = getUVOffset(corner, cubeSize, getYOffset(cube)); - texCoord0 = boxUV + uvOffset; - }else { - texCoord0 = vec2(-1); - } - }else { - texCoord0 = UV0; - } - - // vertexDistance = fog_distance(ModelViewMat, IViewRotMat * Position, FogShape); - vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); - vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); - lightMapColor = texelFetch(Sampler2, UV2 / 16, 0); - overlayColor = texelFetch(Sampler1, UV1, 0); - texCoord1 = UV0; - normal = ProjMat * ModelViewMat * vec4(Normal, 0.0); - } - - - """; - } - - public String getShaderJson() { - return """ - { - "blend": { - "func": "add", - "srcrgb": "srcalpha", - "dstrgb": "1-srcalpha" - }, - "vertex": "rendertype_entity_translucent", - "fragment": "rendertype_entity_translucent", - "attributes": [ - "Position", - "Color", - "UV0", - "UV1", - "UV2", - "Normal" - ], - "samplers": [ - { "name": "Sampler0" }, - { "name": "Sampler1" }, - { "name": "Sampler2" } - ], - "uniforms": [ - { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, - { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, - { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, - { "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, - { "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, - { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, - { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, - { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, - { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } - ] - } - - """; - } -} diff --git a/core/src/main/java/io/th0rgal/oraxen/gestures/GesturePaperListener.java b/core/src/main/java/io/th0rgal/oraxen/gestures/GesturePaperListener.java deleted file mode 100644 index 7f8b33fc7..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/gestures/GesturePaperListener.java +++ /dev/null @@ -1,2 +0,0 @@ -package io.th0rgal.oraxen.gestures; - diff --git a/core/src/main/java/io/th0rgal/oraxen/gestures/OraxenPlayerModel.java b/core/src/main/java/io/th0rgal/oraxen/gestures/OraxenPlayerModel.java deleted file mode 100644 index 92237c109..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/gestures/OraxenPlayerModel.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.th0rgal.oraxen.gestures; - -import com.ticxo.playeranimator.api.model.player.PlayerModel; -import io.th0rgal.oraxen.OraxenPlugin; -import org.bukkit.entity.Player; - -public class OraxenPlayerModel extends PlayerModel { - private final QuitMethod quitMethod; - private final boolean canLook; - private final boolean canMove; - private final float lockedYaw; - private boolean isPlaying; - - public OraxenPlayerModel(Player player, QuitMethod quitMethod, boolean canLook, boolean canMove) { - super(player); - this.quitMethod = quitMethod; - this.canLook = canLook; - this.canMove = canMove; - this.lockedYaw = !canLook ? player.getLocation().getYaw() : super.getBaseYaw(); - } - - public void stopAnimation(QuitMethod quitMethod) { - isPlaying = quitMethod == null || this.quitMethod != quitMethod; - OraxenPlugin.get().getGesturesManager().removePlayerFromGesturing(getPlayer()); - getPlayer().setInvisible(false); - } - - @Override - public void playAnimation(String name) { - super.playAnimation(name); - getPlayer().setInvisible(true); - isPlaying = true; - } - - @Override - public boolean update() { - boolean update = (super.update() && isPlaying); - if (!update) { - stopAnimation(null); - } - return update; - } - - @Override - public float getBaseYaw() { - return canLook ? super.getBaseYaw() : lockedYaw; - } - - public Player getPlayer() { - return (Player) this.getBase(); - } -} diff --git a/core/src/main/java/io/th0rgal/oraxen/gestures/QuitMethod.java b/core/src/main/java/io/th0rgal/oraxen/gestures/QuitMethod.java deleted file mode 100644 index 9b5847068..000000000 --- a/core/src/main/java/io/th0rgal/oraxen/gestures/QuitMethod.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.th0rgal.oraxen.gestures; - -public enum QuitMethod { - SNEAK, JUMP -} diff --git a/core/src/main/java/io/th0rgal/oraxen/items/ItemBuilder.java b/core/src/main/java/io/th0rgal/oraxen/items/ItemBuilder.java index 3c5e3c038..233792428 100644 --- a/core/src/main/java/io/th0rgal/oraxen/items/ItemBuilder.java +++ b/core/src/main/java/io/th0rgal/oraxen/items/ItemBuilder.java @@ -273,6 +273,11 @@ public ItemBuilder setUnstackable(final boolean unstackable) { return this; } + @Nullable + public Integer getDurability() { + return durability; + } + public ItemBuilder setDurability(@Nullable Integer durability) { this.durability = durability; return this; diff --git a/core/src/main/java/io/th0rgal/oraxen/items/ItemParser.java b/core/src/main/java/io/th0rgal/oraxen/items/ItemParser.java index 8ea7c3bdc..ed2ae4368 100644 --- a/core/src/main/java/io/th0rgal/oraxen/items/ItemParser.java +++ b/core/src/main/java/io/th0rgal/oraxen/items/ItemParser.java @@ -251,18 +251,19 @@ private void parseFoodComponent(ItemBuilder item, @NotNull ConfigurationSection ConfigurationSection effectsSection = foodSection.getConfigurationSection("effects"); if (effectsSection != null) for (String effect : effectsSection.getKeys(false)) { + ConfigurationSection effectSection = effectsSection.getConfigurationSection(effect); PotionEffectType effectType = PotionUtils.getEffectType(effect); - if (effectType == null) + if (effectSection == null || effectType == null) Logs.logError("Invalid potion effect: " + effect + ", in " + StringUtils.substringBefore(effectsSection.getCurrentPath(), ".") + " food-property!"); else { foodComponent.addEffect( new PotionEffect(effectType, - foodSection.getInt("duration", 1) * 20, - foodSection.getInt("amplifier", 0), - foodSection.getBoolean("ambient", true), - foodSection.getBoolean("show_particles", true), - foodSection.getBoolean("show_icon", true)), - (float) foodSection.getDouble("probability", 1.0) + effectSection.getInt("duration", 1) * 20, + effectSection.getInt("amplifier", 0), + effectSection.getBoolean("ambient", true), + effectSection.getBoolean("show_particles", true), + effectSection.getBoolean("show_icon", true)), + (float) effectSection.getDouble("probability", 1.0) ); } } diff --git a/core/src/main/java/io/th0rgal/oraxen/items/ItemUpdater.java b/core/src/main/java/io/th0rgal/oraxen/items/ItemUpdater.java index 48b960f4a..fdbd0e564 100644 --- a/core/src/main/java/io/th0rgal/oraxen/items/ItemUpdater.java +++ b/core/src/main/java/io/th0rgal/oraxen/items/ItemUpdater.java @@ -121,6 +121,7 @@ public void onUseMaxDamageItem(EntityDamageByEntityEvent event) { @EventHandler(ignoreCancelled = true) public void onUseConvertedTo(PlayerItemConsumeEvent event) { ItemStack itemStack = event.getItem(); + if (!VersionUtil.atOrAbove("1.21")) return; if (!itemStack.hasItemMeta() || !itemStack.getItemMeta().hasFood()) return; ItemStack usingConvertsTo = itemStack.getItemMeta().getFood().getUsingConvertsTo(); if (usingConvertsTo == null || !itemStack.isSimilar(ItemUpdater.updateItem(usingConvertsTo))) return; diff --git a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanic.java b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanic.java index 9296ee73e..740bb5620 100644 --- a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanic.java +++ b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanic.java @@ -3,13 +3,17 @@ import io.th0rgal.oraxen.OraxenPlugin; import io.th0rgal.oraxen.mechanics.Mechanic; import io.th0rgal.oraxen.mechanics.MechanicFactory; +import io.th0rgal.oraxen.utils.EventUtils; import io.th0rgal.oraxen.utils.ItemUtils; import org.bukkit.NamespacedKey; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerItemBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; +import org.jetbrains.annotations.NotNull; import java.util.concurrent.atomic.AtomicBoolean; @@ -38,7 +42,7 @@ public int getItemDurability(ItemStack item) { return damageable.getPersistentDataContainer().getOrDefault(DURABILITY_KEY, PersistentDataType.INTEGER, 0); } - public boolean changeDurability(ItemStack item, int amount) { + public boolean changeDurability(@NotNull Player player, ItemStack item, int amount) { DurabilityMechanic durabilityMechanic = this; AtomicBoolean check = new AtomicBoolean(false); @@ -59,13 +63,16 @@ public boolean changeDurability(ItemStack item, int amount) { (int) (realMaxDurab - (((double) damageable.getDamage() / (double) baseMaxDurab) * realMaxDurab))); item.setItemMeta(itemMeta); // Call function again to have itemmeta stick and run below part aswell - changeDurability(item, amount); + changeDurability(player, item, amount); } else { realDurabRemain = realDurabRemain + amount; if (realDurabRemain > 0) { pdc.set(DURABILITY_KEY, PersistentDataType.INTEGER, realDurabRemain); (damageable).setDamage((int) ((double) baseMaxDurab - (((double) realDurabRemain / realMaxDurab) * (double) baseMaxDurab))); - } else item.setAmount(0); + } else { + EventUtils.callEvent(new PlayerItemBreakEvent(player, item)); + item.setAmount(0); + } } } } diff --git a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanicManager.java b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanicManager.java index ea154c52c..953b6ea40 100644 --- a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanicManager.java +++ b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/durability/DurabilityMechanicManager.java @@ -1,6 +1,7 @@ package io.th0rgal.oraxen.mechanics.provided.gameplay.durability; import io.th0rgal.oraxen.api.OraxenItems; +import io.th0rgal.oraxen.utils.InventoryUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -22,14 +23,14 @@ public DurabilityMechanicManager(DurabilityMechanicFactory factory) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemDamaged(PlayerItemDamageEvent event) { DurabilityMechanic mechanic = factory.getMechanic(event.getItem()); - if (mechanic == null || !mechanic.changeDurability(event.getItem(), -event.getDamage())) return; + if (mechanic == null || !mechanic.changeDurability(event.getPlayer(), event.getItem(), -event.getDamage())) return; event.setDamage(0); } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemMend(PlayerItemMendEvent event) { DurabilityMechanic mechanic = factory.getMechanic(OraxenItems.getIdByItem(event.getItem())); - if (mechanic == null || !mechanic.changeDurability(event.getItem(), event.getRepairAmount())) return; + if (mechanic == null || !mechanic.changeDurability(event.getPlayer(), event.getItem(), event.getRepairAmount())) return; event.setRepairAmount(0); } @@ -55,7 +56,7 @@ public void onItemRepair(PrepareAnvilEvent event) { DurabilityMechanic resultMechanic = factory.getMechanic(OraxenItems.getIdByItem(resultItem)); if (resultMechanic == null) return; - resultMechanic.changeDurability(resultItem, repairAmount); + resultMechanic.changeDurability(InventoryUtils.playerFromView(event), resultItem, repairAmount); event.setResult(resultItem); } } diff --git a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/furniture/FurnitureMechanic.java b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/furniture/FurnitureMechanic.java index c6578d40a..7bf1a8d38 100644 --- a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/furniture/FurnitureMechanic.java +++ b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/furniture/FurnitureMechanic.java @@ -9,7 +9,6 @@ import io.th0rgal.oraxen.api.OraxenFurniture; import io.th0rgal.oraxen.api.OraxenItems; import io.th0rgal.oraxen.compatibilities.provided.blocklocker.BlockLockerMechanic; -import io.th0rgal.oraxen.items.ItemBuilder; import io.th0rgal.oraxen.mechanics.Mechanic; import io.th0rgal.oraxen.mechanics.MechanicFactory; import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.evolution.EvolvingFurniture; @@ -393,9 +392,13 @@ private Location correctedSpawnLocation(Location baseLocation, BlockFace facing) if (displayEntityProperties.getDisplayTransform() != ItemDisplay.ItemDisplayTransform.NONE && !isWall && !isRoof) return correctedLocation; float scale = displayEntityProperties.hasScale() ? displayEntityProperties.getScale().y() : 1; // Since roof-furniture need to be more or less flipped, we have to add 0.5 (0.49 or it is "inside" the block above) to the Y coordinate - if (isFixed && isWall) correctedLocation.add(-facing.getModX() * (0.49 * scale), 0, -facing.getModZ() * (0.49 * scale)); - float heightCorrection = (hasHitbox() ? hitbox.height : 1) - 1; - return correctedLocation.add(0, (0.5 * scale) + (isRoof ? isFixed ? 0.49 : -1 * heightCorrection : 0), 0); + if (isFixed && isWall && facing.getModY() == 0) correctedLocation.add(-facing.getModX() * (0.49 * scale), 0, -facing.getModZ() * (0.49 * scale)); + + float hitboxOffset = (hasHitbox() ? hitbox.height : 1) - 1; + double yCorrection = (facing != BlockFace.UP ? (0.5 * scale) : 0); + yCorrection += ((isRoof && facing == BlockFace.DOWN) ? isFixed ? 0.49 : -1 * hitboxOffset : 0); + + return correctedLocation.add(0, yCorrection, 0); } public void setEntityData(Entity entity, float yaw, BlockFace facing) { @@ -423,7 +426,7 @@ public void setEntityData(Entity entity, float yaw, ItemStack item, BlockFace fa if (light.hasLightLevel()) light.createBlockLight(block); } } else if (entity instanceof ItemDisplay itemDisplay) { - setItemDisplayData(itemDisplay, item, yaw, displayEntityProperties); + setItemDisplayData(itemDisplay, item, yaw, displayEntityProperties, facing); float width = hasHitbox() ? hitbox.width : displayEntityProperties.getDisplayWidth(); float height = hasHitbox() ? hitbox.height : displayEntityProperties.getDisplayHeight(); boolean isFixed = displayEntityProperties.getDisplayTransform() == ItemDisplay.ItemDisplayTransform.FIXED; @@ -476,16 +479,14 @@ private void setBaseFurnitureData(Entity entity) { } } - private void setItemDisplayData(ItemDisplay itemDisplay, ItemStack item, Float yaw, DisplayEntityProperties properties) { + private void setItemDisplayData(ItemDisplay itemDisplay, ItemStack item, Float yaw, DisplayEntityProperties properties, BlockFace facing) { itemDisplay.setItemDisplayTransform(properties.getDisplayTransform()); if (properties.hasSpecifiedViewRange()) itemDisplay.setViewRange(properties.getViewRange()); - if (properties.hasInterpolationDuration()) - itemDisplay.setInterpolationDuration(properties.getInterpolationDuration()); + if (properties.hasInterpolationDuration()) itemDisplay.setInterpolationDuration(properties.getInterpolationDuration()); if (properties.hasInterpolationDelay()) itemDisplay.setInterpolationDelay(properties.getInterpolationDelay()); if (properties.hasTrackingRotation()) itemDisplay.setBillboard(properties.getTrackingRotation()); if (properties.hasShadowRadius()) itemDisplay.setShadowRadius(properties.getShadowRadius()); if (properties.hasShadowStrength()) itemDisplay.setShadowStrength(properties.getShadowStrength()); - //if (properties.hasGlowColor()) itemDisplay.setGlowColorOverride(properties.getGlowColor()); if (properties.hasBrightness()) itemDisplay.setBrightness(displayEntityProperties.getBrightness()); itemDisplay.setDisplayWidth(properties.getDisplayWidth()); @@ -502,13 +503,16 @@ private void setItemDisplayData(ItemDisplay itemDisplay, ItemStack item, Float y // since FIXED is meant to mimic ItemFrames, we rotate it to match the ItemFrame's rotation // 1.20 Fixes this, will break for 1.19.4 but added disclaimer in console float pitch; - yaw = (VersionUtil.atOrAbove("1.20.1") && (!hasLimitedPlacing() || !limitedPlacing.isRoof() || !isFixed)) ? yaw : yaw - 180; if (VersionUtil.atOrAbove("1.20.1")) { - if (hasLimitedPlacing() && isFixed) - if (limitedPlacing.isFloor()) pitch = -90; - else if (limitedPlacing.isRoof()) pitch = 90; + if (hasLimitedPlacing() && isFixed) { + if (limitedPlacing.isFloor() && facing == BlockFace.UP) pitch = -90; + else if (limitedPlacing.isRoof() && facing == BlockFace.DOWN) pitch = 90; else pitch = 0; - else pitch = 0; + + if (limitedPlacing.isRoof() && facing == BlockFace.DOWN) + yaw -= 180; + else if (limitedPlacing.isWall() && facing.getModY() == 0) yaw = 90f * facing.ordinal() - 180; + } else pitch = 0; } else pitch = isFixed && hasLimitedPlacing() ? limitedPlacing.isFloor() ? 90 : limitedPlacing.isWall() ? 0 : limitedPlacing.isRoof() ? -90 : 0 : 0; diff --git a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/limitedplacing/LimitedPlacing.java b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/limitedplacing/LimitedPlacing.java index fcd2cb840..3e039011f 100644 --- a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/limitedplacing/LimitedPlacing.java +++ b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/limitedplacing/LimitedPlacing.java @@ -148,7 +148,9 @@ public enum LimitedPlacingType { ALLOW, DENY } - public boolean isFloor() { return floor; } + public boolean isFloor() { + return floor; + } public boolean isRoof() { return roof; } diff --git a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/noteblock/NoteBlockMechanicListener.java b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/noteblock/NoteBlockMechanicListener.java index b2f8805b2..54c90f969 100644 --- a/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/noteblock/NoteBlockMechanicListener.java +++ b/core/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/noteblock/NoteBlockMechanicListener.java @@ -271,6 +271,8 @@ public void onBreakingCustomBlock(final BlockBreakEvent event) { @EventHandler public void onEntityExplosion(EntityExplodeEvent event) { + ExplosionResult result = event.getExplosionResult(); + if (result != ExplosionResult.DESTROY && result != ExplosionResult.DESTROY_WITH_DECAY) return; for (Block block : new HashSet<>(event.blockList())) { if (!OraxenBlocks.isOraxenNoteBlock(block)) continue; OraxenBlocks.remove(block.getLocation(), null); @@ -280,6 +282,8 @@ public void onEntityExplosion(EntityExplodeEvent event) { @EventHandler public void onBlockExplosion(BlockExplodeEvent event) { + ExplosionResult result = event.getExplosionResult(); + if (result != ExplosionResult.DESTROY && result != ExplosionResult.DESTROY_WITH_DECAY) return; for (Block block : new HashSet<>(event.blockList())) { if (!OraxenBlocks.isOraxenNoteBlock(block)) continue; OraxenBlocks.remove(block.getLocation(), null); diff --git a/core/src/main/java/io/th0rgal/oraxen/pack/generation/ResourcePack.java b/core/src/main/java/io/th0rgal/oraxen/pack/generation/ResourcePack.java index 0adb92d09..11d0a0b7e 100644 --- a/core/src/main/java/io/th0rgal/oraxen/pack/generation/ResourcePack.java +++ b/core/src/main/java/io/th0rgal/oraxen/pack/generation/ResourcePack.java @@ -11,7 +11,6 @@ import io.th0rgal.oraxen.font.FontManager; import io.th0rgal.oraxen.font.Glyph; import io.th0rgal.oraxen.font.packets.ScoreboardPacketListener; -import io.th0rgal.oraxen.gestures.GestureManager; import io.th0rgal.oraxen.items.ItemBuilder; import io.th0rgal.oraxen.items.OraxenMeta; import io.th0rgal.oraxen.pack.upload.UploadManager; @@ -84,7 +83,6 @@ public void generate() { // Sorting items to keep only one with models (and generate it if needed) generatePredicates(extractTexturedItems()); generateFont(); - if (Settings.GESTURES_ENABLED.toBool()) generateGestureFiles(); if (Settings.HIDE_SCOREBOARD_NUMBERS.toBool()) hideScoreboardNumbers(); if (Settings.HIDE_SCOREBOARD_BACKGROUND.toBool()) generateScoreboardHideBackground(); if (Settings.TEXTURE_SLICER.toBool()) PackSlicer.slicePackFiles(); @@ -460,17 +458,6 @@ private void generateSound(List output) { } } - private void generateGestureFiles() { - GestureManager gestureManager = OraxenPlugin.get().getGesturesManager(); - if (gestureManager == null) return; - for (Map.Entry entry : gestureManager.getPlayerHeadJsons().entrySet()) - writeStringToVirtual(StringUtils.removeEnd(Utils.getParentDirs(entry.getKey()), "/"), Utils.removeParentDirs(entry.getKey()), entry.getValue()); - writeStringToVirtual("assets/minecraft/models/item", "player_head.json", gestureManager.getSkullJson()); - writeStringToVirtual("assets/minecraft/shaders/core", "rendertype_entity_translucent.vsh", gestureManager.getShaderVsh()); - writeStringToVirtual("assets/minecraft/shaders/core", "rendertype_entity_translucent.fsh", gestureManager.getShaderFsh()); - writeStringToVirtual("assets/minecraft/shaders/core", "rendertype_entity_translucent.json", gestureManager.getShaderJson()); - } - private Collection handleCustomSoundEntries(Collection sounds) { ConfigurationSection mechanic = OraxenPlugin.get().getConfigsManager().getMechanics(); ConfigurationSection customSounds = mechanic.getConfigurationSection("custom_block_sounds"); diff --git a/core/src/main/java/io/th0rgal/oraxen/recipes/listeners/RecipesBuilderEvents.java b/core/src/main/java/io/th0rgal/oraxen/recipes/listeners/RecipesBuilderEvents.java index 99c5df6a7..1e71ebaa1 100644 --- a/core/src/main/java/io/th0rgal/oraxen/recipes/listeners/RecipesBuilderEvents.java +++ b/core/src/main/java/io/th0rgal/oraxen/recipes/listeners/RecipesBuilderEvents.java @@ -11,20 +11,19 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.ItemStack; +import java.util.Optional; + public class RecipesBuilderEvents implements Listener { @EventHandler(priority = EventPriority.HIGH) @SuppressWarnings("deprecation") // because we must use setCursor public void setCursor(InventoryClickEvent event) { + String recipeBuilderTitle = Optional.ofNullable(RecipeBuilder.get(event.getWhoClicked().getUniqueId())).map(RecipeBuilder::getInventoryTitle).orElse(null); + if (!InventoryUtils.getTitleFromView(event).equals(recipeBuilderTitle) || event.getSlotType() != InventoryType.SlotType.RESULT) return; - RecipeBuilder recipeBuilder = RecipeBuilder.get(event.getWhoClicked().getUniqueId()); - if (recipeBuilder == null || !InventoryUtils.getTitleFromView(event).equals(recipeBuilder.getInventoryTitle()) - || event.getSlotType() != InventoryType.SlotType.RESULT) - return; event.setCancelled(true); - ItemStack currentResult = event.getCurrentItem() != null ? event.getCurrentItem().clone() - : new ItemStack(Material.AIR); - ItemStack currentCursor = event.getCursor() != null ? event.getCursor().clone() : new ItemStack(Material.AIR); + ItemStack currentResult = Optional.ofNullable(event.getCurrentItem()).orElse(new ItemStack(Material.AIR)).clone(); + ItemStack currentCursor = Optional.ofNullable(event.getCursor()).orElse(new ItemStack(Material.AIR)).clone(); event.setCurrentItem(currentCursor); event.setCursor(currentResult); } diff --git a/core/src/main/java/io/th0rgal/oraxen/utils/BlockHelpers.java b/core/src/main/java/io/th0rgal/oraxen/utils/BlockHelpers.java index f1b94fa49..d6070105f 100644 --- a/core/src/main/java/io/th0rgal/oraxen/utils/BlockHelpers.java +++ b/core/src/main/java/io/th0rgal/oraxen/utils/BlockHelpers.java @@ -79,7 +79,7 @@ public static void playCustomBlockSound(Location location, String sound, SoundCa public static String validateReplacedSounds(String sound) { ConfigurationSection mechanics = OraxenPlugin.get().getConfigsManager().getMechanics().getConfigurationSection("custom_block_sounds"); - if (mechanics == null) return sound; + if (sound == null || mechanics == null) return sound; sound = sound.replace("minecraft:", ""); if (sound.startsWith("block.wood") && mechanics.getBoolean("noteblock_and_block")) { diff --git a/core/src/main/java/io/th0rgal/oraxen/utils/InventoryUtils.java b/core/src/main/java/io/th0rgal/oraxen/utils/InventoryUtils.java index ec7e52a7a..db0c454ce 100644 --- a/core/src/main/java/io/th0rgal/oraxen/utils/InventoryUtils.java +++ b/core/src/main/java/io/th0rgal/oraxen/utils/InventoryUtils.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.NotNull; import java.lang.reflect.Method; import java.util.HashMap; @@ -15,11 +16,14 @@ public class InventoryUtils { private static final Map methodCache = new HashMap<>(); public static Component titleFromView(InventoryEvent event) { + if (VersionUtil.atOrAbove("1.21")) return event.getView().title(); Object view = event.getView(); try { return (Component) methodCache.computeIfAbsent("title", (title) -> { try { - return view.getClass().getMethod(title); + Method method = view.getClass().getMethod("title"); + method.setAccessible(true); + return method; } catch (NoSuchMethodException e) { if (Settings.DEBUG.toBool()) e.printStackTrace(); return null; @@ -32,11 +36,14 @@ public static Component titleFromView(InventoryEvent event) { } public static Player playerFromView(InventoryEvent event) { + if (VersionUtil.atOrAbove("1.21")) return (Player) event.getView().getPlayer(); Object view = event.getView(); try { return (Player) methodCache.computeIfAbsent("getPlayer", (player) -> { try { - return view.getClass().getMethod(player); + Method method = view.getClass().getMethod("getPlayer"); + method.setAccessible(true); + return method; } catch (NoSuchMethodException e) { if (Settings.DEBUG.toBool()) e.printStackTrace(); return null; @@ -49,11 +56,14 @@ public static Player playerFromView(InventoryEvent event) { } public static String getTitleFromView(InventoryEvent event) { - Object view = event.getView(); + if (VersionUtil.atOrAbove("1.21")) return event.getView().getTitle(); + @NotNull Object view = event.getView(); try { return (String) methodCache.computeIfAbsent("getTitle", (title) -> { try { - return view.getClass().getMethod(title); + Method method = view.getClass().getMethod("getTitle"); + method.setAccessible(true); + return method; } catch (NoSuchMethodException e) { if (Settings.DEBUG.toBool()) e.printStackTrace(); return null; @@ -66,11 +76,14 @@ public static String getTitleFromView(InventoryEvent event) { } public static Inventory topInventoryForPlayer(Player player) { + if (VersionUtil.atOrAbove("1.21")) return player.getOpenInventory().getTopInventory(); Object view = player.getOpenInventory(); try { return (Inventory) methodCache.computeIfAbsent("getTopInventory", (topInv) -> { try { - return view.getClass().getMethod(topInv); + Method method = view.getClass().getMethod("getTopInventory"); + method.setAccessible(true); + return method; } catch (NoSuchMethodException e) { if (Settings.DEBUG.toBool()) e.printStackTrace(); return null; diff --git a/core/src/main/java/io/th0rgal/oraxen/utils/MinecraftVersion.java b/core/src/main/java/io/th0rgal/oraxen/utils/MinecraftVersion.java index 93333db98..80fc4135b 100644 --- a/core/src/main/java/io/th0rgal/oraxen/utils/MinecraftVersion.java +++ b/core/src/main/java/io/th0rgal/oraxen/utils/MinecraftVersion.java @@ -36,6 +36,8 @@ * @author Kristian */ public final class MinecraftVersion implements Comparable, Serializable { + + public static final MinecraftVersion v1_21_1 = new MinecraftVersion("1.21.1"); public static final MinecraftVersion TRICKY_TRIALS = new MinecraftVersion("1.21"); /** * Version 1.20.5 - the cookie and transfer packet update diff --git a/core/src/main/java/io/th0rgal/oraxen/utils/VersionUtil.java b/core/src/main/java/io/th0rgal/oraxen/utils/VersionUtil.java index 04812170b..da94d4d51 100644 --- a/core/src/main/java/io/th0rgal/oraxen/utils/VersionUtil.java +++ b/core/src/main/java/io/th0rgal/oraxen/utils/VersionUtil.java @@ -30,7 +30,7 @@ public static boolean matchesServer(NMSVersion version) { } static { - versionMap.put(NMSVersion.v1_21_R1, Map.of(15, new MinecraftVersion("1.21"))); + versionMap.put(NMSVersion.v1_21_R1, Map.of(15, new MinecraftVersion("1.21"), 16, new MinecraftVersion("1.21.1"))); versionMap.put(NMSVersion.v1_20_R4, Map.of(13, new MinecraftVersion("1.20.5"), 14, new MinecraftVersion("1.20.6"))); versionMap.put(NMSVersion.v1_20_R3, Map.of(11, new MinecraftVersion("1.20.3"), 12, new MinecraftVersion("1.20.4"))); versionMap.put(NMSVersion.v1_20_R2, Map.of(10, new MinecraftVersion("1.20.2"))); diff --git a/core/src/main/resources/settings.yml b/core/src/main/resources/settings.yml index 90663736a..ed08b7bf1 100644 --- a/core/src/main/resources/settings.yml +++ b/core/src/main/resources/settings.yml @@ -63,11 +63,6 @@ CustomBlocks: block_correction: NMS # Valid types are NMS and LEGACY use_legacy_noteblocks: true # Setting relevant for future changes, for now leave this to true -# This will break Player Heads for all 1.19.4 players and above. -# Until this issue is resolved, this will be disabled by default -Gestures: - enabled: false # Enabled gesture-mechanic and generates needed files - ItemUpdater: # Update the items in player inventory to the latest in config when player joins update_items: true diff --git a/gradle.properties b/gradle.properties index 9dadc8d28..5dc14ef17 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -pluginVersion=1.179.0 +pluginVersion=1.180.0 idofrontVersion=0.21.12