From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Thu, 25 Mar 2021 01:56:38 +0100 Subject: [PATCH] Projectile offset config diff --git a/src/main/java/net/minecraft/world/item/ItemBow.java b/src/main/java/net/minecraft/world/item/ItemBow.java index 59b803ec4552058f2dda269e9435daf65be10559..6bf8c0f03acd55f0ea5919609f55e2e6736455c5 100644 --- a/src/main/java/net/minecraft/world/item/ItemBow.java +++ b/src/main/java/net/minecraft/world/item/ItemBow.java @@ -41,7 +41,7 @@ public class ItemBow extends ItemProjectileWeapon implements ItemVanishable { ItemArrow itemarrow = (ItemArrow) ((ItemArrow) (itemstack1.getItem() instanceof ItemArrow ? itemstack1.getItem() : Items.ARROW)); EntityArrow entityarrow = itemarrow.a(world, itemstack1, (EntityLiving) entityhuman); - entityarrow.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, f * 3.0F, 1.0F); + entityarrow.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, f * 3.0F, (float) world.purpurConfig.bowProjectileOffset); // Purpur - Projectile offset config if (f == 1.0F) { entityarrow.setCritical(true); } diff --git a/src/main/java/net/minecraft/world/item/ItemCrossbow.java b/src/main/java/net/minecraft/world/item/ItemCrossbow.java index 9cf76f8297c2a44c1df8ce2c4f0813802883a18b..55815737879ce2c736304754f5131961cdcaaebf 100644 --- a/src/main/java/net/minecraft/world/item/ItemCrossbow.java +++ b/src/main/java/net/minecraft/world/item/ItemCrossbow.java @@ -54,7 +54,7 @@ public class ItemCrossbow extends ItemProjectileWeapon implements ItemVanishable ItemStack itemstack = entityhuman.b(enumhand); if (d(itemstack)) { - a(world, entityhuman, enumhand, itemstack, m(itemstack), 1.0F); + a(world, entityhuman, enumhand, itemstack, m(itemstack), (float) world.purpurConfig.crossbowProjectileOffset); // Purpur - Projectile offset config a(itemstack, false); return InteractionResultWrapper.consume(itemstack); } else if (!entityhuman.f(itemstack).isEmpty()) { diff --git a/src/main/java/net/minecraft/world/item/ItemEgg.java b/src/main/java/net/minecraft/world/item/ItemEgg.java index 4b1a6ee784da4595931396a905f1358b7a13f3dd..83c85ad70bbe70f1f3f70b83c842a3eb94d520c6 100644 --- a/src/main/java/net/minecraft/world/item/ItemEgg.java +++ b/src/main/java/net/minecraft/world/item/ItemEgg.java @@ -24,7 +24,7 @@ public class ItemEgg extends Item { EntityEgg entityegg = new EntityEgg(world, entityhuman); entityegg.setItem(itemstack); - entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, (float) world.purpurConfig.eggProjectileOffset); // Purpur - Projectile offset config // Paper start com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityegg.getBukkitEntity()); if (event.callEvent() && world.addEntity(entityegg)) { diff --git a/src/main/java/net/minecraft/world/item/ItemEnderPearl.java b/src/main/java/net/minecraft/world/item/ItemEnderPearl.java index 61512c6755f29cb2c228ae3e80b1e08348d784a5..79367f574d6ad9a45a4a8e9ae040aec4103fac37 100644 --- a/src/main/java/net/minecraft/world/item/ItemEnderPearl.java +++ b/src/main/java/net/minecraft/world/item/ItemEnderPearl.java @@ -24,7 +24,7 @@ public class ItemEnderPearl extends Item { EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); entityenderpearl.setItem(itemstack); - entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, (float) world.purpurConfig.enderPearlProjectileOffset); // Purpur - Projectile offset config // Paper start com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity()); if (event.callEvent() && world.addEntity(entityenderpearl)) { diff --git a/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java b/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java index 27c61fc4e61b0d76565ca6893514b3c73247c954..394916baaf0e572d14c54acc68bc45ab04b789e3 100644 --- a/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java +++ b/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java @@ -23,7 +23,7 @@ public class ItemPotionThrowable extends ItemPotion { EntityPotion entitypotion = new EntityPotion(world, entityhuman); entitypotion.setItem(itemstack); - entitypotion.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.5F, 1.0F); + entitypotion.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.5F, (float) world.purpurConfig.throwablePotionProjectileOffset); // Purpur - Projectile offset config // Paper start com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitypotion.getBukkitEntity()); if (event.callEvent() && world.addEntity(entitypotion)) { diff --git a/src/main/java/net/minecraft/world/item/ItemSnowball.java b/src/main/java/net/minecraft/world/item/ItemSnowball.java index 8a1d59cb1ea5a8959c52272aa762ec35307246d7..fcca6eee05f1d6bcc2909c376bfba7b74c33c421 100644 --- a/src/main/java/net/minecraft/world/item/ItemSnowball.java +++ b/src/main/java/net/minecraft/world/item/ItemSnowball.java @@ -25,7 +25,7 @@ public class ItemSnowball extends Item { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); entitysnowball.setItem(itemstack); - entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, (float) world.purpurConfig.snowballProjectileOffset); // Purpur - Projectile offset config // Paper start com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitysnowball.getBukkitEntity()); if (event.callEvent() && world.addEntity(entitysnowball)) { diff --git a/src/main/java/net/minecraft/world/item/ItemTrident.java b/src/main/java/net/minecraft/world/item/ItemTrident.java index 0711d195c654edef5875f587e391bacfdea096da..2341c98859faa61662d7ed343e6ed1575fa2281e 100644 --- a/src/main/java/net/minecraft/world/item/ItemTrident.java +++ b/src/main/java/net/minecraft/world/item/ItemTrident.java @@ -74,7 +74,7 @@ public class ItemTrident extends Item implements ItemVanishable { if (k == 0) { EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); - entitythrowntrident.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 2.5F + (float) k * 0.5F, 1.0F); + entitythrowntrident.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 2.5F + (float) k * 0.5F, (float) world.purpurConfig.tridentProjectileOffset); // Purpur - Projectile offset config if (entityhuman.abilities.canInstantlyBuild) { entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index e2504bf2846b66563936fc9329561da66e8ae985..75cae460f560a3825915a96126f28ce3d4f9e182 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -307,6 +307,23 @@ public class PurpurWorldConfig { snowballDamage = getInt("gameplay-mechanics.projectile-damage.snowball", snowballDamage); } + public double bowProjectileOffset = 1.0D; + public double crossbowProjectileOffset = 1.0D; + public double eggProjectileOffset = 1.0D; + public double enderPearlProjectileOffset = 1.0D; + public double throwablePotionProjectileOffset = 1.0D; + public double tridentProjectileOffset = 1.0D; + public double snowballProjectileOffset = 1.0D; + private void projectileOffsetSettings() { + bowProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.bow", bowProjectileOffset); + crossbowProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.crossbow", crossbowProjectileOffset); + eggProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.egg", eggProjectileOffset); + enderPearlProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.ender-pearl", enderPearlProjectileOffset); + throwablePotionProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.throwable-potion", throwablePotionProjectileOffset); + tridentProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.trident", tridentProjectileOffset); + snowballProjectileOffset = getDouble("gameplay-mechanics.projectile-offset.snowball", snowballProjectileOffset); + } + public boolean useBetterMending = false; public boolean alwaysTameInCreative = false; public boolean boatEjectPlayersOnLand = false;