Search in sources :

Example 6 with Material

use of net.minecraft.server.v1_15_R1.Material 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;
}
Also used : BlockDoor(net.minecraft.server.v1_12_R1.BlockDoor) IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockFenceGate(net.minecraft.server.v1_12_R1.BlockFenceGate) BlockCobbleWall(net.minecraft.server.v1_12_R1.BlockCobbleWall) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Block(net.minecraft.server.v1_12_R1.Block) Material(net.minecraft.server.v1_12_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_12_R1.BlockMinecartTrackAbstract) BlockFence(net.minecraft.server.v1_12_R1.BlockFence)

Example 7 with Material

use of net.minecraft.server.v1_15_R1.Material in project Citizens2 by CitizensDev.

the class NMSImpl method minecartItemLogic.

@SuppressWarnings("deprecation")
public static void minecartItemLogic(EntityMinecartAbstract minecart) {
    NPC npc = ((NPCHolder) minecart).getNPC();
    if (npc == null)
        return;
    Material mat = Material.getMaterial(npc.data().get(NPC.MINECART_ITEM_METADATA, ""));
    // TODO: migration for this
    int data = npc.data().get(NPC.MINECART_ITEM_DATA_METADATA, 0);
    int offset = npc.data().get(NPC.MINECART_OFFSET_METADATA, 0);
    minecart.a(mat != null);
    if (mat != null) {
        minecart.setDisplayBlock(Block.getByCombinedId(mat.getId()).getBlock().getBlockData());
    }
    minecart.setDisplayBlockOffset(offset);
}
Also used : EntityHumanNPC(net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC) NPC(net.citizensnpcs.api.npc.NPC) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) Material(org.bukkit.Material) PathPoint(net.minecraft.server.v1_15_R1.PathPoint)

Example 8 with Material

use of net.minecraft.server.v1_15_R1.Material in project Citizens2 by CitizensDev.

the class ItemController method createEntity.

@Override
protected Entity createEntity(Location at, NPC npc) {
    WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
    Material id = Material.STONE;
    int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
    if (npc.data().has(NPC.ITEM_ID_METADATA)) {
        id = Material.getMaterial(npc.data().<String>get(NPC.ITEM_ID_METADATA), false);
    }
    if (id == Material.AIR) {
        id = Material.STONE;
        Messaging.severe(npc.getId(), "invalid Material: converted to stone");
    }
    final EntityItemNPC handle = new EntityItemNPC(ws, npc, at.getX(), at.getY(), at.getZ(), CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(id, npc.data().get(NPC.ITEM_AMOUNT_METADATA, 1), (short) data)));
    return handle.getBukkitEntity();
}
Also used : WorldServer(net.minecraft.server.v1_15_R1.WorldServer) Material(org.bukkit.Material) ItemStack(net.minecraft.server.v1_15_R1.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 9 with Material

use of net.minecraft.server.v1_15_R1.Material in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

protected PathType b(IBlockAccess var0, int var1, int var2, int var3) {
    BlockPosition var4 = new BlockPosition(var1, var2, var3);
    IBlockData var5 = var0.getType(var4);
    Block var6 = var5.getBlock();
    Material var7 = var5.getMaterial();
    if (var5.isAir()) {
        return PathType.OPEN;
    } else if (!var6.a(TagsBlock.TRAPDOORS) && var6 != Blocks.LILY_PAD) {
        if (var6 == Blocks.FIRE) {
            return PathType.DAMAGE_FIRE;
        } else if (var6 == Blocks.CACTUS) {
            return PathType.DAMAGE_CACTUS;
        } else if (var6 == Blocks.SWEET_BERRY_BUSH) {
            return PathType.DAMAGE_OTHER;
        } else if (var6 instanceof BlockDoor && var7 == Material.WOOD && !(Boolean) var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_WOOD_CLOSED;
        } else if (var6 instanceof BlockDoor && var7 == Material.ORE && !(Boolean) var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_IRON_CLOSED;
        } else if (var6 instanceof BlockDoor && var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_OPEN;
        } else if (var6 instanceof BlockMinecartTrackAbstract) {
            return PathType.RAIL;
        } else if (var6 instanceof BlockLeaves) {
            return PathType.LEAVES;
        } else if (!var6.a(TagsBlock.FENCES) && !var6.a(TagsBlock.WALLS) && (!(var6 instanceof BlockFenceGate) || var5.get(BlockFenceGate.OPEN))) {
            Fluid var8 = var0.getFluid(var4);
            if (var8.a(TagsFluid.WATER)) {
                return PathType.WATER;
            } else if (var8.a(TagsFluid.LAVA)) {
                return PathType.LAVA;
            } else {
                return var5.a(var0, var4, PathMode.LAND) ? PathType.OPEN : PathType.BLOCKED;
            }
        } else {
            return PathType.FENCE;
        }
    } else {
        return PathType.TRAPDOOR;
    }
}
Also used : BlockDoor(net.minecraft.server.v1_14_R1.BlockDoor) IBlockData(net.minecraft.server.v1_14_R1.IBlockData) BlockLeaves(net.minecraft.server.v1_14_R1.BlockLeaves) BlockFenceGate(net.minecraft.server.v1_14_R1.BlockFenceGate) BlockPosition(net.minecraft.server.v1_14_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.MutableBlockPosition) PooledBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.PooledBlockPosition) Fluid(net.minecraft.server.v1_14_R1.Fluid) TagsFluid(net.minecraft.server.v1_14_R1.TagsFluid) Block(net.minecraft.server.v1_14_R1.Block) TagsBlock(net.minecraft.server.v1_14_R1.TagsBlock) Material(net.minecraft.server.v1_14_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_14_R1.BlockMinecartTrackAbstract)

