Search in sources :

Example 1 with DyeColor

use of net.minecraft.item.DyeColor in project minecolonies by Minecolonies.

the class WindowBannerPicker method createCloseButtons.

/**
 * Creates the Done and Cancel buttons, to return to the town hall window and save the banner or not, respectively.
 */
protected void createCloseButtons() {
    this.addButton(new Button(center(this.width, 2, 80, 1, 10), this.height - 40, 80, SIDE, new TranslationTextComponent("gui.done"), pressed -> {
        BannerPattern.Builder builder = new BannerPattern.Builder();
        for (Pair<BannerPattern, DyeColor> pair : layers) builder.addPattern(pair.getFirst(), pair.getSecond());
        colony.setColonyFlag(builder.toListTag());
        window.open();
    }));
    this.addButton(new Button(center(this.width, 2, 80, 0, 10), this.height - 40, 80, SIDE, new TranslationTextComponent("gui.cancel"), pressed -> window.open()));
}
Also used : AbstractWindowTownHall(com.minecolonies.coremod.client.gui.townhall.AbstractWindowTownHall) Arrays(java.util.Arrays) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) ModelBakery(net.minecraft.client.renderer.model.ModelBakery) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) I18n(net.minecraft.client.resources.I18n) DyeColor(net.minecraft.item.DyeColor) Button(net.minecraft.client.gui.widget.button.Button) BannerTileEntityRenderer(net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer) RenderHelper(net.minecraft.client.renderer.RenderHelper) StringTextComponent(net.minecraft.util.text.StringTextComponent) LinkedList(java.util.LinkedList) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IColonyView(com.minecolonies.api.colony.IColonyView) BannerTileEntity(net.minecraft.tileentity.BannerTileEntity) TextFormatting(net.minecraft.util.text.TextFormatting) BannerPattern(net.minecraft.tileentity.BannerPattern) ModelRenderer(net.minecraft.client.renderer.model.ModelRenderer) Pair(com.mojang.datafixers.util.Pair) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) MathHelper(net.minecraft.util.math.MathHelper) OverlayTexture(net.minecraft.client.renderer.texture.OverlayTexture) Button(net.minecraft.client.gui.widget.button.Button) BannerPattern(net.minecraft.tileentity.BannerPattern) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Pair(com.mojang.datafixers.util.Pair)

Example 2 with DyeColor

use of net.minecraft.item.DyeColor in project minecolonies by Minecolonies.

the class DefaultConcreteMixerCraftingProvider method registerRecipes.

@Override
protected void registerRecipes(@NotNull final Consumer<IFinishedRecipe> consumer) {
    final List<ItemStorage> input = new ArrayList<>();
    input.add(new ItemStorage(new ItemStack(Items.SAND, 4)));
    input.add(new ItemStorage(new ItemStack(Items.GRAVEL, 4)));
    for (final DyeColor color : DyeColor.values()) {
        final String prefix = color.name().toLowerCase(Locale.ROOT);
        final Item powder = ForgeRegistries.ITEMS.getValue(new ResourceLocation(prefix + "_concrete_powder"));
        final Item concrete = ForgeRegistries.ITEMS.getValue(new ResourceLocation(prefix + "_concrete"));
        final Item dye = ForgeRegistries.ITEMS.getValue(new ResourceLocation(prefix + "_dye"));
        if (powder == null || concrete == null || dye == null) {
            throw new IllegalStateException("Missing items for " + color.getSerializedName());
        }
        final List<ItemStorage> customInput = new ArrayList<>(input);
        customInput.add(new ItemStorage(new ItemStack(dye)));
        CustomRecipeBuilder.create(ModJobs.CONCRETE_ID.getPath() + "_custom", powder.getRegistryName().getPath()).inputs(customInput).result(new ItemStack(powder, 8)).build(consumer);
        CustomRecipeBuilder.create(ModJobs.CONCRETE_ID.getPath() + "_custom", concrete.getRegistryName().getPath()).inputs(Collections.singletonList(new ItemStorage(new ItemStack(powder)))).result(new ItemStack(concrete)).build(consumer);
    // TODO: it makes sense for this to have WATER as an intermediate, but the RS logic
    // and JEI rendering don't currently support that.  Previous versions just used
    // air, so we'll do the same for now.
    }
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) DyeColor(net.minecraft.item.DyeColor) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 3 with DyeColor

use of net.minecraft.item.DyeColor in project minecolonies by Minecolonies.

the class TileEntityColonyFlag method getItemClient.

/**
 * Builds a mutable ItemStack from the information within the tile entity
 * @return the ItemStack representing this banner
 */
@OnlyIn(Dist.CLIENT)
public ItemStack getItemClient() {
    ItemStack itemstack = new ItemStack(ModBlocks.blockColonyBanner);
    List<Pair<BannerPattern, DyeColor>> list = getPatternList();
    ListNBT nbt = new ListNBT();
    for (Pair<BannerPattern, DyeColor> pair : list) {
        CompoundNBT pairNBT = new CompoundNBT();
        pairNBT.putString(TAG_SINGLE_PATTERN, pair.getFirst().getHashname());
        pairNBT.putInt(TAG_PATTERN_COLOR, pair.getSecond().getId());
        nbt.add(pairNBT);
    }
    if (!nbt.isEmpty())
        itemstack.getOrCreateTagElement("BlockEntityTag").put(TAG_BANNER_PATTERNS, nbt);
    return itemstack;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) BannerPattern(net.minecraft.tileentity.BannerPattern) ItemStack(net.minecraft.item.ItemStack) DyeColor(net.minecraft.item.DyeColor) Pair(com.mojang.datafixers.util.Pair) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with DyeColor

