use of net.minecraft.server.v1_14_R1.Block in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method b.
protected PathType b(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
BlockPosition localBlockPosition = new BlockPosition(paramInt1, paramInt2, paramInt3);
IBlockData localIBlockData = paramIBlockAccess.getType(localBlockPosition);
Block localBlock = localIBlockData.getBlock();
Material localMaterial = localIBlockData.getMaterial();
if (localMaterial == Material.AIR) {
return PathType.OPEN;
}
if ((localBlock == Blocks.TRAPDOOR) || (localBlock == Blocks.IRON_TRAPDOOR) || (localBlock == Blocks.WATERLILY)) {
return PathType.TRAPDOOR;
}
if (localBlock == Blocks.FIRE) {
return PathType.DAMAGE_FIRE;
}
if (localBlock == Blocks.CACTUS) {
return PathType.DAMAGE_CACTUS;
}
if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.WOOD) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_WOOD_CLOSED;
}
if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.ORE) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_IRON_CLOSED;
}
if (((localBlock instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_OPEN;
}
if ((localBlock instanceof BlockMinecartTrackAbstract)) {
return PathType.RAIL;
}
if (((localBlock instanceof BlockFence)) || ((localBlock instanceof BlockCobbleWall)) || (((localBlock instanceof BlockFenceGate)) && (!localIBlockData.get(BlockFenceGate.OPEN).booleanValue()))) {
return PathType.FENCE;
}
if (localMaterial == Material.WATER) {
return PathType.WATER;
}
if (localMaterial == Material.LAVA) {
return PathType.LAVA;
}
if (localBlock.b(paramIBlockAccess, localBlockPosition)) {
return PathType.OPEN;
}
return PathType.BLOCKED;
}
use of net.minecraft.server.v1_14_R1.Block in project Citizens2 by CitizensDev.
the class PlayerNavigation method u.
private int u() {
if (!this.a.isInWater() || !r())
return MathHelper.floor(this.a.locY() + 0.5D);
int var0 = MathHelper.floor(this.a.locY());
Block var1 = this.b.getType(new BlockPosition(this.a.locX(), var0, this.a.locZ())).getBlock();
int var2 = 0;
while (var1 == Blocks.WATER) {
var0++;
var1 = this.b.getType(new BlockPosition(this.a.locX(), var0, this.a.locZ())).getBlock();
if (++var2 > 16)
return MathHelper.floor(this.a.locY());
}
return var0;
}
use of net.minecraft.server.v1_14_R1.Block in project Citizens2 by CitizensDev.
the class FallingBlockController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
Block id = Blocks.STONE;
int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
// TODO: how to incorporate this - probably delete?
if (npc.data().has("falling-block-id") || npc.data().has(NPC.ITEM_ID_METADATA)) {
id = CraftMagicNumbers.getBlock(Material.getMaterial(npc.data().<String>get(NPC.ITEM_ID_METADATA, npc.data().<String>get("falling-block-id"))));
}
final EntityFallingBlockNPC handle = new EntityFallingBlockNPC(ws, npc, at.getX(), at.getY(), at.getZ(), id.getBlockData());
return handle.getBukkitEntity();
}
use of net.minecraft.server.v1_14_R1.Block in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method b.
public static PathType b(IBlockAccess var0, int var1, int var2, int var3) {
PathType var4 = c(var0, var1, var2, var3);
if (var4 == PathType.OPEN && var2 >= 1) {
Block var5 = var0.getType(new BlockPosition(var1, var2 - 1, var3)).getBlock();
PathType var6 = c(var0, var1, var2 - 1, var3);
var4 = var6 != PathType.WALKABLE && var6 != PathType.OPEN && var6 != PathType.WATER && var6 != PathType.LAVA ? PathType.WALKABLE : PathType.OPEN;
if (var6 == PathType.DAMAGE_FIRE || var5 == Blocks.MAGMA_BLOCK || var5 == Blocks.CAMPFIRE) {
var4 = PathType.DAMAGE_FIRE;
}
if (var6 == PathType.DAMAGE_CACTUS) {
var4 = PathType.DAMAGE_CACTUS;
}
if (var6 == PathType.DAMAGE_OTHER) {
var4 = PathType.DAMAGE_OTHER;
}
if (var6 == PathType.STICKY_HONEY) {
var4 = PathType.STICKY_HONEY;
}
}
if (var4 == PathType.WALKABLE) {
var4 = a(var0, var1, var2, var3, var4);
}
return var4;
}
use of net.minecraft.server.v1_14_R1.Block in project Citizens2 by CitizensDev.
the class NMSImpl method getTargetNavigator.
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, final Function<NavigationAbstract, Boolean> function) {
net.minecraft.server.v1_14_R1.Entity raw = getHandle(entity);
raw.onGround = true;
// not sure of a better way around this - if onGround is false, then
// navigation won't execute, and calling entity.move doesn't
// entirely fix the problem.
final NavigationAbstract navigation = NMSImpl.getNavigation(entity);
final float oldWater = raw instanceof EntityPlayer ? ((EntityHumanNPC) raw).a(PathType.WATER) : ((EntityInsentient) raw).a(PathType.WATER);
if (params.avoidWater() && oldWater >= 0) {
if (raw instanceof EntityPlayer) {
((EntityHumanNPC) raw).a(PathType.WATER, oldWater + 1F);
} else {
((EntityInsentient) raw).a(PathType.WATER, oldWater + 1F);
}
}
return new MCNavigator() {
float lastSpeed;
CancelReason reason;
@Override
public CancelReason getCancelReason() {
return reason;
}
@Override
public Iterable<Vector> getPath() {
return new NavigationIterable(navigation);
}
@Override
public void stop() {
if (params.debug() && navigation.l() != null) {
for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.l().e(); i++) {
PathPoint pp = navigation.l().a(i);
org.bukkit.block.Block block = new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()).getBlock();
player.sendBlockChange(block.getLocation(), block.getBlockData());
}
}
}
if (oldWater >= 0) {
if (raw instanceof EntityPlayer) {
((EntityHumanNPC) raw).a(PathType.WATER, oldWater);
} else {
((EntityInsentient) raw).a(PathType.WATER, oldWater);
}
}
stopNavigation(navigation);
}
@Override
public boolean update() {
if (params.speed() != lastSpeed) {
if (Messaging.isDebugging() && lastSpeed > 0) {
Messaging.debug("Repathfinding " + ((NPCHolder) entity).getNPC().getId() + " due to speed change");
}
Entity handle = getHandle(entity);
EntitySize size = null;
try {
size = (EntitySize) SIZE_FIELD_GETTER.invoke(handle);
if (handle instanceof EntityHorse) {
SIZE_FIELD_SETTER.invoke(handle, new EntitySize(Math.min(0.99F, size.width), size.height, false));
}
} catch (Throwable e) {
e.printStackTrace();
}
if (!function.apply(navigation)) {
reason = CancelReason.STUCK;
}
try {
SIZE_FIELD_SETTER.invoke(handle, size);
} catch (Throwable e) {
e.printStackTrace();
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit.
}
lastSpeed = params.speed();
}
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
BlockData data = Material.DANDELION.createBlockData();
for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.l().e(); i++) {
PathPoint pp = navigation.l().a(i);
player.sendBlockChange(new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()), data);
}
}
}
navigation.a(params.speed());
return NMSImpl.isNavigationFinished(navigation);
}
};
}
Aggregations