Skip to content

Commit

Permalink
Fix frozen parrots
Browse files Browse the repository at this point in the history
Fixes #113
  • Loading branch information
Techcable committed Sep 19, 2018
1 parent c233c92 commit ebdecd7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void setDefaults() {
set("pets." + petType.toString().toLowerCase().replace("_", " ") + ".jumpHeight", 0.6D);

if (petType != PetType.ENDERDRAGON) {
boolean canFly = (petType == PetType.BAT || petType == PetType.BLAZE || petType == PetType.GHAST || petType == PetType.SQUID || petType == PetType.WITHER);
boolean canFly = (petType == PetType.BAT || petType == PetType.BLAZE || petType == PetType.GHAST || petType == PetType.SQUID || petType == PetType.WITHER || petType == PetType.PARROT);
set("pets." + petType.toString().toLowerCase().replace("_", " ") + ".canFly", canFly);
set("pets." + petType.toString().toLowerCase().replace("_", " ") + ".allow.riders", true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ import net.techcable.sonarpet.EntityHook
import net.techcable.sonarpet.EntityHookType
import net.techcable.sonarpet.nms.NMSInsentientEntity
import net.techcable.sonarpet.nms.entity.EntityInsentientPet
import org.bukkit.entity.Parrot

@EntityHook(EntityHookType.PARROT)
class EntityParrotPet internal constructor(
pet: IPet,
entity: NMSInsentientEntity,
hookType: EntityHookType
) : EntityInsentientPet(pet, entity, hookType), IEntityParrotPet
) : EntityInsentientPet(pet, entity, hookType), IEntityParrotPet {
override fun initiateEntityPet() {
super.initiateEntityPet()
// If we're sitting, we can't move
(this.bukkitEntity as Parrot).isSitting = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@

import com.google.common.collect.ImmutableList;

import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityInsentient;
import net.minecraft.server.v1_12_R1.EntityLiving;
import net.minecraft.server.v1_12_R1.GenericAttributes;
import net.minecraft.server.v1_12_R1.Navigation;
import net.minecraft.server.v1_12_R1.PathfinderGoalSelector;
import net.minecraft.server.v1_12_R1.SoundEffect;
import net.minecraft.server.v1_12_R1.*;
import net.techcable.pineapple.reflection.PineappleField;
import net.techcable.pineapple.reflection.Reflection;
import net.techcable.sonarpet.nms.NMSInsentientEntity;
Expand Down Expand Up @@ -77,7 +71,10 @@ public void jump() {

@Override
public void setCanSwim(boolean b) {
((Navigation) getHandle().getNavigation()).c(b);
NavigationAbstract navigation = getHandle().getNavigation();
if (navigation instanceof Navigation) {
((Navigation) navigation).c(b);
}
}

//
Expand All @@ -102,7 +99,7 @@ public void setTarget(LivingEntity target) {

@Override
public net.techcable.sonarpet.nms.Navigation getNavigation() {
return new NavigationImpl((Navigation) getHandle().getNavigation());
return new NavigationImpl((NavigationAbstract) getHandle().getNavigation());
}

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import lombok.*;

import net.minecraft.server.v1_12_R1.Navigation;
import net.minecraft.server.v1_12_R1.NavigationAbstract;
import net.techcable.sonarpet.nms.PathEntity;

import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;

@RequiredArgsConstructor
public class NavigationImpl implements net.techcable.sonarpet.nms.Navigation {
private final Navigation handle;
private final NavigationAbstract handle;


//
Expand All @@ -19,7 +20,7 @@ public class NavigationImpl implements net.techcable.sonarpet.nms.Navigation {

@Override
public boolean canEnterDoors() {
return handle.g(); // PathNavigateGround.getEnterDoors
return handle.r().c(); // PathNavigate.getNodeProcessor().getCanEnterDoors()
}

@Override
Expand Down

0 comments on commit ebdecd7

Please sign in to comment.