Fixes for 1.11

This commit is contained in:
fullwall 2016-11-17 17:00:16 +08:00
parent 0189157400
commit dccfadb846
17 changed files with 502 additions and 306 deletions

View File

@ -12,7 +12,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.10-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.11-R0.1-SNAPSHOT</craftbukkit.version>
<citizensapi.version>2.0.21-SNAPSHOT</citizensapi.version>
<vault.version>1.5.4</vault.version>
<powermock.version>1.4.12</powermock.version>

View File

@ -23,16 +23,14 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@ -79,7 +77,6 @@ import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.trait.Gravity;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.trait.LookClose;
import net.citizensnpcs.trait.NPCSkeletonType;
import net.citizensnpcs.trait.OcelotModifiers;
import net.citizensnpcs.trait.Poses;
import net.citizensnpcs.trait.Powered;
@ -92,7 +89,6 @@ import net.citizensnpcs.trait.SlimeSize;
import net.citizensnpcs.trait.VillagerProfession;
import net.citizensnpcs.trait.WitherTrait;
import net.citizensnpcs.trait.WolfModifiers;
import net.citizensnpcs.trait.ZombieModifier;
import net.citizensnpcs.util.Anchor;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -624,23 +620,6 @@ public class NPCCommands {
Messaging.sendTr(sender, key, npc.getName());
}
@Command(
aliases = { "npc" },
usage = "guardian --elder [true|false]",
desc = "Changes guardian modifiers",
modifiers = { "guardian" },
min = 1,
max = 2,
permission = "citizens.npc.guardian")
@Requirements(selected = true, ownership = true, types = { EntityType.GUARDIAN })
public void guardian(CommandContext args, CommandSender sender, NPC npc) {
Guardian guardian = (Guardian) npc.getEntity();
if (args.hasValueFlag("elder")) {
guardian.setElder(args.getFlag("elder", "false").equals("true") ? true : false);
Messaging.sendTr(sender, guardian.isElder() ? Messages.ELDER_SET : Messages.ELDER_UNSET, npc.getName());
}
}
@Command(
aliases = { "npc" },
usage = "horse (--color color) (--type type) (--style style) (-cb)",
@ -651,8 +630,11 @@ public class NPCCommands {
max = 1,
flags = "cb",
permission = "citizens.npc.horse")
@Requirements(selected = true, ownership = true, types = { EntityType.HORSE })
@Requirements(selected = true, ownership = true)
public void horse(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
if (!(npc.getEntity() instanceof Horse)) {
throw new CommandException(Messages.INVALID_ENTITY_TYPE);
}
HorseModifiers horse = npc.getTrait(HorseModifiers.class);
String output = "";
if (args.hasFlag('c')) {
@ -672,15 +654,6 @@ public class NPCCommands {
horse.setColor(color);
output += Messaging.tr(Messages.HORSE_COLOR_SET, Util.prettyEnum(color));
}
if (args.hasValueFlag("type")) {
Variant variant = Util.matchEnum(Variant.values(), args.getFlag("type"));
if (variant == null) {
String valid = Util.listValuesPretty(Variant.values());
throw new CommandException(Messages.INVALID_HORSE_VARIANT, valid);
}
horse.setType(variant);
output += Messaging.tr(Messages.HORSE_TYPE_SET, Util.prettyEnum(variant));
}
if (args.hasValueFlag("style")) {
Style style = Util.matchEnum(Style.values(), args.getFlag("style"));
if (style == null) {
@ -692,7 +665,7 @@ public class NPCCommands {
}
if (output.isEmpty()) {
Messaging.sendTr(sender, Messages.HORSE_DESCRIBE, Util.prettyEnum(horse.getColor()),
Util.prettyEnum(horse.getType()), Util.prettyEnum(horse.getStyle()));
Util.prettyEnum(horse.getNPC().getEntity().getType()), Util.prettyEnum(horse.getStyle()));
} else {
sender.sendMessage(output);
}
@ -1467,26 +1440,6 @@ public class NPCCommands {
}
}
@Command(
aliases = { "npc" },
usage = "skeletontype [type]",
desc = "Sets the NPC's skeleton type",
modifiers = { "skeletontype", "sktype" },
min = 2,
max = 2,
permission = "citizens.npc.skeletontype")
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
SkeletonType type;
try {
type = SkeletonType.valueOf(args.getString(1).toUpperCase());
} catch (IllegalArgumentException ex) {
throw new CommandException(Messages.INVALID_SKELETON_TYPE, StringUtils.join(SkeletonType.values(), ","));
}
npc.getTrait(NPCSkeletonType.class).setType(type);
Messaging.sendTr(sender, Messages.SKELETON_TYPE_SET, npc.getName(), type);
}
@Command(
aliases = { "npc" },
usage = "skin (-c -p) [name]",
@ -1962,36 +1915,4 @@ public class NPCCommands {
Messaging.sendTr(sender, Messages.WOLF_TRAIT_UPDATED, npc.getName(), args.hasFlag('a'), args.hasFlag('s'),
args.hasFlag('t'), trait.getCollarColor().name());
}
@Command(
aliases = { "npc" },
usage = "zombiemod (-b(aby), -v(illager) --p(rofession) [profession])",
desc = "Sets a zombie NPC to be a baby or villager",
modifiers = { "zombie", "zombiemod" },
flags = "bv",
min = 1,
max = 1,
permission = "citizens.npc.zombiemodifier")
@Requirements(selected = true, ownership = true, types = { EntityType.ZOMBIE, EntityType.PIG_ZOMBIE })
public void zombieModifier(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
ZombieModifier trait = npc.getTrait(ZombieModifier.class);
if (args.hasFlag('b')) {
boolean isBaby = trait.toggleBaby();
Messaging.sendTr(sender, isBaby ? Messages.ZOMBIE_BABY_SET : Messages.ZOMBIE_BABY_UNSET, npc.getName());
}
if (args.hasFlag('v')) {
boolean isVillager = trait.toggleVillager();
Messaging.sendTr(sender, isVillager ? Messages.ZOMBIE_VILLAGER_SET : Messages.ZOMBIE_VILLAGER_UNSET,
npc.getName());
}
if (args.hasValueFlag("profession") || args.hasValueFlag("p")) {
Profession profession = Util.matchEnum(Profession.values(), args.getFlag("profession", args.getFlag("p")));
if (profession == null) {
throw new CommandException();
}
trait.setProfession(profession);
Messaging.sendTr(sender, Messages.ZOMBIE_VILLAGER_PROFESSION_SET, npc.getName(),
Util.prettyEnum(profession));
}
}
}

View File

@ -109,5 +109,13 @@ public class EquipmentEditor extends Editor {
EQUIPPERS.put(EntityType.SHEEP, new SheepEquipper());
EQUIPPERS.put(EntityType.ENDERMAN, new EndermanEquipper());
EQUIPPERS.put(EntityType.HORSE, new HorseEquipper());
try {
EQUIPPERS.put(EntityType.valueOf("ZOMBIE_HORSE"), new HorseEquipper());
EQUIPPERS.put(EntityType.valueOf("LLAMA"), new HorseEquipper());
EQUIPPERS.put(EntityType.valueOf("DONKEY"), new HorseEquipper());
EQUIPPERS.put(EntityType.valueOf("MULE"), new HorseEquipper());
EQUIPPERS.put(EntityType.valueOf("SKELETON_HORSE"), new HorseEquipper());
} catch (IllegalArgumentException ex) {
}
}
}

View File

@ -38,7 +38,6 @@ import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.CitizensBlockBreaker;
import net.citizensnpcs.npc.ai.CitizensNavigator;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.CurrentLocation;
@ -106,7 +105,7 @@ public class CitizensNPC extends AbstractNPC {
@Override
public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreakerConfiguration config) {
return new CitizensBlockBreaker(getEntity(), targetBlock, config);
return NMS.getBlockBreaker(getEntity(), targetBlock, config);
}
@Override

View File

@ -32,7 +32,6 @@ import net.citizensnpcs.trait.Gravity;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.trait.LookClose;
import net.citizensnpcs.trait.MountTrait;
import net.citizensnpcs.trait.NPCSkeletonType;
import net.citizensnpcs.trait.OcelotModifiers;
import net.citizensnpcs.trait.Poses;
import net.citizensnpcs.trait.Powered;
@ -46,7 +45,6 @@ import net.citizensnpcs.trait.VillagerProfession;
import net.citizensnpcs.trait.WitherTrait;
import net.citizensnpcs.trait.WolfModifiers;
import net.citizensnpcs.trait.WoolColor;
import net.citizensnpcs.trait.ZombieModifier;
import net.citizensnpcs.trait.text.Text;
import net.citizensnpcs.trait.waypoint.Waypoints;
@ -76,7 +74,6 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(SheepTrait.class));
registerTrait(TraitInfo.create(SkinLayers.class));
registerTrait(TraitInfo.create(MountTrait.class));
registerTrait(TraitInfo.create(NPCSkeletonType.class));
registerTrait(TraitInfo.create(SlimeSize.class));
registerTrait(TraitInfo.create(Spawned.class));
registerTrait(TraitInfo.create(Speech.class));
@ -87,7 +84,6 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(WoolColor.class));
registerTrait(TraitInfo.create(WolfModifiers.class));
registerTrait(TraitInfo.create(VillagerProfession.class));
registerTrait(TraitInfo.create(ZombieModifier.class));
for (String trait : registered.keySet()) {
INTERNAL_TRAITS.add(trait);

View File

@ -3,7 +3,6 @@ package net.citizensnpcs.trait;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.inventory.ItemStack;
import net.citizensnpcs.api.persistence.Persist;
@ -22,8 +21,6 @@ public class HorseModifiers extends Trait {
private ItemStack saddle = null;
@Persist("style")
private Style style = Style.NONE;
@Persist("type")
private Variant type = Variant.HORSE;
public HorseModifiers() {
super("horsemodifiers");
@ -45,10 +42,6 @@ public class HorseModifiers extends Trait {
return style;
}
public Variant getType() {
return type;
}
@Override
public void onSpawn() {
updateModifiers();
@ -86,18 +79,11 @@ public class HorseModifiers extends Trait {
updateModifiers();
}
public void setType(Horse.Variant type) {
this.type = type;
updateModifiers();
}
private void updateModifiers() {
if (npc.getEntity() instanceof Horse) {
Horse horse = (Horse) npc.getEntity();
horse.setCarryingChest(carryingChest);
horse.setColor(color);
horse.setStyle(style);
horse.setVariant(type);
horse.getInventory().setArmor(armor);
horse.getInventory().setSaddle(saddle);
}

View File

@ -1,34 +0,0 @@
package net.citizensnpcs.trait;
import org.bukkit.entity.Skeleton;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("skeletontype")
public class NPCSkeletonType extends Trait {
private Skeleton skeleton;
@Persist
private org.bukkit.entity.Skeleton.SkeletonType type = org.bukkit.entity.Skeleton.SkeletonType.NORMAL;
public NPCSkeletonType() {
super("skeletontype");
}
@Override
public void onSpawn() {
skeleton = npc.getEntity() instanceof Skeleton ? (Skeleton) npc.getEntity() : null;
}
@Override
public void run() {
if (skeleton != null) {
skeleton.setSkeletonType(type);
}
}
public void setType(org.bukkit.entity.Skeleton.SkeletonType type) {
this.type = type;
}
}

View File

@ -1,58 +0,0 @@
package net.citizensnpcs.trait;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.entity.Zombie;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("zombiemodifier")
public class ZombieModifier extends Trait {
@Persist
private boolean baby;
@Persist
private Profession profession;
@Persist
private boolean villager;
private boolean zombie;
public ZombieModifier() {
super("zombiemodifier");
}
@Override
public void onSpawn() {
if (npc.getEntity() instanceof Zombie) {
((Zombie) npc.getEntity()).setVillager(villager);
((Zombie) npc.getEntity()).setBaby(baby);
((Zombie) npc.getEntity()).setVillagerProfession(profession);
zombie = true;
} else {
zombie = false;
}
}
public void setProfession(Profession profession) {
this.profession = profession;
if (zombie) {
((Zombie) npc.getEntity()).setVillagerProfession(profession);
}
}
public boolean toggleBaby() {
baby = !baby;
if (zombie) {
((Zombie) npc.getEntity()).setBaby(baby);
}
return baby;
}
public boolean toggleVillager() {
villager = !villager;
if (zombie) {
((Zombie) npc.getEntity()).setVillager(villager);
}
return villager;
}
}

View File

@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
@ -22,6 +23,8 @@ import com.mojang.authlib.GameProfileRepository;
import net.citizensnpcs.api.ai.NavigatorParameters;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.util.Messaging;
@ -54,6 +57,10 @@ public class NMS {
return BRIDGE.fillProfileProperties(profile, requireSecure);
}
public static BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config) {
return BRIDGE.getBlockBreaker(entity, targetBlock, config);
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
return BRIDGE.getBossBar(entity);
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
@ -22,6 +23,8 @@ import com.mojang.authlib.GameProfileRepository;
import net.citizensnpcs.api.ai.NavigatorParameters;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
@ -37,6 +40,8 @@ public interface NMSBridge {
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception;
public BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config);
public BossBar getBossBar(Entity entity);
public BoundingBox getBoundingBox(Entity handle);

View File

@ -99,6 +99,8 @@ public class Util {
}
public static boolean isAlwaysFlyable(EntityType type) {
if (type.name().toLowerCase().contains("vex")) // 1.11 compatibility
return true;
switch (type) {
case BAT:
case BLAZE:

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.npc.ai;
package net.citizensnpcs.nms.v1_10_R1.util;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import net.citizensnpcs.api.ai.tree.BehaviorStatus;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.PlayerAnimation;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.BlockPosition;

View File

@ -58,6 +58,8 @@ import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.ai.NavigatorParameters;
import net.citizensnpcs.api.ai.event.CancelReason;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.util.Messaging;
@ -280,6 +282,12 @@ public class NMSImpl implements NMSBridge {
return Setting.AUTH_SERVER_URL.asString();
}
@Override
public BlockBreaker getBlockBreaker(org.bukkit.entity.Entity entity, org.bukkit.block.Block targetBlock,
BlockBreakerConfiguration config) {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
@ -1319,6 +1327,7 @@ public class NMSImpl implements NMSBridge {
private static final Random RANDOM = Util.getFastRandom();
private static Field SKULL_PROFILE_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bG");
static {

View File

@ -0,0 +1,167 @@
package net.citizensnpcs.nms.v1_11_R1.entity;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftVex;
import org.bukkit.entity.Vex;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.EntityVex;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
import net.minecraft.server.v1_11_R1.SoundEffect;
import net.minecraft.server.v1_11_R1.World;
public class VexController extends MobEntityController {
public VexController() {
super(EntityVexNPC.class);
}
@Override
public Vex getBukkitEntity() {
return (Vex) super.getBukkitEntity();
}
public static class EntityVexNPC extends EntityVex implements NPCHolder {
private final CitizensNPC npc;
public EntityVexNPC(World world) {
this(world, null);
}
public EntityVexNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
}
}
@Override
protected SoundEffect bW() {
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA);
}
@Override
protected SoundEffect bX() {
return NMSImpl.getSoundEffect(npc, super.bX(), NPC.HURT_SOUND_METADATA);
}
@Override
public void collide(net.minecraft.server.v1_11_R1.Entity entity) {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
}
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
}
@Override
public void f(double x, double y, double z) {
if (npc == null) {
super.f(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
super.f(x, y, z);
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.f(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}
@Override
protected SoundEffect G() {
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
}
@Override
public CraftEntity getBukkitEntity() {
if (bukkitEntity == null && npc != null)
bukkitEntity = new VexNPC(this);
return super.getBukkitEntity();
}
@Override
public NPC getNPC() {
return npc;
}
@Override
public boolean isLeashed() {
if (npc == null) {
return super.isLeashed();
}
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
}
@Override
protected void L() {
if (npc == null) {
super.L();
}
}
@Override
public void M() {
if (npc == null) {
super.M();
} else {
NMSImpl.updateAI(this);
npc.update();
}
}
}
public static class VexNPC extends CraftVex implements NPCHolder {
private final CitizensNPC npc;
public VexNPC(EntityVexNPC entity) {
super((CraftServer) Bukkit.getServer(), entity);
this.npc = entity.npc;
}
@Override
public NPC getNPC() {
return npc;
}
}
}

View File

@ -0,0 +1,173 @@
package net.citizensnpcs.nms.v1_11_R1.util;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import net.citizensnpcs.api.ai.tree.BehaviorStatus;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.PlayerAnimation;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Blocks;
import net.minecraft.server.v1_11_R1.EnchantmentManager;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityLiving;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.EnumItemSlot;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.Material;
import net.minecraft.server.v1_11_R1.MobEffects;
public class CitizensBlockBreaker extends BlockBreaker {
private final BlockBreakerConfiguration configuration;
private int currentDamage;
private int currentTick;
private final Entity entity;
private boolean isDigging = true;
private final Location location;
private int startDigTick;
private final int x, y, z;
public CitizensBlockBreaker(org.bukkit.entity.Entity entity, org.bukkit.block.Block target,
BlockBreakerConfiguration config) {
this.entity = ((CraftEntity) entity).getHandle();
this.x = target.getX();
this.y = target.getY();
this.z = target.getZ();
this.location = target.getLocation();
this.startDigTick = (int) (System.currentTimeMillis() / 50);
this.configuration = config;
}
private double distanceSquared() {
return Math.pow(entity.locX - x, 2) + Math.pow(entity.locY - y, 2) + Math.pow(entity.locZ - z, 2);
}
private net.minecraft.server.v1_11_R1.ItemStack getCurrentItem() {
return configuration.item() != null ? CraftItemStack.asNMSCopy(configuration.item())
: entity instanceof EntityLiving ? ((EntityLiving) entity).getEquipment(EnumItemSlot.MAINHAND) : null;
}
private float getStrength(IBlockData block) {
float base = block.getBlock().a(block, null, new BlockPosition(0, 0, 0));
return base < 0.0F ? 0.0F : (!isDestroyable(block) ? 1.0F / base / 100.0F : strengthMod(block) / base / 30.0F);
}
private boolean isDestroyable(IBlockData block) {
if (block.getMaterial().isAlwaysDestroyable()) {
return true;
} else {
ItemStack current = getCurrentItem();
return current != null ? current.b(block) : false;
}
}
@Override
public void reset() {
if (configuration.callback() != null) {
configuration.callback().run();
}
isDigging = false;
setBlockDamage(currentDamage = -1);
}
@Override
public BehaviorStatus run() {
if (entity.dead) {
return BehaviorStatus.FAILURE;
}
if (!isDigging) {
return BehaviorStatus.SUCCESS;
}
currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
if (configuration.radiusSquared() > 0 && distanceSquared() >= configuration.radiusSquared()) {
startDigTick = currentTick;
if (entity instanceof NPCHolder) {
NPC npc = ((NPCHolder) entity).getNPC();
if (npc != null && !npc.getNavigator().isNavigating()) {
npc.getNavigator()
.setTarget(entity.world.getWorld().getBlockAt(x, y, z).getLocation().add(0, 1, 0));
}
}
return BehaviorStatus.RUNNING;
}
Util.faceLocation(entity.getBukkitEntity(), location);
if (entity instanceof EntityPlayer) {
PlayerAnimation.ARM_SWING.play((Player) entity.getBukkitEntity());
}
IBlockData block = entity.world.getType(new BlockPosition(x, y, z));
if (block == null || block == Blocks.AIR) {
return BehaviorStatus.SUCCESS;
} else {
int tickDifference = currentTick - startDigTick;
float damage = getStrength(block) * (tickDifference + 1) * configuration.blockStrengthModifier();
if (damage >= 1F) {
entity.world.getWorld().getBlockAt(x, y, z)
.breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
return BehaviorStatus.SUCCESS;
}
int modifiedDamage = (int) (damage * 10.0F);
if (modifiedDamage != currentDamage) {
setBlockDamage(modifiedDamage);
currentDamage = modifiedDamage;
}
}
return BehaviorStatus.RUNNING;
}
private void setBlockDamage(int modifiedDamage) {
entity.world.c(entity.getId(), new BlockPosition(x, y, z), modifiedDamage);
}
@Override
public boolean shouldExecute() {
return entity.world.getType(new BlockPosition(x, y, z)).getBlock() != Blocks.AIR;
}
private float strengthMod(IBlockData block) {
ItemStack itemstack = getCurrentItem();
float f = itemstack.a(block);
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) entity;
if (f > 1.0F) {
int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
if (i > 0) {
f += i * i + 1;
}
}
if (handle.hasEffect(MobEffects.FASTER_DIG)) {
f *= (1.0F + (handle.getEffect(MobEffects.FASTER_DIG).getAmplifier() + 1) * 0.2F);
}
if (handle.hasEffect(MobEffects.SLOWER_DIG)) {
float f1 = 1.0F;
switch (handle.getEffect(MobEffects.SLOWER_DIG).getAmplifier()) {
case 0:
f1 = 0.3F;
break;
case 1:
f1 = 0.09F;
break;
case 2:
f1 = 0.0027F;
break;
case 3:
default:
f1 = 8.1E-4F;
}
f *= f1;
}
if ((handle.a(Material.WATER)) && (!EnchantmentManager.i(handle))) {
f /= 5.0F;
}
}
if (!entity.onGround) {
f /= 5.0F;
}
return f;
}
}

View File

@ -57,6 +57,8 @@ import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.ai.NavigatorParameters;
import net.citizensnpcs.api.ai.event.CancelReason;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.util.Messaging;
@ -100,6 +102,7 @@ import net.citizensnpcs.nms.v1_11_R1.entity.SlimeController;
import net.citizensnpcs.nms.v1_11_R1.entity.SnowmanController;
import net.citizensnpcs.nms.v1_11_R1.entity.SpiderController;
import net.citizensnpcs.nms.v1_11_R1.entity.SquidController;
import net.citizensnpcs.nms.v1_11_R1.entity.VexController;
import net.citizensnpcs.nms.v1_11_R1.entity.VillagerController;
import net.citizensnpcs.nms.v1_11_R1.entity.VindicatorController;
import net.citizensnpcs.nms.v1_11_R1.entity.WitchController;
@ -295,6 +298,12 @@ public class NMSImpl implements NMSBridge {
return Setting.AUTH_SERVER_URL.asString();
}
@Override
public BlockBreaker getBlockBreaker(org.bukkit.entity.Entity entity, org.bukkit.block.Block targetBlock,
BlockBreakerConfiguration config) {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
@ -579,6 +588,7 @@ public class NMSImpl implements NMSBridge {
EntityControllers.setEntityControllerForType(EntityType.TIPPED_ARROW, TippedArrowController.class);
EntityControllers.setEntityControllerForType(EntityType.THROWN_EXP_BOTTLE, ThrownExpBottleController.class);
EntityControllers.setEntityControllerForType(EntityType.PRIMED_TNT, TNTPrimedController.class);
EntityControllers.setEntityControllerForType(EntityType.VEX, VexController.class);
EntityControllers.setEntityControllerForType(EntityType.VILLAGER, VillagerController.class);
EntityControllers.setEntityControllerForType(EntityType.VINDICATOR, VindicatorController.class);
EntityControllers.setEntityControllerForType(EntityType.WOLF, WolfController.class);

View File

@ -3,6 +3,8 @@ package net.citizensnpcs.nms.v1_11_R1.util;
import java.util.EnumSet;
import java.util.HashSet;
import com.google.common.collect.Sets;
import net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Block;
@ -28,57 +30,59 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
@Override
public void a() {
super.a();
this.b.a(PathType.WATER, this.j);
super.a();
}
@Override
public PathPoint a(double paramDouble1, double paramDouble2, double paramDouble3) {
return a(MathHelper.floor(paramDouble1 - this.b.width / 2.0F), MathHelper.floor(paramDouble2),
MathHelper.floor(paramDouble3 - this.b.width / 2.0F));
return a(MathHelper.floor(paramDouble1), MathHelper.floor(paramDouble2), MathHelper.floor(paramDouble3));
}
private PathType a(EntityHumanNPC paramEntityInsentient, BlockPosition paramBlockPosition) {
return a(this.a, paramBlockPosition.getX(), paramBlockPosition.getY(), paramBlockPosition.getZ(),
paramEntityInsentient, this.d, this.e, this.f, d(), c());
return a(paramEntityInsentient, paramBlockPosition.getX(), paramBlockPosition.getY(),
paramBlockPosition.getZ());
}
private PathType a(EntityHumanNPC paramEntityInsentient, int paramInt1, int paramInt2, int paramInt3) {
return a(this.a, paramInt1, paramInt2, paramInt3, paramEntityInsentient, this.d, this.e, this.f, d(), c());
}
@Override
public void a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient) {
super.a(paramIBlockAccess, paramEntityInsentient);
this.j = paramEntityInsentient.a(PathType.WATER);
}
@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
PathType localPathType1 = getPathTypeBase(paramIBlockAccess, paramInt1, paramInt2, paramInt3);
PathType localPathType1 = b(paramIBlockAccess, paramInt1, paramInt2, paramInt3);
if ((localPathType1 == PathType.OPEN) && (paramInt2 >= 1)) {
PathType localPathType2 = localPathType1;
while (localPathType2 == PathType.OPEN && (--paramInt2 >= 1)) {
localPathType2 = getPathTypeBase(paramIBlockAccess, paramInt1, paramInt2, paramInt3);
}
Block localObject = paramIBlockAccess.getType(new BlockPosition(paramInt1, paramInt2 - 1, paramInt3))
.getBlock();
PathType localPathType2 = b(paramIBlockAccess, paramInt1, paramInt2 - 1, paramInt3);
localPathType1 = (localPathType2 == PathType.WALKABLE) || (localPathType2 == PathType.OPEN)
|| (localPathType2 == PathType.WATER) || (localPathType2 == PathType.LAVA) ? PathType.OPEN
: PathType.WALKABLE;
if ((localPathType2 == PathType.DAMAGE_FIRE) || (localObject == Blocks.df)) {
localPathType1 = PathType.DAMAGE_FIRE;
}
if (localPathType2 == PathType.DAMAGE_CACTUS) {
localPathType1 = PathType.DAMAGE_CACTUS;
}
}
Object localObject = BlockPosition.PooledBlockPosition.s();
if (localPathType1 == PathType.WALKABLE) {
for (int i = paramInt1 - 1; i <= paramInt1 + 1; i++) {
for (int k = paramInt3 - 1; k <= paramInt3 + 1; k++) {
if ((i != paramInt1) || (k != paramInt3)) {
Block localBlock2 = paramIBlockAccess.getType(new BlockPosition(i, paramInt2, k)).getBlock();
if (localBlock2 == Blocks.CACTUS) {
for (int i = -1; i <= 1; i++) {
for (int k = -1; k <= 1; k++) {
if ((i != 0) || (k != 0)) {
Block localBlock = paramIBlockAccess.getType(((BlockPosition.PooledBlockPosition) localObject)
.f(i + paramInt1, paramInt2, k + paramInt3)).getBlock();
if (localBlock == Blocks.CACTUS) {
localPathType1 = PathType.DANGER_CACTUS;
} else if (localBlock2 == Blocks.FIRE) {
} else if (localBlock == Blocks.FIRE) {
localPathType1 = PathType.DANGER_FIRE;
}
}
}
}
}
((BlockPosition.PooledBlockPosition) localObject).t();
return localPathType1;
}
@ -87,14 +91,17 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1,
boolean paramBoolean2) {
EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
Object localObject1 = PathType.BLOCKED;
PathType localObject1 = PathType.BLOCKED;
double d = paramEntityInsentient.width / 2.0D;
BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
PathType localPathType2 = a(paramIBlockAccess, i, k, m);
for (int i = 0; i < paramInt4; i++) {
for (int k = 0; k < paramInt5; k++) {
for (int m = 0; m < paramInt6; m++) {
int n = i + paramInt1;
int i1 = k + paramInt2;
int i2 = m + paramInt3;
PathType localPathType2 = a(paramIBlockAccess, n, i1, i2);
if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
localPathType2 = PathType.WALKABLE;
}
@ -108,16 +115,9 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
.getBlock() instanceof BlockMinecartTrackAbstract))) {
localPathType2 = PathType.FENCE;
}
if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
if ((i == 0) && (k == 0) && (m == 0)) {
localObject1 = localPathType2;
}
if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D,
m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
localPathType2 = PathType.OPEN;
}
}
localEnumSet.add(localPathType2);
}
}
@ -125,19 +125,19 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
if (localEnumSet.contains(PathType.FENCE)) {
return PathType.FENCE;
}
Object localObject2 = PathType.BLOCKED;
PathType localObject2 = PathType.BLOCKED;
for (PathType localPathType1 : localEnumSet) {
if (paramEntityInsentient.a(localPathType1) < 0.0F) {
return localPathType1;
}
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a(localObject2)) {
localObject2 = localPathType1;
}
}
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a(localObject2) == 0.0F)) {
return PathType.OPEN;
}
return (PathType) localObject2;
return localObject2;
}
@Override
@ -145,14 +145,17 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
EntityInsentient paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1,
boolean paramBoolean2) {
EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
Object localObject1 = PathType.BLOCKED;
PathType localObject1 = PathType.BLOCKED;
double d = paramEntityInsentient.width / 2.0D;
BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
PathType localPathType2 = a(paramIBlockAccess, i, k, m);
for (int i = 0; i < paramInt4; i++) {
for (int k = 0; k < paramInt5; k++) {
for (int m = 0; m < paramInt6; m++) {
int n = i + paramInt1;
int i1 = k + paramInt2;
int i2 = m + paramInt3;
PathType localPathType2 = a(paramIBlockAccess, n, i1, i2);
if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
localPathType2 = PathType.WALKABLE;
}
@ -166,16 +169,9 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
.getBlock() instanceof BlockMinecartTrackAbstract))) {
localPathType2 = PathType.FENCE;
}
if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
if ((i == 0) && (k == 0) && (m == 0)) {
localObject1 = localPathType2;
}
if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D,
m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
localPathType2 = PathType.OPEN;
}
}
localEnumSet.add(localPathType2);
}
}
@ -183,19 +179,19 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
if (localEnumSet.contains(PathType.FENCE)) {
return PathType.FENCE;
}
Object localObject2 = PathType.BLOCKED;
PathType localObject2 = PathType.BLOCKED;
for (PathType localPathType1 : localEnumSet) {
if (paramEntityInsentient.a(localPathType1) < 0.0F) {
return localPathType1;
}
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a(localObject2)) {
localObject2 = localPathType1;
}
}
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a(localObject2) == 0.0F)) {
return PathType.OPEN;
}
return (PathType) localObject2;
return localObject2;
}
private PathPoint a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, double paramDouble,
@ -204,56 +200,67 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
BlockPosition localBlockPosition1 = new BlockPosition(paramInt1, paramInt2, paramInt3);
BlockPosition localBlockPosition2 = localBlockPosition1.down();
double d1 = paramInt2 - (1.0D - this.a.getType(localBlockPosition2).c(this.a, localBlockPosition2).e);
if (d1 - paramDouble > 1.0D) {
double d1 = paramInt2 - (1.0D - this.a.getType(localBlockPosition2).d(this.a, localBlockPosition2).e);
if (d1 - paramDouble > 1.125D) {
return null;
}
PathType localPathType = a(this.b, paramInt1, paramInt2, paramInt3);
float f = this.b.a(localPathType);
PathType localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);
float f = this.b.a(localPathType1);
double d2 = this.b.width / 2.0D;
if (f >= 0.0F) {
localPathPoint = a(paramInt1, paramInt2, paramInt3);
localPathPoint.m = localPathType;
localPathPoint.m = localPathType1;
localPathPoint.l = Math.max(localPathPoint.l, f);
}
if (localPathType == PathType.WALKABLE) {
if (localPathType1 == PathType.WALKABLE) {
return localPathPoint;
}
if ((localPathPoint == null) && (paramInt4 > 0) && (localPathType != PathType.FENCE)
&& (localPathType != PathType.TRAPDOOR)) {
if ((localPathPoint == null) && (paramInt4 > 0) && (localPathType1 != PathType.FENCE)
&& (localPathType1 != PathType.TRAPDOOR)) {
localPathPoint = a(paramInt1, paramInt2 + 1, paramInt3, paramInt4 - 1, paramDouble, paramEnumDirection);
if ((localPathPoint != null)
&& ((localPathPoint.m == PathType.OPEN) || (localPathPoint.m == PathType.WALKABLE))) {
&& ((localPathPoint.m == PathType.OPEN) || (localPathPoint.m == PathType.WALKABLE))
&& (this.b.width < 1.0F)) {
double d3 = paramInt1 - paramEnumDirection.getAdjacentX() + 0.5D;
double d4 = paramInt3 - paramEnumDirection.getAdjacentZ() + 0.5D;
AxisAlignedBB localAxisAlignedBB1 = new AxisAlignedBB(d3 - d2, paramInt2 + 0.001D, d4 - d2, d3 + d2,
paramInt2 + this.b.length, d4 + d2);
AxisAlignedBB localAxisAlignedBB2 = this.a.getType(localBlockPosition1).c(this.a, localBlockPosition1);
AxisAlignedBB localAxisAlignedBB2 = this.a.getType(localBlockPosition1).d(this.a, localBlockPosition1);
AxisAlignedBB localAxisAlignedBB3 = localAxisAlignedBB1.a(0.0D, localAxisAlignedBB2.e - 0.002D, 0.0D);
AxisAlignedBB localAxisAlignedBB3 = localAxisAlignedBB1.b(0.0D, localAxisAlignedBB2.e - 0.002D, 0.0D);
if (this.b.world.b(localAxisAlignedBB3)) {
localPathPoint = null;
}
}
}
if (localPathType == PathType.OPEN) {
if (localPathType1 == PathType.OPEN) {
AxisAlignedBB localAxisAlignedBB4 = new AxisAlignedBB(paramInt1 - d2 + 0.5D, paramInt2 + 0.001D,
paramInt3 - d2 + 0.5D, paramInt1 + d2 + 0.5D, paramInt2 + this.b.length, paramInt3 + d2 + 0.5D);
if (this.b.world.b(localAxisAlignedBB4)) {
return null;
}
if (this.b.width >= 1.0F) {
PathType localPathType2 = a(this.b, paramInt1, paramInt2 - 1, paramInt3);
if (localPathType2 == PathType.BLOCKED) {
localPathPoint = a(paramInt1, paramInt2, paramInt3);
localPathPoint.m = PathType.WALKABLE;
localPathPoint.l = Math.max(localPathPoint.l, f);
return localPathPoint;
}
}
int i = 0;
while ((paramInt2 > 0) && (localPathType == PathType.OPEN)) {
while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) {
paramInt2--;
if (i++ >= this.b.aY()) {
return null;
}
localPathType = a(this.b, paramInt1, paramInt2, paramInt3);
f = this.b.a(localPathType);
if ((localPathType != PathType.OPEN) && (f >= 0.0F)) {
localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);
f = this.b.a(localPathType1);
if ((localPathType1 != PathType.OPEN) && (f >= 0.0F)) {
localPathPoint = a(paramInt1, paramInt2, paramInt3);
localPathPoint.m = localPathType;
localPathPoint.m = localPathType1;
localPathPoint.l = Math.max(localPathPoint.l, f);
} else if (f < 0.0F) {
return null;
@ -271,11 +278,11 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
int k = 0;
PathType localPathType = a(this.b, paramPathPoint1.a, paramPathPoint1.b + 1, paramPathPoint1.c);
if (this.b.a(localPathType) >= 0.0F) {
k = 1;
k = MathHelper.d(Math.max(1.0F, this.b.P));
}
BlockPosition localBlockPosition = new BlockPosition(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c)
.down();
double d = paramPathPoint1.b - (1.0D - this.a.getType(localBlockPosition).c(this.a, localBlockPosition).e);
double d = paramPathPoint1.b - (1.0D - this.a.getType(localBlockPosition).d(this.a, localBlockPosition).e);
PathPoint localPathPoint1 = a(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c + 1, k, d,
EnumDirection.SOUTH);
@ -356,7 +363,9 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
MathHelper.floor(this.b.locZ));
localObject2 = this.a.getType(localObject1).getBlock();
}
} else if (!this.b.onGround) {
} else if (this.b.onGround) {
i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
} else {
localObject1 = new BlockPosition(this.b);
while (((this.a.getType(localObject1).getMaterial() == Material.AIR)
|| (this.a.getType(localObject1).getBlock().b(this.a, localObject1)))
@ -364,13 +373,11 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
localObject1 = localObject1.down();
}
i = localObject1.up().getY();
} else {
i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
}
localObject1 = new BlockPosition(this.b);
Object localObject2 = a(this.b, localObject1.getX(), i, localObject1.getZ());
if (this.b.a((PathType) localObject2) < 0.0F) {
HashSet<BlockPosition> localHashSet = new HashSet<BlockPosition>();
HashSet<BlockPosition> localHashSet = Sets.newHashSet();
localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().c));
localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().f));
localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().c));
@ -385,55 +392,52 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
return a(localObject1.getX(), i, localObject1.getZ());
}
public PathType getPathTypeBase(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
private PathType b(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
BlockPosition localBlockPosition = new BlockPosition(paramInt1, paramInt2, paramInt3);
IBlockData localIBlockData = paramIBlockAccess.getType(localBlockPosition);
Block localBlock1 = localIBlockData.getBlock();
Block localBlock = localIBlockData.getBlock();
Material localMaterial = localIBlockData.getMaterial();
PathType localPathType1 = PathType.BLOCKED;
if ((localBlock1 == Blocks.TRAPDOOR) || (localBlock1 == Blocks.IRON_TRAPDOOR)
|| (localBlock1 == Blocks.WATERLILY)) {
if (localMaterial == Material.AIR) {
return PathType.OPEN;
}
if ((localBlock == Blocks.TRAPDOOR) || (localBlock == Blocks.IRON_TRAPDOOR)
|| (localBlock == Blocks.WATERLILY)) {
return PathType.TRAPDOOR;
}
if (localBlock1 == Blocks.FIRE) {
if (localBlock == Blocks.FIRE) {
return PathType.DAMAGE_FIRE;
}
if (localBlock1 == Blocks.CACTUS) {
if (localBlock == Blocks.CACTUS) {
return PathType.DAMAGE_CACTUS;
}
if (((localBlock1 instanceof BlockDoor)) && (localMaterial == Material.WOOD)
if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.WOOD)
&& (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_WOOD_CLOSED;
}
if (((localBlock1 instanceof BlockDoor)) && (localMaterial == Material.ORE)
if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.ORE)
&& (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_IRON_CLOSED;
}
if (((localBlock1 instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
if (((localBlock instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_OPEN;
}
if ((localBlock1 instanceof BlockMinecartTrackAbstract)) {
if ((localBlock instanceof BlockMinecartTrackAbstract)) {
return PathType.RAIL;
}
if (((localBlock1 instanceof BlockFence)) || ((localBlock1 instanceof BlockCobbleWall))
|| (((localBlock1 instanceof BlockFenceGate))
if (((localBlock instanceof BlockFence)) || ((localBlock instanceof BlockCobbleWall))
|| (((localBlock instanceof BlockFenceGate))
&& (!localIBlockData.get(BlockFenceGate.OPEN).booleanValue()))) {
return PathType.FENCE;
}
if (localMaterial == Material.AIR) {
localPathType1 = PathType.OPEN;
} else {
if (localMaterial == Material.WATER) {
return PathType.WATER;
}
if (localMaterial == Material.LAVA) {
return PathType.LAVA;
}
if (localMaterial == Material.WATER) {
return PathType.WATER;
}
if ((localBlock1.b(paramIBlockAccess, localBlockPosition)) && (localPathType1 == PathType.BLOCKED)) {
localPathType1 = PathType.OPEN;
if (localMaterial == Material.LAVA) {
return PathType.LAVA;
}
return localPathType1;
if (localBlock.b(paramIBlockAccess, localBlockPosition)) {
return PathType.OPEN;
}
return PathType.BLOCKED;
}
}