Search in sources :

Example 6 with Material

use of net.minecraft.server.v1_8_R3.Material in project acidisland by tastybento.

the class NMSHandler method setPotion.

@Override
public ItemStack setPotion(Material itemMaterial, Tag itemTags, ItemStack chestItem) {
    // Try some backwards compatibility with new 1.9 schematics
    Map<String, Tag> cont = (Map<String, Tag>) ((CompoundTag) itemTags).getValue();
    if (cont != null) {
        if (((CompoundTag) itemTags).getValue().containsKey("tag")) {
            Map<String, Tag> contents = (Map<String, Tag>) ((CompoundTag) itemTags).getValue().get("tag").getValue();
            StringTag stringTag = ((StringTag) contents.get("Potion"));
            if (stringTag != null) {
                String tag = stringTag.getValue().replace("minecraft:", "");
                PotionType type = null;
                boolean strong = tag.contains("strong");
                boolean _long = tag.contains("long");
                // Bukkit.getLogger().info("tag = " + tag);
                if (tag.equals("fire_resistance") || tag.equals("long_fire_resistance")) {
                    type = PotionType.FIRE_RESISTANCE;
                } else if (tag.equals("harming") || tag.equals("strong_harming")) {
                    type = PotionType.INSTANT_DAMAGE;
                } else if (tag.equals("healing") || tag.equals("strong_healing")) {
                    type = PotionType.INSTANT_HEAL;
                } else if (tag.equals("invisibility") || tag.equals("long_invisibility")) {
                    type = PotionType.INVISIBILITY;
                } else if (tag.equals("leaping") || tag.equals("long_leaping") || tag.equals("strong_leaping")) {
                    type = PotionType.JUMP;
                } else if (tag.equals("night_vision") || tag.equals("long_night_vision")) {
                    type = PotionType.NIGHT_VISION;
                } else if (tag.equals("poison") || tag.equals("long_poison") || tag.equals("strong_poison")) {
                    type = PotionType.POISON;
                } else if (tag.equals("regeneration") || tag.equals("long_regeneration") || tag.equals("strong_regeneration")) {
                    type = PotionType.REGEN;
                } else if (tag.equals("slowness") || tag.equals("long_slowness")) {
                    type = PotionType.SLOWNESS;
                } else if (tag.equals("swiftness") || tag.equals("long_swiftness") || tag.equals("strong_swiftness")) {
                    type = PotionType.SPEED;
                } else if (tag.equals("strength") || tag.equals("long_strength") || tag.equals("strong_strength")) {
                    type = PotionType.STRENGTH;
                } else if (tag.equals("water_breathing") || tag.equals("long_water_breathing")) {
                    type = PotionType.WATER_BREATHING;
                } else if (tag.equals("water")) {
                    type = PotionType.WATER;
                } else if (tag.equals("weakness") || tag.equals("long_weakness")) {
                    type = PotionType.WEAKNESS;
                } else {
                    return chestItem;
                }
                Potion potion = new Potion(type);
                potion.setHasExtendedDuration(_long);
                potion.setLevel(strong ? 2 : 1);
                chestItem = potion.toItemStack(chestItem.getAmount());
            }
        }
    }
    return chestItem;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) Potion(org.bukkit.potion.Potion) NBTTagString(net.minecraft.server.v1_8_R3.NBTTagString) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) Tag(com.wasteofplastic.org.jnbt.Tag) ListTag(com.wasteofplastic.org.jnbt.ListTag) PotionType(org.bukkit.potion.PotionType) Map(java.util.Map)

Example 7 with Material

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

the class PlayerNavigation method a.

private boolean a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, Vec3D paramVec3D, double paramDouble1, double paramDouble2) {
    int i = paramInt1 - paramInt4 / 2;
    int j = paramInt3 - paramInt6 / 2;
    if (!b(i, paramInt2, j, paramInt4, paramInt5, paramInt6, paramVec3D, paramDouble1, paramDouble2)) {
        return false;
    }
    for (int k = i; k < i + paramInt4; k++) {
        for (int m = j; m < j + paramInt6; m++) {
            double d1 = k + 0.5D - paramVec3D.a;
            double d2 = m + 0.5D - paramVec3D.c;
            if (d1 * paramDouble1 + d2 * paramDouble2 >= 0.0D) {
                Block localBlock = this.c.getType(new BlockPosition(k, paramInt2 - 1, m)).getBlock();
                Material localMaterial = localBlock.getMaterial();
                if (localMaterial == Material.AIR) {
                    return false;
                }
                if ((localMaterial == Material.WATER) && (!this.b.V())) {
                    return false;
                }
                if (localMaterial == Material.LAVA) {
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) Block(net.minecraft.server.v1_8_R3.Block) Material(net.minecraft.server.v1_8_R3.Material) PathPoint(net.minecraft.server.v1_8_R3.PathPoint)

Example 8 with Material

use of net.minecraft.server.v1_8_R3.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));
    }
    final EntityItemNPC handle = new EntityItemNPC(ws, npc, at.getX(), at.getY(), at.getZ(), CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(id, 1, (short) data)));
    return handle.getBukkitEntity();
}
Also used : WorldServer(net.minecraft.server.v1_8_R3.WorldServer) Material(org.bukkit.Material) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 9 with Material

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

the class PlayerPathfinderNormal method b.

private 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_11_R1.BlockDoor) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) BlockFenceGate(net.minecraft.server.v1_11_R1.BlockFenceGate) BlockCobbleWall(net.minecraft.server.v1_11_R1.BlockCobbleWall) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Block(net.minecraft.server.v1_11_R1.Block) Material(net.minecraft.server.v1_11_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_11_R1.BlockMinecartTrackAbstract) BlockFence(net.minecraft.server.v1_11_R1.BlockFence)

Aggregations

PathPoint (net.minecraft.server.v1_8_R3.PathPoint)3 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)2 ListTag (com.wasteofplastic.org.jnbt.ListTag)2 StringTag (com.wasteofplastic.org.jnbt.StringTag)2 Tag (com.wasteofplastic.org.jnbt.Tag)2 Map (java.util.Map)2 Block (net.minecraft.server.v1_8_R3.Block)2 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)2 Material (net.minecraft.server.v1_8_R3.Material)2 NBTTagString (net.minecraft.server.v1_8_R3.NBTTagString)2 Material (org.bukkit.Material)2 NPC (net.citizensnpcs.api.npc.NPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.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 BlockFenceGate (net.minecraft.server.v1_10_R1.BlockFenceGate)1 BlockMinecartTrackAbstract (net.minecraft.server.v1_10_R1.BlockMinecartTrackAbstract)1