Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Commit baaff66

Browse files
authored
Merge pull request #10 from Sentropic/1.97
1.97
2 parents 8f4097f + e9c5dd0 commit baaff66

26 files changed

Lines changed: 557 additions & 187 deletions

editor/js/component.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,8 @@ function TargetLinear()
868868
this.data.push(new AttributeValue("Range", "range", 5, 0)
869869
.setTooltip('The max distance away any target can be in blocks')
870870
);
871-
this.data.push(new AttributeValue("Tolerance", "tolerance", 4, 0)
872-
.setTooltip('How lenient the targeting is. Larger numbers allow easier targeting. It is essentially how wide a cone is which is where you are targeting.')
871+
this.data.push(new AttributeValue("Tolerance", "tolerance", 0, 0)
872+
.setTooltip('How much to expand the potential entity\'s hitbox in all directions, in blocks. This makes it easier to aim')
873873
);
874874
this.data.push(new ListValue("Group", "group", ["Ally", "Enemy", "Both"], "Enemy")
875875
.setTooltip('The alignment of targets to get')
@@ -972,8 +972,8 @@ function TargetSingle()
972972
this.data.push(new AttributeValue("Range", "range", 5, 0)
973973
.setTooltip('The max distance away any target can be in blocks')
974974
);
975-
this.data.push(new AttributeValue("Tolerance", "tolerance", 4, 0)
976-
.setTooltip('How lenient the targeting is. Larger numbers allow easier targeting. It is essentially how wide a cone is which is where you are targeting.')
975+
this.data.push(new AttributeValue("Tolerance", "tolerance", 0, 0)
976+
.setTooltip('How much to expand the potential entity\'s hitbox in all directions, in blocks. This makes it easier to aim')
977977
);
978978
this.data.push(new ListValue("Group", "group", ["Ally", "Enemy", "Both"], "Enemy")
979979
.setTooltip('The alignment of targets to get')
@@ -1765,10 +1765,10 @@ function MechanicCommand()
17651765
this.description ='Executes a command for each of the targets.';
17661766

17671767
this.data.push(new StringValue('Command', 'command', '')
1768-
.setTooltip('The command to execute')
1768+
.setTooltip('The command to execute. {player} = caster\'s name, {target} = target\'s name, {targetUUID} = target\'s UUID (useful if targets are non players), &lc: "{", &rc: "}", &sq: "\'"')
17691769
);
17701770
this.data.push(new ListValue('Execute Type', 'type', [ 'Console', 'OP' ], 'OP')
1771-
.setTooltip('Console: executes the command from the console. OP: Only if the target is a player, will have them execute it while given a temporary OP permission (If server closes in the meantime, the permission might stay, not recommended!!). {player} = caster\'s name, {target} = target\'s name, {targetUUID} = target\'s UUID (useful if targets are non players), &lc: "{", &rc: "}"')
1771+
.setTooltip('Console: executes the command from the console. OP: Only if the target is a player, will have them execute it while given a temporary OP permission (If server closes in the meantime, the permission might stay, not recommended!!)')
17721772
);
17731773
}
17741774

@@ -2229,7 +2229,7 @@ function MechanicMessage()
22292229
this.description = 'Sends a message to each player target. To include numbers from Value mechanics, use the filters {<key>} where <key> is the key the value is stored under.'
22302230

22312231
this.data.push(new StringValue('Message', 'message', 'text')
2232-
.setTooltip('The message to display')
2232+
.setTooltip('The message to display. {player} = caster\'s name, {target} = target\'s name, {targetUUID} = target\'s UUID (useful if targets are non players), &lc: "{", &rc: "}", &sq: "\'"')
22332233
);
22342234
}
22352235

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.sucy.skill</groupId>
88
<artifactId>SkillAPI</artifactId>
9-
<version>s1.96</version>
9+
<version>s1.97</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SkillAPI</name>
@@ -109,7 +109,7 @@
109109
<dependency>
110110
<groupId>org.spigotmc</groupId>
111111
<artifactId>spigot-api</artifactId>
112-
<version>1.15.2-R0.1-SNAPSHOT</version>
112+
<version>1.16.4-R0.1-SNAPSHOT</version>
113113
<scope>provided</scope>
114114
</dependency>
115115
<dependency>

src/main/java/com/sucy/skill/SkillAPI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public void onEnable() {
167167
listen(new DeathListener(), !VersionManager.isVersionAtLeast(11000));
168168
listen(new LingeringPotionListener(), VersionManager.isVersionAtLeast(VersionManager.V1_9_0));
169169
listen(new ExperienceListener(), settings.yieldsEnabled());
170+
listen(new PluginChecker(), true);
171+
170172

171173
// Set up tasks
172174
if (settings.isManaEnabled()) {

src/main/java/com/sucy/skill/api/player/PlayerData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import com.rit.sucy.config.Filter;
3030
import com.rit.sucy.config.FilterType;
3131
import com.rit.sucy.config.parse.DataSection;
32-
import com.sucy.skill.api.TargetHelper;
32+
import com.sucy.skill.api.target.TargetHelper;
3333
import com.rit.sucy.version.VersionManager;
3434
import com.rit.sucy.version.VersionPlayer;
3535
import com.sucy.skill.SkillAPI;

src/main/java/com/sucy/skill/api/projectile/CustomProjectile.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ public void applyLanded() {
182182

183183
/**
184184
* Checks if the projectile collides with a given list of entities
185+
* Returns true if another check should happen, false other wise
185186
*/
186-
protected void checkCollision(final boolean pierce) {
187+
protected boolean checkCollision(final boolean pierce) {
187188
for (LivingEntity entity : getColliding()) {
188189
if (entity == thrower || hit.contains(entity.getEntityId())) {
189190
continue;
@@ -202,9 +203,10 @@ protected void checkCollision(final boolean pierce) {
202203

203204
if (!pierce) {
204205
cancel();
205-
return;
206+
return false;
206207
}
207208
}
209+
return true;
208210
}
209211

210212
/**

src/main/java/com/sucy/skill/api/projectile/ParticleProjectile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public void run()
206206
if (!isTraveling())
207207
return;
208208

209-
checkCollision(pierce);
209+
if (!checkCollision(pierce)) break;
210210
}
211211

212212
// Particle along path
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
package com.sucy.skill.api.target;
2+
3+
import com.google.common.base.Objects;
4+
import org.bukkit.Location;
5+
import org.bukkit.util.Vector;
6+
7+
/**
8+
* Represents an axix-aligned bounding box.
9+
*
10+
* @author Kristian
11+
*/
12+
public class AABB {
13+
public static class Vec3D {
14+
/**
15+
* Point with the coordinate (1, 1, 1).
16+
*/
17+
public static final Vec3D UNIT_MAX = new Vec3D(1, 1, 1);
18+
19+
/** X coordinate. */
20+
public final double x;
21+
/** Y coordinate. */
22+
public final double y;
23+
/** Z coordinate. */
24+
public final double z;
25+
26+
/**
27+
* Creates a new vector with the given coordinates.
28+
* @param x the x
29+
* @param y the y
30+
* @param z the z
31+
*/
32+
public Vec3D(double x, double y, double z) {
33+
this.x = x;
34+
this.y = y;
35+
this.z = z;
36+
}
37+
38+
/**
39+
* Creates a new vector with the coordinates of the given vector.
40+
* @param v vector to copy.
41+
*/
42+
public Vec3D(Vec3D v) {
43+
this.x = v.x;
44+
this.y = v.y;
45+
this.z = v.z;
46+
}
47+
48+
/**
49+
* Construct a vector from a Bukkit location.
50+
* @param loc - the Bukkit location.
51+
*/
52+
public static Vec3D fromLocation(Location loc) {
53+
return new Vec3D(loc.getX(), loc.getY(), loc.getZ());
54+
}
55+
56+
/**
57+
* Construct a copy of our immutable vector from Bukkit's mutable vector.
58+
* @param v - Bukkit vector.
59+
* @return A copy of the given vector.
60+
*/
61+
public static Vec3D fromVector(Vector v) {
62+
return new Vec3D(v.getX(), v.getY(), v.getZ());
63+
}
64+
65+
/**
66+
* Add vector v and returns result as new vector.
67+
*
68+
* @param v vector to add
69+
* @return result as new vector
70+
*/
71+
public final Vec3D add(Vec3D v) {
72+
return new Vec3D(x + v.x, y + v.y, z + v.z);
73+
}
74+
75+
/**
76+
* Scales vector uniformly and returns result as new vector.
77+
*
78+
* @param s scale factor
79+
*
80+
* @return new vector
81+
*/
82+
public Vec3D scale(double s) {
83+
return new Vec3D(x * s, y * s, z * s);
84+
}
85+
86+
/**
87+
* Normalizes the vector so that its magnitude = 1.
88+
* @return The normalized vector.
89+
*/
90+
public Vec3D normalize() {
91+
double mag = Math.sqrt(x * x + y * y + z * z);
92+
93+
if (mag > 0)
94+
return scale(1.0 / mag);
95+
return this;
96+
}
97+
98+
@Override
99+
public boolean equals(Object obj) {
100+
if (obj instanceof Vec3D) {
101+
final Vec3D v = (Vec3D) obj;
102+
return x == v.x && y == v.y && z == v.z;
103+
}
104+
return false;
105+
}
106+
107+
@Override
108+
public int hashCode() {
109+
return Objects.hashCode(x, y, z);
110+
}
111+
112+
public String toString() {
113+
return String.format("{x: %g, y: %g, z: %g}", x, y, z);
114+
}
115+
}
116+
117+
public static class Ray3D extends Vec3D {
118+
public final Vec3D dir;
119+
120+
public Ray3D(Vec3D origin, Vec3D direction) {
121+
super(origin);
122+
dir = direction.normalize();
123+
}
124+
125+
/**
126+
* Construct a 3D ray from a location.
127+
* @param loc - the Bukkit location.
128+
*/
129+
public Ray3D(Location loc) {
130+
this(Vec3D.fromLocation(loc), Vec3D.fromVector(loc.getDirection()));
131+
}
132+
133+
public Vec3D getDirection() {
134+
return dir;
135+
}
136+
137+
public Vec3D getPointAtDistance(double dist) {
138+
return add(dir.scale(dist));
139+
}
140+
141+
public String toString() {
142+
return "origin: " + super.toString() + " dir: " + dir;
143+
}
144+
}
145+
146+
private Vec3D max;
147+
private Vec3D min;
148+
149+
/**
150+
* Creates a new instance from a minimum point and a maximum point.
151+
*/
152+
public AABB(Vec3D min, Vec3D max) {
153+
this.min = min;
154+
this.max = max;
155+
}
156+
157+
/**
158+
* Create a new AABB from a given block.
159+
* @param block - the block.
160+
*/
161+
public AABB(Location block) {
162+
this(Vec3D.fromLocation(block), Vec3D.fromLocation(block).add(Vec3D.UNIT_MAX));
163+
}
164+
165+
public Vec3D getMax() { return max; }
166+
public Vec3D getMin() { return min; }
167+
168+
public void expand(double expand) {
169+
min = min.add(new Vec3D(-expand, -expand, -expand));
170+
max = max.add(new Vec3D(expand, expand, expand));
171+
}
172+
173+
/**
174+
* Calculates intersection with the given ray between a certain distance
175+
* interval.
176+
* <p>
177+
* Ray-box intersection is using IEEE numerical properties to ensure the
178+
* test is both robust and efficient, as described in:
179+
* <br>
180+
* <code>Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley: "An
181+
* Efficient and Robust Ray-Box Intersection Algorithm" Journal of graphics
182+
* tools, 10(1):49-54, 2005</code>
183+
*
184+
* @param ray incident ray
185+
* @param minDist
186+
* @param maxDist
187+
* @return intersection point on the bounding box (only the first is
188+
* returned) or null if no intersection
189+
*/
190+
public Vec3D intersectsRay(Ray3D ray, float minDist, double maxDist) {
191+
Vec3D invDir = new Vec3D(1f / ray.dir.x, 1f / ray.dir.y, 1f / ray.dir.z);
192+
193+
boolean signDirX = invDir.x < 0;
194+
boolean signDirY = invDir.y < 0;
195+
boolean signDirZ = invDir.z < 0;
196+
197+
Vec3D bbox = signDirX ? max : min;
198+
double tmin = (bbox.x - ray.x) * invDir.x;
199+
bbox = signDirX ? min : max;
200+
double tmax = (bbox.x - ray.x) * invDir.x;
201+
bbox = signDirY ? max : min;
202+
double tymin = (bbox.y - ray.y) * invDir.y;
203+
bbox = signDirY ? min : max;
204+
double tymax = (bbox.y - ray.y) * invDir.y;
205+
206+
if ((tmin > tymax) || (tymin > tmax)) {
207+
return null;
208+
}
209+
if (tymin > tmin) {
210+
tmin = tymin;
211+
}
212+
if (tymax < tmax) {
213+
tmax = tymax;
214+
}
215+
216+
bbox = signDirZ ? max : min;
217+
double tzmin = (bbox.z - ray.z) * invDir.z;
218+
bbox = signDirZ ? min : max;
219+
double tzmax = (bbox.z - ray.z) * invDir.z;
220+
221+
if ((tmin > tzmax) || (tzmin > tmax)) {
222+
return null;
223+
}
224+
if (tzmin > tmin) {
225+
tmin = tzmin;
226+
}
227+
if (tzmax < tmax) {
228+
tmax = tzmax;
229+
}
230+
if ((tmin < maxDist) && (tmax > minDist)) {
231+
return ray.getPointAtDistance(tmin);
232+
}
233+
return null;
234+
}
235+
}

0 commit comments

Comments
 (0)