use of net.minecraft.item.DyeColor in project Hyper-Lighting by Exploding-Creeper.

the class UnderwaterLantern method animateTick.

@Override
public void animateTick(BlockState state, World worldIn, BlockPos pos, Random rand) {
    if (worldIn.isRemote && state.get(LIT)) {
        DyeColor color = DyeColor.values()[rand.nextInt(DyeColor.values().length)];
        Direction direction = state.get(HORIZONTAL_FACING);
        double d0 = (double) pos.getX() + 0.5D;
        double d1 = (double) pos.getY() + 0.7D;
        double d2 = (double) pos.getZ() + 0.5D;
        if (state.get(FACE) == AttachFace.WALL) {
            Direction direction1 = direction.getOpposite();
            worldIn.addParticle(ParticleTypes.SMOKE, d0 + 0.27D * (double) direction1.getXOffset(), d1, d2 + 0.27D * (double) direction1.getZOffset(), 0.0D, 0.0D, 0.0D);
            worldIn.addParticle(ParticleRegistryHandler.CUSTOM_FLAME.get(), d0 + 0.27D * (double) direction1.getXOffset(), d1 - 0.3D, d2 + 0.27D * (double) direction1.getZOffset(), color.getColorComponentValues()[0], color.getColorComponentValues()[1], color.getColorComponentValues()[2]);
        } else if (state.get(FACE) == AttachFace.FLOOR) {
            worldIn.addParticle(ParticleTypes.SMOKE, d0, d1 - 0.3D, d2, 0.0D, 0.0D, 0.0D);
            worldIn.addParticle(ParticleRegistryHandler.CUSTOM_FLAME.get(), d0, d1 - 0.5D, d2, color.getColorComponentValues()[0], color.getColorComponentValues()[1], color.getColorComponentValues()[2]);
        } else if (state.get(FACE) == AttachFace.CEILING) {
            worldIn.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
            worldIn.addParticle(ParticleRegistryHandler.CUSTOM_FLAME.get(), d0, d1 - 0.3D, d2, color.getColorComponentValues()[0], color.getColorComponentValues()[1], color.getColorComponentValues()[2]);
        }
    }
}
Also used : DyeColor(net.minecraft.item.DyeColor) Direction(net.minecraft.util.Direction)

Example 5 with DyeColor

use of net.minecraft.item.DyeColor in project Hyper-Lighting by Exploding-Creeper.

the class UnderwaterTorch method animateTick.

@Override
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    if (stateIn.get(LIT)) {
        BasicParticleType particleData = ParticleRegistryHandler.CUSTOM_FLAME.get();
        DyeColor color = DyeColor.values()[rand.nextInt(DyeColor.values().length)];
        if (stateIn.get(ATTACH_FACE) == AttachFace.FLOOR) {
            double d0 = (double) pos.getX() + 0.5D;
            double d1 = (double) pos.getY() + 0.7D;
            double d2 = (double) pos.getZ() + 0.5D;
            worldIn.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
            // xSpeed, ySpeed and zSpeed here is used to pass color data. This isn't the proper way, but I don't wanna add a bunch of extra code for something so simple
            worldIn.addParticle(particleData, d0, d1, d2, color.getColorComponentValues()[0], color.getColorComponentValues()[1], color.getColorComponentValues()[2]);
        } else {
            Direction direction = stateIn.get(HORIZONTAL_FACING);
            double d0 = (double) pos.getX() + 0.5D;
            double d1 = (double) pos.getY() + 0.7D;
            double d2 = (double) pos.getZ() + 0.5D;
            double d3 = 0.22D;
            double d4 = 0.27D;
            Direction direction1 = direction.getOpposite();
            worldIn.addParticle(ParticleTypes.SMOKE, d0 + 0.27D * (double) direction1.getXOffset(), d1 + 0.22D, d2 + 0.27D * (double) direction1.getZOffset(), 0.0D, 0.0D, 0.0D);
            // xSpeed, ySpeed and zSpeed here is used to pass color data. This isn't the proper way, but I don't wanna add a bunch of extra code for something so simple
            worldIn.addParticle(particleData, d0 + 0.27D * (double) direction1.getXOffset(), d1 + 0.22D, d2 + 0.27D * (double) direction1.getZOffset(), color.getColorComponentValues()[0], color.getColorComponentValues()[1], color.getColorComponentValues()[2]);
        }
    }
}
Also used : BasicParticleType(net.minecraft.particles.BasicParticleType) DyeColor(net.minecraft.item.DyeColor) Direction(net.minecraft.util.Direction)

Aggregations

DyeColor (net.minecraft.item.DyeColor)27 ItemStack (net.minecraft.item.ItemStack)16 EnumColor (mekanism.api.text.EnumColor)6 Item (net.minecraft.item.Item)6 ArrayList (java.util.ArrayList)5 Pair (com.mojang.datafixers.util.Pair)4 List (java.util.List)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 IngredientWithout (mekanism.common.recipe.ingredient.IngredientWithout)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3 BannerPattern (net.minecraft.tileentity.BannerPattern)3 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)3 IColonyView (com.minecolonies.api.colony.IColonyView)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 AbstractWindowTownHall (com.minecolonies.coremod.client.gui.townhall.AbstractWindowTownHall)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 Arrays (java.util.Arrays)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 Optional (java.util.Optional)2