Skip to content

Commit

Permalink
Added vector component reduction for velocity.
Browse files Browse the repository at this point in the history
Should make knockback work with X/Z even if Y component is blocked.

Also fixed an issue with /summon that incorrectly checked if an entity was spawnable.
  • Loading branch information
aramperes committed Oct 7, 2017
1 parent 194b486 commit 47db4c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -101,7 +101,7 @@ private boolean checkSummon(CommandSender sender, String type) {
if (sender != null)
sender.sendMessage(ChatColor.RED + "The entity '" + entityType.getName() + "' is not implemented yet.");
return false;
} else if (entityType != null && (entityType.isSpawnable() || !Summonable.class.isAssignableFrom(EntityRegistry.getEntity(entityType)))) {
} else if (entityType != null && (!entityType.isSpawnable() && !Summonable.class.isAssignableFrom(EntityRegistry.getEntity(entityType)))) {
if (sender != null)
sender.sendMessage(ChatColor.RED + "The entity '" + entityType.getName() + "' cannot be summoned.");
return false;
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/net/glowstone/entity/GlowEntity.java
Expand Up @@ -882,8 +882,19 @@ public boolean intersects(BoundingBox box) {

protected void pulsePhysics() {
Location velLoc = location.clone().add(velocity);
if (velLoc.getBlock().getType().isSolid()) {
velocity.zero();
if (velLoc.getBlock().getType().isOccluding()) {
Location velLocY = location.clone().add(0, velocity.getY(), 0);
if (velLocY.getBlock().getType().isOccluding()) {
velocity.setY(0);
}
Location velLocX = location.clone().add(velocity.getX(), 0, 0);
if (velLocX.getBlock().getType().isOccluding()) {
velocity.setX(0);
}
Location velLocZ = location.clone().add(0, 0, velocity.getZ());
if (velLocZ.getBlock().getType().isOccluding()) {
velocity.setZ(0);
}
} else {
location.add(velocity);
// apply friction and gravity
Expand Down

0 comments on commit 47db4c4

Please sign in to comment.