Skip to content

Commit

Permalink
Fixed bug with MetalClips and misc errors. (ProjectKorra#869)
Browse files Browse the repository at this point in the history
## Errors and bugs corrected
* A `ClassCastException` in `PKListener.java:onEntityDamageEvent()` would occur when a non-Living Entity took damage.
* Ingots on the ground would disappear when their `ItemStack` merged with MetalClips', and the latter is removed upon colliding with an Entity.

## Improvements made
* A small vertical push was given to items affected by the *magnetize* functionality of MetalClips, so that they no longer get stuck when being pulled upwards.

## Other changes
* Added a `gitignore` entry to omit IntelliJ's out/ directory, which contains compiled code.
  • Loading branch information
Carbogen authored and ChristopherWMM committed Dec 20, 2017
1 parent 102112f commit 08165ed
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,5 @@ target/

.idea/
classes/
out/
projectkorra.iml
2 changes: 1 addition & 1 deletion src/com/projectkorra/projectkorra/PKListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public void onEntityDamageEvent(EntityDamageEvent event) {
FireDamageTimer.dealFlameDamage(entity);
}

if (TempArmor.hasTempArmor((LivingEntity)entity)) {
if (entity instanceof LivingEntity && TempArmor.hasTempArmor((LivingEntity)entity)) {
event.setDamage(DamageModifier.ARMOR, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public void progress() {
Item iron = (Item) entity;

if (Arrays.asList(METAL_ITEMS).contains(iron.getItemStack().getType())) {
iron.setVelocity(vector.normalize().multiply(magnetPower));
iron.setVelocity(vector.normalize().multiply(magnetPower).add(new Vector(0, 0.2, 0)));
}
}
}
Expand Down Expand Up @@ -435,7 +435,7 @@ public void progress() {
}
} else {
DamageHandler.damageEntity(e, player, damage, this);
dropIngots(e.getLocation());
dropIngots(e.getLocation(), ii.getItemStack().getAmount());
remove();
}

Expand All @@ -450,7 +450,11 @@ public void progress() {
}

public void dropIngots(Location loc) {
Item i = player.getWorld().dropItem(loc, new ItemStack(Material.IRON_INGOT, metalClipsCount == 0 ? 1 : metalClipsCount));
dropIngots(loc, metalClipsCount == 0 ? 1 : metalClipsCount);
}

public void dropIngots(Location loc, int amount) {
Item i = player.getWorld().dropItem(loc, new ItemStack(Material.IRON_INGOT, amount));
i.setPickupDelay(61);
}

Expand Down

0 comments on commit 08165ed

Please sign in to comment.