Example 10 with Material

use of net.minecraft.server.v1_15_R1.Material in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

public static int a(IBlockAccess paramIBlockAccess, Entity paramEntity, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3) {
    int k = 0;
    BlockPosition localBlockPosition = new BlockPosition(paramEntity);
    BlockPosition.MutableBlockPosition localMutableBlockPosition = new BlockPosition.MutableBlockPosition();
    for (int m = paramInt1; m < paramInt1 + paramInt4; m++) {
        for (int n = paramInt2; n < paramInt2 + paramInt5; n++) {
            for (int i1 = paramInt3; i1 < paramInt3 + paramInt6; i1++) {
                localMutableBlockPosition.c(m, n, i1);
                Block localBlock = paramIBlockAccess.getType(localMutableBlockPosition).getBlock();
                if (localBlock.getMaterial() != Material.AIR) {
                    if ((localBlock == Blocks.TRAPDOOR) || (localBlock == Blocks.IRON_TRAPDOOR)) {
                        k = 1;
                    } else if ((localBlock == Blocks.FLOWING_WATER) || (localBlock == Blocks.WATER)) {
                        if (paramBoolean1) {
                            return -1;
                        }
                        k = 1;
                    } else if ((!paramBoolean3) && ((localBlock instanceof BlockDoor)) && (localBlock.getMaterial() == Material.WOOD)) {
                        return 0;
                    }
                    if ((paramEntity.world.getType(localMutableBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) {
                        if ((!(paramEntity.world.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramEntity.world.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
                            return -3;
                        }
                    } else if (!localBlock.b(paramIBlockAccess, localMutableBlockPosition)) {
                        if ((!paramBoolean2) || (!(localBlock instanceof BlockDoor)) || (localBlock.getMaterial() != Material.WOOD)) {
                            if (((localBlock instanceof BlockFence)) || ((localBlock instanceof BlockFenceGate)) || ((localBlock instanceof BlockCobbleWall))) {
                                return -3;
                            }
                            if ((localBlock == Blocks.TRAPDOOR) || (localBlock == Blocks.IRON_TRAPDOOR)) {
                                return -4;
                            }
                            Material localMaterial = localBlock.getMaterial();
                            if (localMaterial == Material.LAVA) {
                                if (!paramEntity.ab()) {
                                    return -2;
                                }
                            } else {
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    return k != 0 ? 2 : 1;
}
Also used : BlockDoor(net.minecraft.server.v1_8_R3.BlockDoor) BlockFenceGate(net.minecraft.server.v1_8_R3.BlockFenceGate) BlockCobbleWall(net.minecraft.server.v1_8_R3.BlockCobbleWall) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) Block(net.minecraft.server.v1_8_R3.Block) Material(net.minecraft.server.v1_8_R3.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_8_R3.BlockMinecartTrackAbstract) BlockFence(net.minecraft.server.v1_8_R3.BlockFence) PathPoint(net.minecraft.server.v1_8_R3.PathPoint)

Aggregations

HashMap (java.util.HashMap)8 IdentityHashMap (java.util.IdentityHashMap)7 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)7 BukkitMaterial (org.dynmap.bukkit.helper.BukkitMaterial)3 IBlockData (net.minecraft.server.v1_13_R2.IBlockData)2 Material (net.minecraft.server.v1_13_R2.Material)2 IBlockData (net.minecraft.server.v1_15_R1.IBlockData)2 WorldServer (net.minecraft.server.v1_15_R1.WorldServer)2 Material (org.bukkit.Material)2 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)2 StringReader (com.mojang.brigadier.StringReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NPC (net.citizensnpcs.api.npc.NPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)1 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)1 Block (net.minecraft.server.v1_10_R1.Block)1 BlockCobbleWall (net.minecraft.server.v1_10_R1.BlockCobbleWall)1 BlockDoor (net.minecraft.server.v1_10_R1.BlockDoor)1 BlockFence (net.minecraft.server.v1_10_R1.BlockFence)1