diff --git a/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/GensouJank.java b/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/GensouJank.java index 2cc7e60..b2454f3 100644 --- a/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/GensouJank.java +++ b/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/GensouJank.java @@ -22,7 +22,7 @@ public void onEnable(){ instance = this; config.addDefault("hitbox-y-offset", 1.2); - // config.addDefault("debug-mode", false); + config.options().copyDefaults(true); saveConfig(); diff --git a/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/TouhouHitboxes.java b/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/TouhouHitboxes.java index cc43022..e38845e 100644 --- a/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/TouhouHitboxes.java +++ b/GensouJank/src/main/java/net/gensokyoreimagined/gensoujank/TouhouHitboxes.java @@ -81,43 +81,35 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command query.hitbox = hitbox; hitbox.setVisibleByDefault(false); - hitbox.setTeleportDuration(1); + // hitbox.setTeleportDuration(1); player.showEntity(GensouJank.getInstance(), hitbox); - hitbox.setBlock(Material.GLASS.createBlockData()); + // Set hitbox to glass block + hitbox.setBlock(Material.SPAWNER.createBlockData()); // I do not particularly like Bukkit's API, soooo hitbox.getHandle().setTransformation(new Transformation( - null, + new Vector3f((float) -player.getWidth() / 2.0f, (float) -box.getHeight(), (float) -player.getWidth() / 2.0f), null, new Vector3f((float) box.getWidthX(), (float) box.getHeight(), (float) box.getWidthZ()), null )); + // Make the hitbox follow the player + player.addPassenger(hitbox); + query.debugTask = Bukkit.getScheduler().runTaskTimer(GensouJank.getInstance(), () -> { var timerBox = player.getBoundingBox(); var tHitBox = query.hitbox; tHitBox.getHandle().setTransformation(new Transformation( - null, + new Vector3f((float) -player.getWidth() / 2.0f, (float) -timerBox.getHeight(), (float) -player.getWidth() / 2.0f), null, new Vector3f((float) timerBox.getWidthX(), (float) timerBox.getHeight(), (float) timerBox.getWidthZ()), null )); - var onGround = player.isOnGround(); - // compensate for player movement - step one tick ahead - var velocityX = query.lastBoundingBox == null ? 0 : timerBox.getMinX() - query.lastBoundingBox.getMinX(); - var velocityY = query.lastBoundingBox == null ? 0 : timerBox.getMinY() - query.lastBoundingBox.getMinY(); - var velocityZ = query.lastBoundingBox == null ? 0 : timerBox.getMinZ() - query.lastBoundingBox.getMinZ(); - - query.hitbox.teleport(new Location( - player.getWorld(), timerBox.getMinX() + 1 * velocityX, timerBox.getMinY() + (onGround ? 0 : 1 * velocityY), timerBox.getMinZ() + 1 * velocityZ - )); - query.lastBoundingBox = timerBox; - - // Bukkit.getLogger().info("[GensouJank] " + player.getName() + " position: " + player.getLocation()); }, 0L, 1L); } else if (args[2].equalsIgnoreCase("false") && query.debugTask != null) { query.debugTask.cancel(); diff --git a/GensouJankMod/src/main/java/net/gensokyoreimagined/gensoujankmod/mixin/core/MixinServerPlayer.java b/GensouJankMod/src/main/java/net/gensokyoreimagined/gensoujankmod/mixin/core/MixinServerPlayer.java index 1023ed1..9b3576d 100644 --- a/GensouJankMod/src/main/java/net/gensokyoreimagined/gensoujankmod/mixin/core/MixinServerPlayer.java +++ b/GensouJankMod/src/main/java/net/gensokyoreimagined/gensoujankmod/mixin/core/MixinServerPlayer.java @@ -6,7 +6,6 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Pose; import net.minecraft.world.phys.AABB; -import org.bukkit.Bukkit; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -26,11 +25,10 @@ private void makeBoundingBox(CallbackInfoReturnable cir) { var uuid = player.getUUID(); if (gensouJank$instance == null) { - Bukkit.getLogger().info("[GensouJank] Creating new TouhouPlayer instance for " + uuid + "..."); gensouJank$instance = TouhouPlayers.players.computeIfAbsent(uuid, o -> new TouhouPlayer(uuid)); TouhouPlayers.players.put(uuid, gensouJank$instance); } else if (!gensouJank$instance.uuid.equals(uuid)) { - Bukkit.getLogger().info("[GensouJank] Updating TouhouPlayer instance " + gensouJank$instance.uuid + " -> " + uuid + "..."); + // UUID gets changed when the player fully logs in (changes to Minecraft UUID rather than entity UUID) TouhouPlayers.players.remove(gensouJank$instance.uuid); TouhouPlayers.players.put(uuid, gensouJank$instance); gensouJank$instance.uuid = uuid;