use of net.minecraft.server.v1_9_R2.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));
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.fromLegacyData(data));
return handle.getBukkitEntity();
}
use of net.minecraft.server.v1_9_R2.Block in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
public PathType a(IBlockAccess var1, int var2, int var3, int var4, PathType var5) {
if (var5 == PathType.WALKABLE) {
BlockPosition.PooledBlockPosition var6 = BlockPosition.PooledBlockPosition.r();
Throwable var7 = null;
try {
for (int var8 = -1; var8 <= 1; ++var8) {
for (int var9 = -1; var9 <= 1; ++var9) {
if (var8 != 0 || var9 != 0) {
BlockPosition blockPos;
try {
blockPos = var6.c(var8 + var2, var3, var9 + var4);
} catch (NoSuchMethodError ex) {
try {
blockPos = (BlockPosition.PooledBlockPosition) BLOCK_POSITION_B_C.invoke(var6, var8 + var2, var3, var9 + var4);
} catch (Throwable ex2) {
ex2.printStackTrace();
return PathType.BLOCKED;
}
}
Block var10 = var1.getType(blockPos).getBlock();
if (var10 == Blocks.CACTUS) {
var5 = PathType.DANGER_CACTUS;
} else if (var10 == Blocks.FIRE) {
var5 = PathType.DANGER_FIRE;
}
}
}
}
} catch (Throwable var18) {
var7 = var18;
throw var18;
} finally {
if (var6 != null) {
if (var7 != null) {
try {
var6.close();
} catch (Throwable var17) {
var7.addSuppressed(var17);
}
} else {
var6.close();
}
}
}
}
return var5;
}
use of net.minecraft.server.v1_9_R2.Block in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
@Override
public PathType a(IBlockAccess var1, int var2, int var3, int var4) {
PathType var5 = this.b(var1, var2, var3, var4);
if (var5 == PathType.OPEN && var3 >= 1) {
Block var6 = var1.getType(new BlockPosition(var2, var3 - 1, var4)).getBlock();
PathType var7 = this.b(var1, var2, var3 - 1, var4);
var5 = var7 != PathType.WALKABLE && var7 != PathType.OPEN && var7 != PathType.WATER && var7 != PathType.LAVA ? PathType.WALKABLE : PathType.OPEN;
if (var7 == PathType.DAMAGE_FIRE || var6 == Blocks.MAGMA_BLOCK) {
var5 = PathType.DAMAGE_FIRE;
}
if (var7 == PathType.DAMAGE_CACTUS) {
var5 = PathType.DAMAGE_CACTUS;
}
}
var5 = this.a(var1, var2, var3, var4, var5);
return var5;
}
use of net.minecraft.server.v1_9_R2.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_9_R2.Block in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method b.
protected static PathType b(IBlockAccess var0, BlockPosition var1) {
IBlockData var2 = var0.getType(var1);
Block var3 = var2.getBlock();
Material var4 = var2.getMaterial();
if (var2.isAir())
return PathType.OPEN;
if (var2.a(TagsBlock.TRAPDOORS) || var2.a(Blocks.LILY_PAD))
return PathType.TRAPDOOR;
if (var2.a(Blocks.CACTUS))
return PathType.DAMAGE_CACTUS;
if (var2.a(Blocks.SWEET_BERRY_BUSH))
return PathType.DAMAGE_OTHER;
if (var2.a(Blocks.HONEY_BLOCK))
return PathType.STICKY_HONEY;
if (var2.a(Blocks.COCOA))
return PathType.COCOA;
Fluid var5 = var0.getFluid(var1);
if (var5.a(TagsFluid.WATER))
return PathType.WATER;
if (var5.a(TagsFluid.LAVA))
return PathType.LAVA;
if (a(var2))
return PathType.DAMAGE_FIRE;
if (BlockDoor.l(var2) && !var2.get(BlockDoor.OPEN).booleanValue())
return PathType.DOOR_WOOD_CLOSED;
if (var3 instanceof BlockDoor && var4 == Material.ORE && !var2.get(BlockDoor.OPEN).booleanValue())
return PathType.DOOR_IRON_CLOSED;
if (var3 instanceof BlockDoor && var2.get(BlockDoor.OPEN).booleanValue())
return PathType.DOOR_OPEN;
if (var3 instanceof BlockMinecartTrackAbstract)
return PathType.RAIL;
if (var3 instanceof BlockLeaves)
return PathType.LEAVES;
if (var3.a(TagsBlock.FENCES) || var3.a(TagsBlock.WALLS) || (var3 instanceof BlockFenceGate && !var2.get(BlockFenceGate.OPEN).booleanValue()))
return PathType.FENCE;
if (!var2.a(var0, var1, PathMode.LAND))
return PathType.BLOCKED;
return PathType.OPEN;
}
Aggregations