Java 类net.minecraft.tileentity.BannerPattern 实例源码

项目:Backmemed    文件:ItemBanner.java   
public static void appendHoverTextFromTileEntityTag(ItemStack stack, List<String> p_185054_1_)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag");

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns"))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        for (int i = 0; i < nbttaglist.tagCount() && i < 6; ++i)
        {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(nbttagcompound1.getInteger("Color"));
            BannerPattern bannerpattern = BannerPattern.func_190994_a(nbttagcompound1.getString("Pattern"));

            if (bannerpattern != null)
            {
                p_185054_1_.add(I18n.translateToLocal("item.banner." + bannerpattern.func_190997_a() + "." + enumdyecolor.getUnlocalizedName()));
            }
        }
    }
}
项目:Mods    文件:TF2EventsCommon.java   
public static List<BannerPattern> getPatterns(TileEntityBanner banner){
    List<BannerPattern> patterns = new ArrayList<>();
       patterns.add(BannerPattern.BASE);
       NBTTagList patternsnbt = banner.writeToNBT(new NBTTagCompound()).getTagList("Patterns", 10);
       for (int i = 0; i < patternsnbt.tagCount(); ++i)
       {
           NBTTagCompound nbttagcompound = patternsnbt.getCompoundTagAt(i);
           for(BannerPattern pattern:BannerPattern.values()) {
            if (pattern.getHashname().equals(nbttagcompound.getString("Pattern")))
            {
                patterns.add(pattern);
                break;
            }
           }
       }
       return patterns;
}
项目:Mods    文件:EntityTF2Character.java   
public boolean detectBanner(){
    Iterator<BlockPos> iterator=this.world.getCapability(TF2weapons.WORLD_CAP, null).banners.iterator();
    while(iterator.hasNext()){
        BlockPos pos=iterator.next();
        if(pos.distanceSq(this.getPosition())<1200){
            TileEntity banner=this.world.getTileEntity(pos);
            if(banner != null && banner instanceof TileEntityBanner){
                boolean fast=false;
                for(BannerPattern pattern: TF2EventsCommon.getPatterns((TileEntityBanner)banner)){
                    if(pattern==TF2weapons.redPattern)
                        this.bannerTeam=0;
                    else if(pattern==TF2weapons.bluPattern)
                        this.bannerTeam=1;
                    else if(pattern==TF2weapons.fastSpawn)
                        fast=true;
                }
                return fast && pos.distanceSq(this.getPosition())<512;
            }
            else{
                iterator.remove();
                return false;
            }
        }
    }
    return false;
}
项目:AdditionalBanners    文件:CreativeTabAdditionalBanners.java   
@Override
public void displayAllRelevantItems (NonNullList<ItemStack> itemList) {

    super.displayAllRelevantItems(itemList);

    for (final BannerPattern pattern : BannerPattern.values())
        itemList.add(PatternHandler.createBanner(EnumDyeColor.WHITE, PatternHandler.createPatternList(EnumDyeColor.BLACK, new BannerLayer(pattern, EnumDyeColor.BLACK))));
    if (CACHE == null) {

        CACHE = new ArrayList<ItemStack>();
        for (final EnumDyeColor color : EnumDyeColor.values())
            for (final DesignHandler.LanguageDesign design : DesignHandler.LanguageDesign.values()) {

                final ItemStack stack = PatternHandler.createBanner(color, PatternHandler.createPatternList(color, design.getLayers()));
                stack.setStackDisplayName(ChatFormatting.RESET + "Design: " + design.name().toLowerCase());
                CACHE.add(stack);
            }
    }

    itemList.addAll(CACHE);
}
项目:Backmemed    文件:BannerTextures.java   
@Nullable
public ResourceLocation getResourceLocation(String id, List<BannerPattern> patternList, List<EnumDyeColor> colorList)
{
    if (id.isEmpty())
    {
        return null;
    }
    else
    {
        id = this.cacheId + id;
        BannerTextures.CacheEntry bannertextures$cacheentry = (BannerTextures.CacheEntry)this.cacheMap.get(id);

        if (bannertextures$cacheentry == null)
        {
            if (this.cacheMap.size() >= 256 && !this.freeCacheSlot())
            {
                return BannerTextures.BANNER_BASE_TEXTURE;
            }

            List<String> list = Lists.<String>newArrayList();

            for (BannerPattern bannerpattern : patternList)
            {
                list.add(this.cacheResourceBase + bannerpattern.func_190997_a() + ".png");
            }

            bannertextures$cacheentry = new BannerTextures.CacheEntry();
            bannertextures$cacheentry.textureLocation = new ResourceLocation(id);
            Minecraft.getMinecraft().getTextureManager().loadTexture(bannertextures$cacheentry.textureLocation, new LayeredColorMaskTexture(this.cacheResourceLocation, list, colorList));
            this.cacheMap.put(id, bannertextures$cacheentry);
        }

        bannertextures$cacheentry.lastUseMillis = System.currentTimeMillis();
        return bannertextures$cacheentry.textureLocation;
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent
public void placeBanner(BlockEvent.PlaceEvent event) {
    TileEntity banner = event.getWorld().getTileEntity(event.getBlockSnapshot().getPos());
    if(banner != null && banner instanceof TileEntityBanner){
        List<BannerPattern> patterns = getPatterns((TileEntityBanner) banner);
        if(patterns.contains(TF2weapons.redPattern) || patterns.contains(TF2weapons.bluPattern)){
            //System.out.println("Banner is");
            event.getWorld().getCapability(TF2weapons.WORLD_CAP, null).banners.add(event.getPos());
        }
    }

}
项目:minecraft-roguelike    文件:Banner.java   
public static ItemStack addPattern(ItemStack banner, BannerPattern pattern, EnumDyeColor color){

    NBTTagCompound nbt = banner.getTagCompound();
    if(nbt == null){
        banner.setTagCompound(new NBTTagCompound());
        nbt = banner.getTagCompound();
    }

    NBTTagCompound tag;

    if(nbt.hasKey("BlockEntityTag")){
        tag = nbt.getCompoundTag("BlockEntityTag");
    } else {
        tag = new NBTTagCompound();
        nbt.setTag("BlockEntityTag", tag);
    }

    NBTTagList patterns;

    if(tag.hasKey("Patterns")){
        patterns = tag.getTagList("Patterns", 10);
    } else {
        patterns = new NBTTagList();
        tag.setTag("Patterns", patterns);
    }

    NBTTagCompound toAdd = new NBTTagCompound();
    toAdd.setInteger("Color", color.getDyeDamage());
    toAdd.setString("Pattern", pattern.getHashname());
    patterns.appendTag(toAdd);

    return banner;
}
项目:CrystalMod    文件:ModBanners.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void addBanner(String enumName, String textureName, String id, ItemStack recipeItem){
    final Class<?>[] paramClasses = new Class[] { String.class, String.class, ItemStack.class };
       EnumHelper.addEnum((Class)BannerPattern.class, enumName.toUpperCase(), (Class[])paramClasses, new Object[] { textureName, id, recipeItem });
}
项目:AdditionalBanners    文件:AdditionalBannersJEI.java   
@Override
public void register (IModRegistry registry) {

    IJeiHelpers jeiHelpers = registry.getJeiHelpers();
    IGuiHelper guiHelper = jeiHelpers.getGuiHelper();

    registry.addRecipeCategories(new RecipeCategoryBanners(guiHelper));
    registry.addRecipeHandlers(new RecipeHandlerBanners());

    List<RecipeWrapperBanners> recipes = new ArrayList<RecipeWrapperBanners>();

    for (BannerPattern pattern : BannerPattern.values()) {

        final RecipeWrapperBanners recipe = new RecipeWrapperBanners(pattern);
        recipes.add(recipe);
    }

    registry.addRecipes(recipes);
}
项目:AdditionalBanners    文件:PatternHandler.java   
public BannerLayer (BannerPattern pattern, EnumDyeColor color) {

            this.pattern = pattern;
            this.color = color;
        }
项目:minecraft-roguelike    文件:Banner.java   
public static ItemStack addPattern(ItemStack banner, Random rand){
    BannerPattern pattern = BannerPattern.values()[rand.nextInt(BannerPattern.values().length)];
    EnumDyeColor color = EnumDyeColor.values()[rand.nextInt(EnumDyeColor.values().length)];

    return addPattern(banner, pattern, color);
}
项目:AdditionalBanners    文件:PatternHandler.java   
/**
 * Adds a new banner pattern to the game. This banner pattern will be hidden and will not
 * have a crafting recipe. An example of such is the base white pattern in vanilla.
 *
 * @param name The name of the banner pattern. This is used for the texture file, and is
 *        also converted into upper case and used for the enum entry. Given how this system
 *        works, it's critical that this value is unique, consider adding the mod id to the
 *        name.
 * @param id A small string used to represent the pattern without taking up much space. An
 *        example of this is "bri". Given how the system works, it is critical that this is
 *        a unique value. please consider adding the mod id to the pattern id.
 * @return BannerPattern: A reference to the new BannerPattern entry that has been created.
 */
public static BannerPattern addBasicPattern (String name) {

    final Class<?>[] paramTypes = { String.class, String.class };
    final Object[] paramValues = { AdditionalBanners.MOD_ID + "_" + name, AdditionalBanners.MOD_ID + "." + name };
    return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
项目:AdditionalBanners    文件:PatternHandler.java   
/**
 * Adds a new banner pattern to the game. This banner pattern will be applied by using the
 * provided item in a crafting recipe with the banner.
 *
 * @param name The name of the banner pattern. This is used for the texture file, and is
 *        also converted into upper case and used for the enum entry. Given how this system
 *        works, it's critical that this value is unique, consider adding the mod id to the
 *        name.
 * @param id A small string used to represent the pattern without taking up much space. An
 *        example of this is "bri". Given how the system works, it is critical that this is
 *        a unique value. please consider adding the mod id to the pattern id.
 *
 * @param craftingStack An ItemStack which is used in the crafting recipe for this pattern.
 *        An example of this would be the creeper skull being used for the creeper pattern.
 * @return BannerPattern: A reference to the new BannerPattern entry that has been created.
 */
public static BannerPattern addCraftingPattern (String name, ItemStack craftingStack) {

    final Class<?>[] paramTypes = { String.class, String.class, ItemStack.class };
    final Object[] paramValues = { AdditionalBanners.MOD_ID + "_" + name, AdditionalBanners.MOD_ID + "." + name, craftingStack };
    return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
项目:AdditionalBanners    文件:PatternHandler.java   
/**
 * Adds a new banner pattern to the game. This banner pattern will be available by using
 * dyes in a specific configuration. Keep in mind that this pattern only accepts dyes, and
 * recipes can conflict. This means this option is limited to 2^9 (512) possibilities.
 *
 * @param name The name of the banner pattern. This is used for the texture file, and is
 *        also converted into upper case and used for the enum entry. Given how this system
 *        works, it's critical that this value is unique, consider adding the mod id to the
 *        name.
 * @param id A small string used to represent the pattern without taking up much space. An
 *        example of this is "bri". Given how the system works, it is critical that this is
 *        a unique value. please consider adding the mod id to the pattern id.
 * @param craftingTop A layout for the pattern in the top row of the crafting grid. This is
 *        represented by a string with three characters. A blank space means nothing goes
 *        in that slot, while a # means that a dye would go in that slot. Example: "# #"
 * @param craftingMid A layout for the pattern in the middle row of the crafting grid. This
 *        is represented by a string with three characters. A blank space means nothing
 *        goes in that slot, while a # means that a dye would go in that slot. Example: " #
 *        "
 * @param craftingBot A layout for the pattern in the bottom row of the crafting grid. This
 *        is represented by a string with three characters. A blank space means nothing
 *        goes in that slot, while a # means that a dye would go in that slot. Example:
 *        "###"
 * @return BannerPattern: A reference to the new BannerPattern entry that has been created.
 */
public static BannerPattern addDyePattern (String name, String id, String craftingTop, String craftingMid, String craftingBot) {

    final Class<?>[] paramTypes = { String.class, String.class, String.class, String.class, String.class };
    final Object[] paramValues = { name, id, craftingTop, craftingMid, craftingBot };
    return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
项目:Bookshelf    文件:BannerUtils.java   
/**
 * Creates a new banner pattern that is not obtainable through vanilla means. An example of
 * such a pattern is the default empty pattern.
 *
 * @param name The name of the banner pattern being created. This is used for the texture
 *        file and unlocalized name. This is also upper cased to use as the Enum value
 *        name.
 * @param id A short ID to represent the banner pattern. It is critical that this value be
 *        unique. Please consider adding the modID into this somehow.
 * @return The pattern that was created.
 */
public static BannerPattern addBasicPattern (String name, String id) {

    final Class<?>[] paramTypes = { String.class, String.class };
    final Object[] paramValues = { name, id };
    return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
项目:Bookshelf    文件:BannerUtils.java   
/**
 * Creates a new banner pattern that can only be created by placing a the specified
 * ItemStack into the crafting table as part of the recipe. This pattern can be dyed
 * different colors by adding additional dyes into the recipe.
 *
 * @param name The name of the banner pattern being created. This is used for the texture
 *        file and unlocalized name. This is also upper cased to use as the Enum value
 *        name.
 * @param id A short ID to represent the banner pattern. It is critical that this value be
 *        unique. Please consider adding the modID into this somehow.
 * @param craftingStack The ItemStack to use to create this pattern.
 * @return The pattern that was created.
 */
public static BannerPattern addCraftingPattern (String name, String id, ItemStack craftingStack) {

    final Class<?>[] paramTypes = { String.class, String.class, ItemStack.class };
    final Object[] paramValues = { name, id, craftingStack };
    return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
项目:Bookshelf    文件:BannerUtils.java   
/**
 * Creates a new banner pattern that can only be created by placing dyes in the crafting
 * table using a certain arrangement. These recipes only use dye items and can conflict
 * with vanilla. There is roughly 512 possibilities for this.
 *
 * @param name The name of the banner pattern being created. This is used for the texture
 *        file and unlocalized name. This is also upper cased to use as the Enum value
 *        name.
 * @param id A short ID to represent the banner pattern. It is critical that this value be
 *        unique. Please consider adding the modID into this somehow.
 * @param craftingTop A layout for the pattern in the top row of the crafting grid. This is
 *        represented by a string with three characters. A blank space means nothing goes
 *        in that slot, while a # means that a dye would go in that slot. Example: "# #"
 * @param craftingMid A layout for the pattern in the middle row of the crafting grid. This
 *        is represented by a string with three characters. A blank space means nothing
 *        goes in that slot, while a # means that a dye would go in that slot. Example: " #
 *        "
 * @param craftingBot A layout for the pattern in the bottom row of the crafting grid. This
 *        is represented by a string with three characters. A blank space means nothing
 *        goes in that slot, while a # means that a dye would go in that slot. Example:
 *        "###"
 * @return The pattern that was created.
 */
public static BannerPattern addDyePattern (String name, String id, String craftingTop, String craftingMid, String craftingBot) {

    final Class<?>[] paramTypes = { String.class, String.class, String.class, String.class, String.class };
    final Object[] paramValues = { name, id, craftingTop, craftingMid, craftingBot };
    return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
项目:AdditionalBanners    文件:RecipeWrapperBanners.java   
public RecipeWrapperBanners(BannerPattern pattern) {

    this.pattern = pattern;
}
项目:AdditionalBanners    文件:RecipeWrapperBanners.java   
public BannerPattern getPattern() {

    return this.pattern;
}
项目:AdditionalBanners    文件:PatternHandler.java   
public BannerPattern getPattern () {

            return this.pattern;
        }
项目:Bookshelf    文件:BannerUtils.java   
/**
 * Creates a new layer using the passed pattern and color.
 *
 * @param pattern The pattern for the layer.
 * @param color The color for the layer.
 */
public BannerLayer (BannerPattern pattern, EnumDyeColor color) {

    this.pattern = pattern;
    this.color = color;
}
项目:Bookshelf    文件:BannerUtils.java   
/**
 * Gets the pattern depicted by the layer.
 *
 * @return The pattern depicted by the layer.
 */
public BannerPattern getPattern () {

    return this.pattern;
}