MCPcopy Create free account
hub / github.com/VolmitSoftware/Adapt / punch

Method punch

src/main/java/com/volmit/adapt/util/Impulse.java:73–103  ·  view source on GitHub ↗
(Location at)

Source from the content-addressed store, hash-verified

71 }
72
73 public void punch(Location at) {
74 Area a = new Area(at, radius);
75
76 for (Entity i : a.getNearbyEntities()) {
77 if (ignore.contains(i)) {
78 continue;
79 }
80
81 Vector force = VectorMath.direction(at, i.getLocation());
82 double damage = 0;
83 double distance = i.getLocation().distance(at);
84
85 if (forceMin < forceMax) {
86 force.clone().multiply(((1D - (distance / radius)) * (forceMax - forceMin)) + forceMin);
87 }
88
89 if (damageMin < damageMax) {
90 damage = ((1D - (distance / radius)) * (damageMax - damageMin)) + damageMin;
91 }
92
93 try {
94 if (i instanceof LivingEntity && damage > 0) {
95 ((LivingEntity) i).damage(damage);
96 }
97
98 i.setVelocity(i.getVelocity().add(force));
99 } catch (Exception e) {
100
101 }
102 }
103 }
104
105 public Impulse ignore(Entity player) {
106 ignore.add(player);

Callers 1

onMethod · 0.80

Calls 8

getNearbyEntitiesMethod · 0.95
directionMethod · 0.95
containsMethod · 0.65
damageMethod · 0.65
addMethod · 0.65
getLocationMethod · 0.45
distanceMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected