Search in sources :

Example 11 with Material

use of net.minecraft.server.v1_13_R2.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 : NPC(net.citizensnpcs.api.npc.NPC) EntityHumanNPC(net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) Material(org.bukkit.Material) PathPoint(net.minecraft.server.v1_13_R2.PathPoint)

Example 12 with Material

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

the class PlayerPathfinderNormal method b.

protected PathType b(IBlockAccess var1, int var2, int var3, int var4) {
    BlockPosition var5 = new BlockPosition(var2, var3, var4);
    IBlockData var6 = var1.getType(var5);
    Block var7 = var6.getBlock();
    Material var8 = var6.getMaterial();
    if (var6.isAir()) {
        return PathType.OPEN;
    } else if (var7 != Blocks.OAK_TRAPDOOR && var7 != Blocks.IRON_TRAPDOOR && var7 != Blocks.LILY_PAD) {
        if (var7 == Blocks.FIRE) {
            return PathType.DAMAGE_FIRE;
        } else if (var7 == Blocks.CACTUS) {
            return PathType.DAMAGE_CACTUS;
        } else if (var7 instanceof BlockDoor && var8 == Material.WOOD && !var6.get(BlockDoor.OPEN).booleanValue()) {
            return PathType.DOOR_WOOD_CLOSED;
        } else if (var7 instanceof BlockDoor && var8 == Material.ORE && !var6.get(BlockDoor.OPEN).booleanValue()) {
            return PathType.DOOR_IRON_CLOSED;
        } else if (var7 instanceof BlockDoor && var6.get(BlockDoor.OPEN).booleanValue()) {
            return PathType.DOOR_OPEN;
        } else if (var7 instanceof BlockMinecartTrackAbstract) {
            return PathType.RAIL;
        } else if (var7 instanceof BlockFence || var7 instanceof BlockCobbleWall || var7 instanceof BlockFenceGate && !var6.get(BlockFenceGate.OPEN).booleanValue()) {
            return PathType.FENCE;
        } else {
            Fluid var9;
            try {
                var9 = var1.getFluid(var5);
            } catch (NoSuchMethodError ex) {
                try {
                    var9 = (Fluid) GET_FLUID.invoke(var1, var5);
                } catch (Throwable ex2) {
                    ex2.printStackTrace();
                    return PathType.BLOCKED;
                }
            }
            if (var9.a(TagsFluid.WATER)) {
                return PathType.WATER;
            } else if (var9.a(TagsFluid.LAVA)) {
                return PathType.LAVA;
            } else {
                return var6.a(var1, var5, PathMode.LAND) ? PathType.OPEN : PathType.BLOCKED;
            }
        }
    } else {
        return PathType.TRAPDOOR;
    }
}
Also used : BlockDoor(net.minecraft.server.v1_13_R2.BlockDoor) IBlockData(net.minecraft.server.v1_13_R2.IBlockData) BlockFenceGate(net.minecraft.server.v1_13_R2.BlockFenceGate) BlockCobbleWall(net.minecraft.server.v1_13_R2.BlockCobbleWall) MutableBlockPosition(net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_13_R2.BlockPosition) TagsFluid(net.minecraft.server.v1_13_R2.TagsFluid) Fluid(net.minecraft.server.v1_13_R2.Fluid) Block(net.minecraft.server.v1_13_R2.Block) Material(net.minecraft.server.v1_13_R2.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_13_R2.BlockMinecartTrackAbstract) BlockFence(net.minecraft.server.v1_13_R2.BlockFence)

Example 13 with Material

use of net.minecraft.server.v1_13_R2.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_13_R2.WorldServer) Material(org.bukkit.Material) ItemStack(net.minecraft.server.v1_13_R2.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld)

Example 14 with Material

use of net.minecraft.server.v1_13_R2.Material in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot116_4 method initializeBlockStates.

/**
 * Initialize block states (org.dynmap.blockstate.DynmapBlockState)
 */
@Override
public void initializeBlockStates() {
    dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
    HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
    int cnt = Block.REGISTRY_ID.a();
    DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        Block b = bd.getBlock();
        String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        // See if we have seen this one
        DynmapBlockState lastbs = lastBlockState.get(bname);
        int idx = 0;
        if (lastbs != null) {
            // Yes
            // Get number of states so far, since this is next
            idx = lastbs.getStateCount();
        }
        // Build state name
        String sb = "";
        String fname = bd.toString();
        int off1 = fname.indexOf('[');
        if (off1 >= 0) {
            int off2 = fname.indexOf(']');
            sb = fname.substring(off1 + 1, off2);
        }
        Material mat = bd.getMaterial();
        // getLightBlock
        int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
        // Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
        // Fill in base attributes
        bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
        if (mat.isSolid()) {
            bld.setSolid();
        }
        if (mat == Material.AIR) {
            bld.setAir();
        }
        if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
            bld.setLog();
        }
        if (mat == Material.LEAVES) {
            bld.setLeaves();
        }
        if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bld.setWaterlogged();
        }
        // Build state
        DynmapBlockState dbs = bld.build();
        dataToState.put(bd, dbs);
        lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
        Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
    }
}
Also used : IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) Material(net.minecraft.server.v1_16_R3.Material) BukkitMaterial(org.dynmap.bukkit.helper.BukkitMaterial)

Example 15 with Material

use of net.minecraft.server.v1_13_R2.Material in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot116 method initializeBlockStates.

/**
 * Initialize block states (org.dynmap.blockstate.DynmapBlockState)
 */
@Override
public void initializeBlockStates() {
    dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
    HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
    int cnt = Block.REGISTRY_ID.a();
    DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        Block b = bd.getBlock();
        String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        // See if we have seen this one
        DynmapBlockState lastbs = lastBlockState.get(bname);
        int idx = 0;
        if (lastbs != null) {
            // Yes
            // Get number of states so far, since this is next
            idx = lastbs.getStateCount();
        }
        // Build state name
        String sb = "";
        String fname = bd.toString();
        int off1 = fname.indexOf('[');
        if (off1 >= 0) {
            int off2 = fname.indexOf(']');
            sb = fname.substring(off1 + 1, off2);
        }
        Material mat = bd.getMaterial();
        // getLightBlock
        int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
        // Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
        // Fill in base attributes
        bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
        if (mat.isSolid()) {
            bld.setSolid();
        }
        if (mat == Material.AIR) {
            bld.setAir();
        }
        if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
            bld.setLog();
        }
        if (mat == Material.LEAVES) {
            bld.setLeaves();
        }
        if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bld.setWaterlogged();
        }
        // Build state
        DynmapBlockState dbs = bld.build();
        dataToState.put(bd, dbs);
        lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
        Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
    }
}
Also used : BlockRotatable(net.minecraft.server.v1_16_R1.BlockRotatable) HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) BukkitMaterial(org.dynmap.bukkit.helper.BukkitMaterial) Material(net.minecraft.server.v1_16_R1.Material) IBlockData(net.minecraft.server.v1_16_R1.IBlockData) Block(net.minecraft.server.v1_16_R1.Block) BlockFluids(net.minecraft.server.v1_16_R1.BlockFluids)

Aggregations

HashMap (java.util.HashMap)8 IdentityHashMap (java.util.IdentityHashMap)7 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)7 IBlockData (net.minecraft.server.v1_13_R2.IBlockData)3 Material (org.bukkit.Material)3 BukkitMaterial (org.dynmap.bukkit.helper.BukkitMaterial)3 Material (net.minecraft.server.v1_13_R2.Material)2 CraftItemStack (org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NPC (net.citizensnpcs.api.npc.NPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_13_R2.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 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1