net.minecraft.item.EnumDyeColor Java Examples
The following examples show how to use
net.minecraft.item.EnumDyeColor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StructureTofuVillagePieces.java From TofuCraftReload with MIT License | 6 votes |
@SuppressWarnings("deprecation") public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) { if (this.averageGroundLvl < 0) { this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn); if (this.averageGroundLvl < 0) { return true; } this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 5, 0); } IBlockState iblockstate = this.getBiomeSpecificBlockState(Blocks.SPRUCE_FENCE.getDefaultState()); this.setBlockState(worldIn, iblockstate, 1, 0, 0, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate, 1, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate, 1, 2, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.WOOL.getStateFromMeta(EnumDyeColor.BLACK.getDyeDamage()), 1, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.EAST, 2, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.NORTH, 1, 3, 1, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.WEST, 0, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.SOUTH, 1, 3, -1, structureBoundingBoxIn); return true; }
Example #2
Source File: MinecraftTypeHelper.java From malmo with MIT License | 6 votes |
/** Recolour the Minecraft block * @param state The block to be recoloured * @param colour The new colour * @return A new blockstate which is a recoloured version of the original */ static IBlockState applyColour(IBlockState state, Colour colour) { for (IProperty prop : state.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop); if (!current.getName().equalsIgnoreCase(colour.name())) { return state.withProperty(prop, EnumDyeColor.valueOf(colour.name())); } } } return state; }
Example #3
Source File: MinecraftTypeHelper.java From malmo with MIT License | 6 votes |
/** Test whether this block has a colour attribute which matches the list of allowed colours * @param bs blockstate to test * @param allowedColours list of allowed Colour enum values * @return true if the block matches. */ public static boolean blockColourMatches(IBlockState bs, List<Colour> allowedColours) { for (IProperty prop : bs.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { // The block in question has a colour, so check it is a specified one: net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)bs.getValue(prop); for (Colour col : allowedColours) { if (current.getName().equalsIgnoreCase(col.name())) return true; } } } return false; }
Example #4
Source File: CraftBanner.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public void applyTo(TileEntityBanner banner) { super.applyTo(banner); banner.baseColor = EnumDyeColor.byDyeDamage(base.getDyeData()); NBTTagList newPatterns = new NBTTagList(); for (Pattern p : patterns) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("Color", p.getColor().getDyeData()); compound.setString("Pattern", p.getPattern().getIdentifier()); newPatterns.appendTag(compound); } banner.patterns = newPatterns; }
Example #5
Source File: TileEntityElevator.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public static Predicate<TileEntity> isMatchingElevator(final EnumDyeColor color) { return new Predicate<TileEntity> () { @Override public boolean apply(TileEntity te) { if ((te instanceof TileEntityElevator) == false) { return false; } IBlockState state = te.getWorld().getBlockState(te.getPos()); return state.getBlock() instanceof BlockElevator && state.getValue(BlockElevator.COLOR) == color; } }; }
Example #6
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand handIn) { if (!playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getNbtData(playerStack); if (nbt.hasKey(COLOR)) { EnumDyeColor dye = EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)); if (colorBlock(world.getBlockState(pos), world, pos, null, dye)) { if (playerStack.getItemDamage() < playerStack.getMaxDamage()) { playerStack.damageItem(1, playerIn); if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.painterUse); } } else { playerIn.setHeldItem(handIn, GTMaterialGen.get(GTItems.sprayCanEmpty)); if (!IC2.platform.isSimulating()) { playerIn.playSound(SoundEvents.ENTITY_ITEM_BREAK, 1.0F, 1.0F); } } return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; }
Example #7
Source File: StructureTofuVillagePieces.java From TofuCraftReload with MIT License | 6 votes |
/** * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes * Mineshafts at the end, it adds Fences... */ public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) { if (this.averageGroundLvl < 0) { this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn); if (this.averageGroundLvl < 0) { return true; } this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 4 - 1, 0); } IBlockState iblockstate = this.getBiomeSpecificBlockState(Blocks.OAK_FENCE.getDefaultState()); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 2, 3, 1, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); this.setBlockState(worldIn, iblockstate, 1, 0, 0, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate, 1, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate, 1, 2, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.WOOL.getStateFromMeta(EnumDyeColor.WHITE.getDyeDamage()), 1, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.EAST, 2, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.NORTH, 1, 3, 1, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.WEST, 0, 3, 0, structureBoundingBoxIn); this.placeTorch(worldIn, EnumFacing.SOUTH, 1, 3, -1, structureBoundingBoxIn); return true; }
Example #8
Source File: DyeUtil.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
/** * Determines dye color nearest to specified RGB color */ public static EnumDyeColor determineDyeColor(int rgbColor) { Color c = new Color(rgbColor); Map<Double, EnumDyeColor> distances = new HashMap<>(); for (EnumDyeColor dyeColor : EnumDyeColor.values()) { Color c2 = new Color(dyeColor.colorValue); double distance = (c.getRed() - c2.getRed()) * (c.getRed() - c2.getRed()) + (c.getGreen() - c2.getGreen()) * (c.getGreen() - c2.getGreen()) + (c.getBlue() - c2.getBlue()) * (c.getBlue() - c2.getBlue()); distances.put(distance, dyeColor); } double min = Collections.min(distances.keySet()); return distances.get(min); }
Example #9
Source File: DyeModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Listener public void onUpdate(EventPlayerUpdate event) { if (event.getStage() == EventStageable.EventStage.PRE) { final Minecraft mc = Minecraft.getMinecraft(); if(mc.player.inventory.getCurrentItem().getItem() instanceof ItemDye) { final EnumDyeColor color = EnumDyeColor.byDyeDamage(mc.player.inventory.getCurrentItem().getMetadata()); for(Entity e : mc.world.loadedEntityList) { if(e != null && e instanceof EntitySheep) { final EntitySheep sheep = (EntitySheep) e; if(sheep.getHealth() > 0) { if (sheep.getFleeceColor() != color && !sheep.getSheared() && mc.player.getDistance(sheep) <= 4.5f) { mc.playerController.interactWithEntity(mc.player, sheep, EnumHand.MAIN_HAND); } } } } } } }
Example #10
Source File: DyeUtil.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static String getOrdictColorName(EnumDyeColor dyeColor) { String colorName; if (dyeColor == EnumDyeColor.SILVER) colorName = "LightGray"; else colorName = getColorName(dyeColor); return "dye" + colorName; }
Example #11
Source File: BlockElevator.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = EntityUtils.getHeldItemOfType(player, ItemDye.class); if (stack.isEmpty() == false) { EnumDyeColor stackColor = EnumDyeColor.byDyeDamage(stack.getMetadata()); if (state.getValue(COLOR) != stackColor) { if (world.isRemote == false) { world.setBlockState(pos, state.withProperty(COLOR, stackColor), 3); world.playSound(null, pos, SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.BLOCKS, 1f, 1f); if (player.capabilities.isCreativeMode == false) { stack.shrink(1); } } return true; } return false; } else { return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); } }
Example #12
Source File: BlockElevator.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ItemBlock createItemBlock() { return new ItemBlockEnderUtilities(this) { @Override public String getItemStackDisplayName(ItemStack stack) { String name = super.getItemStackDisplayName(stack); return name.replace("{COLOR}", EnumDyeColor.byMetadata(stack.getMetadata()).getName()); } }; }
Example #13
Source File: BlockElevator.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected String[] generateUnlocalizedNames() { String[] names = new String[EnumDyeColor.values().length]; Arrays.fill(names, this.blockName); return names; }
Example #14
Source File: BlockElevatorSlab.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public BlockElevatorSlab(String name, float hardness, float resistance, int harvestLevel, Material material) { super(name, hardness, resistance, harvestLevel, material); this.setDefaultState(this.getBlockState().getBaseState() .withProperty(COLOR, EnumDyeColor.WHITE) .withProperty(HALF, EnumBlockHalf.BOTTOM)); }
Example #15
Source File: DebugModeTestBlockRange.java From AgriCraft with MIT License | 5 votes |
/** * This method allows the user to test what Block Positions are covered by the BlockRange * iterator. The expected result will be the full cuboid between opposing corner positions. Also * remember that the BlockRange min and max positions aren't necessarily the input positions. * * Usage: Right-click on two blocks to specify the opposite corners. Some blocks should get * replaced with free wool. Be careful. In case of terrible bugs, might destroy or overwrite * unexpected locations! */ @Override public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return; } Optional<BlockPos> startPos = getStartPos(stack); if (!startPos.isPresent()) { // This is the first click. Save 'pos' as the starting coordinate. setStartPos(stack, pos); player.sendMessage(new TextComponentString("Starting corner set: (" + pos.getX() + "," + pos.getY() + "," + pos.getZ() + ")")); player.sendMessage(new TextComponentString("Next right click will set the opposite/ending corner.")); player.sendMessage(new TextComponentString("WARNING: this mode will destroy blocks, be careful.")); } else { // This is the second click. Load the starting coordinate. Use 'pos' as the ending coordinate. Then fill the cuboid with wool. int count = 0; IBlockState wool = Blocks.WOOL.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.BLACK); // // IMPORTANT PART OF THE TEST IS BELOW // BlockRange range = new BlockRange(startPos.get(), pos); for (BlockPos target : range) { // <-- Is the iterator giving a complete set? IBlockState old = world.getBlockState(target); world.destroyBlock(target, true); world.setBlockState(target, wool); world.notifyBlockUpdate(target, old, wool, 2); count += 1; } // // IMPORTANT PART OF THE TEST IS ABOVE // player.sendMessage(new TextComponentString("Volume: " + range.getVolume())); player.sendMessage(new TextComponentString("Replaced: " + count)); player.sendMessage(new TextComponentString("Coverage: " + (range.getVolume() == count ? "Complete" : "INCOMPLETE"))); setStartPos(stack, null); } }
Example #16
Source File: ModCrafting.java From pycode-minecraft with MIT License | 5 votes |
public static void register() { GameRegistry.addShapedRecipe( new ItemStack(ModBlocks.python_block), "CLC", "LRY", "CYC", 'C', Blocks.COBBLESTONE, 'L', new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()), 'Y', new ItemStack(Items.DYE, 1, EnumDyeColor.YELLOW.getDyeDamage()), 'R', Items.REDSTONE ); GameRegistry.addShapedRecipe( new ItemStack(ModItems.python_wand), " L", " RY", "S ", 'S', Items.STICK, 'L', new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()), 'Y', new ItemStack(Items.DYE, 1, EnumDyeColor.YELLOW.getDyeDamage()), 'R', Items.REDSTONE ); GameRegistry.addShapedRecipe( new ItemStack(ModItems.python_hand), " L ", "WRY", " W ", 'W', Blocks.WOOL, 'L', new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()), 'Y', new ItemStack(Items.DYE, 1, EnumDyeColor.YELLOW.getDyeDamage()), 'R', Items.REDSTONE ); GameRegistry.addShapelessRecipe( new ItemStack(ModItems.python_book), ModItems.python_wand, Items.WRITABLE_BOOK ); }
Example #17
Source File: QuestEnemyEncampment.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private void buildHut(QuestData data, BlockPos pos) { World world = data.getPlayer().getEntityWorld(); if (pos == null) { return; } int w = hutHalfWidth; BlockPos pointer; IBlockState block; for (int x = -w; x <= w; x++) { for (int y = 0; y <= w; y++) { for (int z = -w; z <= w; z++) { pointer = pos.add(x, y, z); block = world.getBlockState(pointer); if (cantBuildOver(block)) { continue; } if (y + Math.abs(z) == w) { if (x % 2 == 0) { world.setBlockState(pointer, Blocks.WOOL.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.RED)); } else { world.setBlockState(pointer, Blocks.WOOL.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.BLACK)); } } else if (z == 0 && (x == w || x == -w)) { world.setBlockState(pointer, Blocks.DARK_OAK_FENCE.getDefaultState()); } } } } }
Example #18
Source File: LayerOvergrownSheepWool.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public void doRenderLayer(EntityOvergrownSheep sheep, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (!sheep.getSheared() && !sheep.isInvisible()) { this.sheepRenderer.bindTexture(TEXTURE); if (sheep.hasCustomName() && "jeb_".equals(sheep.getCustomNameTag())) { float time = 25F; int i = sheep.ticksExisted / 25 + sheep.getEntityId(); int j = EnumDyeColor.values().length; int k = i % j; int l = (i + 1) % j; float f = ((sheep.ticksExisted % time) + partialTicks) / time; float[] afloat1 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(k)); float[] afloat2 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(l)); GlStateManager.color(afloat1[0] * (1.0F - f) + afloat2[0] * f, afloat1[1] * (1.0F - f) + afloat2[1] * f, afloat1[2] * (1.0F - f) + afloat2[2] * f); } else { float[] afloat = EntitySheep.getDyeRgb(sheep.getFleeceColor()); GlStateManager.color(afloat[0], afloat[1], afloat[2]); } this.sheepModel.setModelAttributes(this.sheepRenderer.getMainModel()); this.sheepModel.setLivingAnimations(sheep, limbSwing, limbSwingAmount, partialTicks); //(float)sheep.getDataManager().get(EntityOvergrownSheep.GROWTH) / 10000000F this.sheepModel.render(sheep, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); } }
Example #19
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, EnumDyeColor color) { MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); if (metaTileEntity == null || metaTileEntity.getPaintingColor() == color.colorValue) return false; metaTileEntity.setPaintingColor(color.colorValue); return true; }
Example #20
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Color getColor(ItemStack stack, int index) { NBTTagCompound nbt = StackUtil.getNbtData(stack); if (index == 1 && nbt.hasKey(COLOR)) { return new Color(EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)).getColorValue()); } return Color.white; }
Example #21
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
public boolean colorBlock(IBlockState state, World world, BlockPos pos, EnumFacing side, EnumDyeColor color) { try { return state.getBlock().recolorBlock(world, pos, side, color); } catch (Exception var7) { return false; } }
Example #22
Source File: BlockPipe.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, EnumDyeColor color) { IPipeTile<PipeType, NodeDataType> tileEntityPipe = (IPipeTile<PipeType, NodeDataType>) world.getTileEntity(pos); if (tileEntityPipe != null && tileEntityPipe.getPipeType() != null && tileEntityPipe.getPipeType().isPaintable() && tileEntityPipe.getInsulationColor() != color.colorValue) { tileEntityPipe.setInsulationColor(color.colorValue); return true; } return false; }
Example #23
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { NBTTagCompound nbt = StackUtil.getNbtData(stack); if (nbt.hasKey(COLOR)) { String name = EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)).getDyeColorName(); tooltip.add(I18n.format("Current: " + name.toUpperCase())); } else { tooltip.add(I18n.format("Current: NONE")); } tooltip.add(I18n.format("Sneak + click to change colors")); }
Example #24
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int getRGBDurabilityForDisplay(ItemStack stack) { NBTTagCompound nbt = StackUtil.getNbtData(stack); if (nbt.hasKey(COLOR)) { return EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)).getColorValue(); } return super.getRGBDurabilityForDisplay(stack); }
Example #25
Source File: CraftingRecipeLoader.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private static void registerColoringRecipes(BlockColored block) { for (EnumDyeColor dyeColor : EnumDyeColor.values()) { String recipeName = String.format("%s_color_%s", block.getRegistryName().getResourcePath(), getColorName(dyeColor)); ModHandler.addShapedRecipe(recipeName, new ItemStack(block, 8, dyeColor.getMetadata()), "XXX", "XDX", "XXX", 'X', new ItemStack(block, 1, GTValues.W), 'D', getOrdictColorName(dyeColor)); } }
Example #26
Source File: PartsRecipeHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void processLens(OrePrefix lensPrefix, GemMaterial material) { ItemStack stack = OreDictUnifier.get(lensPrefix, material); RecipeMaps.LATHE_RECIPES.recipeBuilder() .input(OrePrefix.plate, material) .outputs(stack, OreDictUnifier.get(OrePrefix.dustSmall, material)) .duration((int) (material.getAverageMass() / 2L)) .EUt(16) .buildAndRegister(); EnumDyeColor dyeColor = determineDyeColor(material.materialRGB); MarkerMaterial colorMaterial = MarkerMaterials.Color.COLORS.get(dyeColor); OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, colorMaterial); }
Example #27
Source File: ClientProxy.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public int colorMultiplier(ItemStack stack, int tintIndex) { return tintIndex == this.targetTintIndex ? MapColor.getBlockColor(EnumDyeColor.byMetadata(stack.getMetadata())).colorValue : this.defaultColor; }
Example #28
Source File: ClientProxy.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
private BlockColorHandlerDyes(int targetTintIndex, int defaultColor, PropertyEnum<EnumDyeColor> prop) { this.targetTintIndex = targetTintIndex; this.defaultColor = defaultColor; this.prop = prop; }
Example #29
Source File: Banner.java From minecraft-roguelike with GNU General Public License v3.0 | 4 votes |
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); }
Example #30
Source File: TileEntityPortalPanel.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
private int getColorFromDyeMeta(int dyeMeta) { return dyeMeta >= 0 && dyeMeta <= 15 ? MapColor.getBlockColor(EnumDyeColor.byDyeDamage(dyeMeta)).colorValue : 0xFFFFFF; }