mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Merge branch 'master' into chore/has-unlocked
This commit is contained in:
commit
32b9788e74
8
.github/ISSUE_TEMPLATE/bug-report.md
vendored
8
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@ -19,7 +19,9 @@ assignees: ''
|
||||
<!-- Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. -->
|
||||
<!-- Youtube Videos and Screenshots are recommended!!! -->
|
||||
<!-- Start writing below this line -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## :bulb: Expected behavior (REQUIRED)
|
||||
<!-- What were you expecting to happen? -->
|
||||
@ -34,7 +36,7 @@ assignees: ''
|
||||
|
||||
|
||||
## :open_file_folder: /error-reports/ Folder
|
||||
<!-- Check the folder /plugins/Slimefun/error-reports/ and upload all files inside that folder. -->
|
||||
<!-- Check the folder /plugins/Slimefun/error-reports/ and upload any files inside that folder. -->
|
||||
<!-- You can also post these files via https://pastebin.com/ -->
|
||||
<!-- Paste your link(s) below this line -->
|
||||
|
||||
@ -46,7 +48,7 @@ assignees: ''
|
||||
<!-- Make sure that the screenshot covers the entire output of that command. -->
|
||||
<!-- If your issue is related to other plugins, make sure to include the versions of these plugins too! -->
|
||||
|
||||
- Server Software (Spigot/Paper):
|
||||
- Server Software:
|
||||
- Minecraft Version:
|
||||
- Slimefun Version:
|
||||
- CS-CoreLib Version:
|
||||
|
@ -39,6 +39,7 @@
|
||||
* Fixed ghost blocks to some extent (ghost blocks will now drop and be replaced)
|
||||
* Fixed #2636
|
||||
* Fixed some backpack opening issues
|
||||
* Fixed #2647
|
||||
|
||||
## Release Candidate 18 (03 Dec 2020)
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -348,7 +348,7 @@
|
||||
<dependency>
|
||||
<groupId>com.konghq</groupId>
|
||||
<artifactId>unirest-java</artifactId>
|
||||
<version>3.11.06</version>
|
||||
<version>3.11.09</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -42,30 +44,30 @@ public class StomperBoots extends SlimefunItem {
|
||||
* The {@link EntityDamageEvent} in which the {@link Player} has taken fall damage
|
||||
*/
|
||||
public void stomp(EntityDamageEvent fallDamageEvent) {
|
||||
Player p = (Player) fallDamageEvent.getEntity();
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
|
||||
p.setVelocity(new Vector(0, 0.7, 0));
|
||||
Player player = (Player) fallDamageEvent.getEntity();
|
||||
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
|
||||
player.setVelocity(new Vector(0, 0.7, 0));
|
||||
|
||||
for (Entity n : p.getNearbyEntities(4, 4, 4)) {
|
||||
if (n instanceof LivingEntity && n.isValid() && !n.getUniqueId().equals(p.getUniqueId())) {
|
||||
Vector velocity = getShockwave(p.getLocation(), n.getLocation());
|
||||
n.setVelocity(velocity);
|
||||
for (Entity entity : player.getNearbyEntities(4, 4, 4)) {
|
||||
if (entity instanceof LivingEntity && canPush(player, (LivingEntity) entity)) {
|
||||
Vector velocity = getShockwave(player.getLocation(), entity.getLocation());
|
||||
entity.setVelocity(velocity);
|
||||
|
||||
// Check if it's not a Player or if PvP is enabled
|
||||
if (!(n instanceof Player) || (p.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(p, n.getLocation(), ProtectableAction.ATTACK_PLAYER))) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, fallDamageEvent.getDamage() / 2);
|
||||
if (!(entity instanceof Player) || (player.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(player, entity.getLocation(), ProtectableAction.ATTACK_PLAYER))) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(player, entity, DamageCause.ENTITY_ATTACK, fallDamageEvent.getDamage() / 2);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
((LivingEntity) n).damage(event.getDamage());
|
||||
((LivingEntity) entity).damage(event.getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockFace face : BlockFace.values()) {
|
||||
Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
|
||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
|
||||
player.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +81,7 @@ public class StomperBoots extends SlimefunItem {
|
||||
*
|
||||
* @return A {@link Vector} to determine the velocity for our {@link Entity}
|
||||
*/
|
||||
private Vector getShockwave(Location origin, Location target) {
|
||||
private Vector getShockwave(@Nonnull Location origin, @Nonnull Location target) {
|
||||
// As the distance approaches zero we might slip into a "division by zero" when normalizing
|
||||
if (origin.distanceSquared(target) < 0.05) {
|
||||
return new Vector(0, 1, 0);
|
||||
@ -89,4 +91,21 @@ public class StomperBoots extends SlimefunItem {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the stomper boots can move an entity and is not the player who is using the boots.
|
||||
* <p>
|
||||
* <b>For developers:</b> If you're spawning an immovable NPC, you should be denying
|
||||
* collision with {@link LivingEntity#setCollidable(boolean)} or
|
||||
* gravity with {@link LivingEntity#setGravity(boolean)}.
|
||||
*
|
||||
* @param entity
|
||||
* The {@link LivingEntity} to check.
|
||||
* @param player
|
||||
* The {@link Player} using the {@link StomperBoots}.
|
||||
* @return If the entity can move.
|
||||
*/
|
||||
protected boolean canPush(@Nonnull Player player, @Nonnull LivingEntity entity) {
|
||||
return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId())
|
||||
&& entity.isCollidable() && entity.hasGravity();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user