Skip to content
This repository was archived by the owner on Aug 31, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Bukkit/0062-Allow-custom-underwater-arrow-distances.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From af2eddf6ef44cbce89014ecbe07387ed944c055c Mon Sep 17 00:00:00 2001
From: ShinyDialga45 <shinydialga45@gmail.com>
Date: Tue, 18 Aug 2015 09:40:44 -0500
Subject: [PATCH] Allow custom underwater arrow distances


diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 37918e4..d0fae2c 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -339,6 +339,13 @@ public final class Bukkit {
}

/**
+ * @see Server#getArrowWaterDistance()
+ */
+ public static float getArrowWaterDistance() {
+ return server.getArrowWaterDistance();
+ }
+
+ /**
* Gets default ticks per animal spawns value.
* <p>
* <b>Example Usage:</b>
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 4e64c28..d599d23 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -275,6 +275,11 @@ public interface Server extends PluginMessageRecipient {
public boolean getWaterPushesTNT();

/**
+ * How far should arrows go in water?
+ */
+ public float getArrowWaterDistance();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not have a setter too? Seems a bit silly to have sportbukkit options not mutable, that is the purpose of plugins.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also that comment isn't the best. "Distance arrow moves in water" would probably be better, I don't think questions are the best for describing a method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was simply following previous commits structures. The commit for water-pushes-tnt was a bukkit.yml option as well. Not sure what's the need for a setter as this isn't a case you'd change often. The comment for it was also in the form of a question.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because someone else does it that way doesn't make it right. I requested (and never got) a setter for that commit, and having a question as a javadoc is pretty awful at best.

Even if you don't think it would be changed much, the whole point of the API is to give the plugins ways to interact with the server. If we didn't want to change it there would be little point to an API in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is a wrapper for a configuration value. It should not have a setter. Plugins generally should not mutate config values.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any real justification behind that? What makes a config value so sacred that a plugin can't add functionality to interact with it? Setters exist for numerous other config values, so why should sportbukkit's additions be any different? All values that can be mutable should be mutable through the API, rather than requiring reflection to manipulate them. The configs should just provide a default.

+
+ /**
* Gets default ticks per animal spawns value.
* <p>
* <b>Example Usage:</b>
--
1.9.4.msysgit.2

88 changes: 88 additions & 0 deletions CraftBukkit/0126-Allow-custom-underwater-arrow-distances.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
From 6f0adaa2d68840c619f584c20bcebddc20f8a6dd Mon Sep 17 00:00:00 2001
From: ShinyDialga45 <shinydialga45@gmail.com>
Date: Tue, 18 Aug 2015 09:40:21 -0500
Subject: [PATCH] Allow custom underwater arrow distances


diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index 04863b3..a9cfac2 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -340,7 +340,7 @@ public class EntityArrow extends Entity implements IProjectile {
this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, new int[0]);
}

- f4 = 0.6F;
+ f4 = this.world.getServer().getArrowWaterDistance(); //SportBukkit - use a custom arrow distance value instead
}

if (this.U()) {
@@ -474,4 +474,37 @@ public class EntityArrow extends Entity implements IProjectile {
return inGround;
}
// CraftBukkit end
+
+ //SportBukkit start - Send the client updates in order to display the true location of the arrow rather than show the arrow teleport back.
+ //Code used from @jedediah commit "Fix TNT physics": https://github.com/OvercastNetwork/SportBukkit/commit/3fa8e200bba73c381ccd77c31dfec3b81de2d2e5
+ @Override
+ public boolean W() {
+ if (this.world.a(this.getBoundingBox().grow(0.0D, -0.4000000059604645D, 0.0D).shrink(0.001D, 0.001D, 0.001D), Material.WATER, this)) {
+ if (!this.inWater && !this.justCreated) {
+ this.X();
+ }
+
+ this.fallDistance = 0.0F;
+ this.inWater = true;
+ this.fireTicks = 0;
+ // Send position and velocity updates to nearby players on every tick while the Arrow is in water.
+ // This does pretty well at keeping their clients in sync with the server.
+ EntityTrackerEntry ete = (EntityTrackerEntry) ((WorldServer) this.getWorld()).getTracker().trackedEntities.get(this.getId());
+ if (ete != null && this.inWater) {
+ PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(this);
+ PacketPlayOutEntityTeleport positionPacket = new PacketPlayOutEntityTeleport(this);
+ for (EntityPlayer viewer : ete.trackedPlayers) {
+ if ((viewer.locX - this.locX) * (viewer.locY - this.locY) * (viewer.locZ - this.locZ) < 16 * 16) {
+ viewer.playerConnection.sendPacket(velocityPacket);
+ viewer.playerConnection.sendPacket(positionPacket);
+ }
+ }
+ }
+ } else {
+ this.inWater = false;
+ }
+
+ return this.inWater;
+ }
+ //SportBukkit end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c006200..c14a046 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -599,6 +599,11 @@ public final class CraftServer implements Server {
}

@Override
+ public float getArrowWaterDistance() {
+ return Float.parseFloat(this.configuration.getString("settings.arrow-water-distance", "0.6"));
+ }
+
+ @Override
public int getTicksPerAnimalSpawns() {
return this.configuration.getInt("ticks-per.animal-spawns");
}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 6867fe3..8d60321 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -25,6 +25,7 @@ settings:
shutdown-message: Server closed
bungeecord: false
fetch-skulls: true
+ arrow-water-distance: 0.6
spawn-limits:
monsters: 70
animals: 15
--
1.9.4.msysgit.2