@Override public boolean generate(World worldIn, Random rand, BlockPos position) { BlockPos cur = NeoHellGenerators.findSurface(worldIn, position); if (cur==null) return false; IBlockState norfairite = TWBlocks.NORFAIRITE_CLEAR.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.GREEN); ArrayList<BlockPos> bushArea = new ArrayList<BlockPos>(); NeoHellGenerators.sphereAround(cur.up(), 1.5f + rand.nextFloat(), bushArea); for(BlockPos leaf : bushArea) { IBlockState state = worldIn.getBlockState(leaf); if (state.getBlock().canBeReplacedByLeaves(state, worldIn, leaf)) { worldIn.setBlockState(leaf, norfairite); } } return true; }
/** * Returns true if the item can be used on the given entity, e.g. shears on sheep. */ public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) { if (par3EntityLivingBase instanceof EntitySheep) { EntitySheep var4 = (EntitySheep)par3EntityLivingBase; int var5 = BlockColored.func_150032_b(par1ItemStack.getItemDamage()); if (!var4.getSheared() && var4.getFleeceColor() != var5) { var4.setFleeceColor(var5); --par1ItemStack.stackSize; } return true; } else { return false; } }
@Override public boolean interact(EntityPlayer player) { ItemStack stack = player.inventory.getCurrentItem(); if (stack != null) { if (InventoryHelper.isDye(stack)) { int i = BlockColored.func_150032_b(InventoryHelper.getDyeMetaFromOreDict(stack)); if (!this.getSheared() && this.getFleeceColor() != i) { this.setFleeceColor(i); --stack.stackSize; return true; } else { return super.interact(player); } } else { return super.interact(player); } } else { return super.interact(player); } }
@SideOnly(Side.CLIENT) @Override public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) { if (ModBlocks.lantern.isGlass(itemStack)) { String glassName = Blocks.stained_glass.getUnlocalizedName() + "." + ItemDye.field_150923_a[BlockColored.func_150032_b(itemStack.getItemDamage())]; list.add(StatCollector.translateToLocal(glassName + ".name")); } String contents = StatCollector.translateToLocal(ModBlocks.makeName("lanternSource")) + ": " + EnumChatFormatting.YELLOW; String source = ModBlocks.lantern.getLightSource(itemStack); ILanternSource lanternSource = (source != null) ? Api.instance.registries().lanternSources().getLanternSource(source) : null; if (lanternSource != null) contents += StatCollector.translateToLocal(lanternSource.getLanguageKey(itemStack.getItemDamage())); else contents += StatCollector.translateToLocal(ModBlocks.makeName("lanternSource.none")); list.add(contents); }
public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { if (p_111207_3_ instanceof EntitySheep) { EntitySheep entitysheep = (EntitySheep)p_111207_3_; int i = BlockColored.func_150032_b(p_111207_1_.getItemDamage()); if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { entitysheep.setFleeceColor(i); --p_111207_1_.stackSize; } return true; } else { return false; } }
/** * Returns true if the item can be used on the given entity, e.g. shears on sheep. */ public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) { if (par3EntityLivingBase instanceof EntitySheep) { EntitySheep entitysheep = (EntitySheep)par3EntityLivingBase; int i = BlockColored.getBlockFromDye(par1ItemStack.getItemDamage()); if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { entitysheep.setFleeceColor(i); --par1ItemStack.stackSize; } return true; } else { return false; } }
@Override public boolean onBlockActivated(EntityPlayer player, ItemStack stack, TileEntity tileEntity) { if(stack != null && stack.getItem() == Items.dye && tileEntity instanceof TileEntityProducer) { TileEntityProducer producer = (TileEntityProducer)tileEntity; int[] modi = producer.getModifiers(); if(modi[2] != BlockColored.func_150032_b(stack.getItemDamage())) { modi[2] = BlockColored.func_150032_b(stack.getItemDamage()); if(!player.capabilities.isCreativeMode) { stack.stackSize--; if(stack.stackSize == 0) stack = null; } producer.getWorldObj().markBlockForUpdate(producer.xCoord, producer.yCoord, producer.zCoord); producer.setModifiers(modi);; return true; } } return false; }
@Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(@Nonnull IBlockState blockStateIn, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing side) { IBlockState otherState = world.getBlockState(pos.offset(side)).getActualState(world, pos.offset(side)); if (FacadeUtil.instance.isFacaded(otherState)) { IBlockState facade = FacadeUtil.instance.getFacade(otherState, world, pos.offset(side), side); if (facade != null) { otherState = facade; } } if (otherState.getBlock() instanceof BlockFusedQuartz) { IBlockState ourState = blockStateIn.getActualState(world, pos); return !ourState.getValue(FusedQuartzType.KIND).connectTo(otherState.getValue(FusedQuartzType.KIND)) || (!glassConnectToTheirColorVariants && ourState.getValue(BlockColored.COLOR) != otherState.getValue(BlockColored.COLOR)); } return true; }
public static void addDyeRecipes(IForgeRegistry<IRecipe> registry, BlockColored block) { ResourceLocation group = new ResourceLocation("thermionics_world", "dye"); for(EnumDyeColor dye : EnumDyeColor.values()) { ShapelessOreRecipe recipe = new ShapelessOreRecipe(group, new ItemStack(TWBlocks.NORFAIRITE_CLEAR,1,dye.getMetadata()), new ItemStack(Items.DYE,1,dye.getDyeDamage()), new ItemStack(TWBlocks.NORFAIRITE_CLEAR,1,OreDictionary.WILDCARD_VALUE)); recipe.setRegistryName(new ResourceLocation("thermionics_world", block.getRegistryName().getResourcePath()+"_DyeTo_"+dye.getUnlocalizedName()) ); registry.register(recipe); } }
@SuppressWarnings("deprecation") @Override public String getLocalizedName(ItemStack stack) { EnumDyeColor color = this.getStateFromMeta(stack.getItemDamage()).getValue(BlockColored.COLOR); String localColor = I18n.translateToLocal("color."+color.getUnlocalizedName()); return I18n.translateToLocalFormatted(getUnlocalizedName()+".name", localColor); }
public HobbitPipeRecipeHandler() { super(); if (pipes.isEmpty()) { for (int i = 0; i < 17; i++) { pipes.add(new ItemStack(LOTRMod.hobbitPipe)); LOTRItemHobbitPipe.setSmokeColor((ItemStack) pipes.get(i), i); } } if (dyes.isEmpty()) { NeiLotrUtil.getDyes().forEach(stack -> { dyes.put(BlockColored.func_150031_c(LOTRItemDye.isItemDye(stack)), stack); }); dyes.put(16, new ItemStack(LOTRMod.mithrilNugget)); } }
public BlockCableSignal(String subId) { super(subId); this.setDefaultState(blockState.getBaseState() .withProperty(NORTH, false) .withProperty(SOUTH, false) .withProperty(EAST, false) .withProperty(WEST, false) .withProperty(UP, false) .withProperty(DOWN, false) .withProperty(BlockColored.COLOR, EnumDyeColor.WHITE) ); }
/** * This method will generate a cluster of Coral that will randomly choose a color for each piece of Coral. * @param world * @param pos * @param size * @param ignoreSpread if this is enabled the search will not avoid duplicate directions (Forms a tighter clump) * @param notifyBlocks */ public static void generateCoralCluster(World world, BlockPos pos, int size, boolean ignoreSpread, boolean notifyBlocks){ BlockPos nodePos = pos; EnumFacing lastFace = null; for(int i = 0; i < size; i++){ EnumDyeColor color = EnumDyeColor.byMetadata(MathHelper.getInt(Util.rand, 0, 15)); if(ModBlocks.coral.canPlaceBlockAt(world, nodePos)){ world.setBlockState(nodePos, ModBlocks.coral.getDefaultState().withProperty(BlockColored.COLOR, color), notifyBlocks ? 3 : 2); boolean found = false; search: for(int t = 0; t < 6; t++){ EnumFacing face = EnumFacing.VALUES[MathHelper.getInt(Util.rand, 0, 5)]; if(!ignoreSpread && lastFace !=null && face == lastFace){ continue search; } if(ModBlocks.coral.canPlaceBlockAt(world, nodePos.offset(face))){ nodePos = nodePos.offset(face); lastFace = face; found = true; break search; } } if(!found){ break; } } } }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte)0)); this.dataWatcher.addObject(20, new Byte((byte)BlockColored.func_150032_b(1))); }
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()); } } } } }
private static void registerVanillaVariantProps() { // TODO: omit similar blocks registerVariantProperty(BlockStone.VARIANT); registerVariantProperty(BlockPlanks.VARIANT); registerVariantProperty(BlockSapling.TYPE); registerVariantProperty(BlockDirt.VARIANT); registerVariantProperty(BlockSand.VARIANT); registerVariantProperty(BlockOldLog.VARIANT); registerVariantProperty(BlockNewLog.VARIANT); registerVariantProperty(BlockOldLeaf.VARIANT); registerVariantProperty(BlockNewLeaf.VARIANT); registerVariantProperty(BlockSandStone.TYPE); registerVariantProperty(BlockTallGrass.TYPE); registerVariantProperty(BlockPistonExtension.TYPE); registerVariantProperty(BlockColored.COLOR); registerVariantProperty(BlockPistonMoving.TYPE); registerVariantProperty(Blocks.YELLOW_FLOWER.getTypeProperty()); registerVariantProperty(Blocks.RED_FLOWER.getTypeProperty()); registerVariantProperty(BlockStoneSlab.VARIANT); registerVariantProperty(BlockWoodSlab.VARIANT); registerVariantProperty(BlockAnvil.DAMAGE); registerVariantProperty(BlockQuartz.VARIANT); registerVariantProperty(BlockCarpet.COLOR); registerVariantProperty(BlockDoublePlant.VARIANT); registerVariantProperty(BlockStainedGlass.COLOR); registerVariantProperty(BlockStainedGlassPane.COLOR); registerVariantProperty(BlockPrismarine.VARIANT); registerVariantProperty(BlockRedSandstone.TYPE); registerVariantProperty(BlockStoneSlabNew.VARIANT); }
@Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(IdBase+1, new Byte((byte)0));//ENTITY STATE this.dataWatcher.addObject(IdBase+2, new Byte((byte)BlockColored.getBlockFromDye(1)));//COLLAR this.dataWatcher.addObject(IdBase+3, new Integer(-1));//BREED this.dataWatcher.addObject(IdBase+4, "");//COMMAND this.dataWatcher.addObject(IdBase+5, (byte)0);//STAND this.dataWatcher.addObject(IdBase+6, new Float(20F));//Hunger }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(INDEX_INTEGER, Integer.valueOf(0)); this.dataWatcher.addObject(INDEX_BREED, new Byte((byte)0)); this.dataWatcher.addObject(INDEX_COLLAR_COLOR, new Byte((byte)BlockColored.func_150032_b(1))); this.dataWatcher.addObject(INDEX_SADDLE, Byte.valueOf((byte)0)); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(INDEX_HEALTH, new Float(this.getHealth())); this.dataWatcher.addObject(INDEX_BREED, new Byte((byte)0)); this.dataWatcher.addObject(INDEX_COLLAR_COLOR, new Byte((byte)BlockColored.func_150032_b(1))); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(INDEX_BREED, new Byte((byte)0)); this.dataWatcher.addObject(INDEX_COLLAR_COLOR, new Byte((byte)BlockColored.func_150032_b(1))); this.dataWatcher.addObject(INDEX_SADDLE, Byte.valueOf((byte)0)); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte)0)); this.dataWatcher.addObject(20, new Byte((byte)BlockColored.getBlockFromDye(1))); addHelper(new CustomTameableHacks(this)); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(21, Byte.valueOf((byte)0)); this.dataWatcher.addObject(19, new Byte((byte)0)); this.dataWatcher.addObject(20, new Byte((byte)BlockColored.getBlockFromDye(1))); addHelper(new CustomTameableHacks(this)); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(INDEX_BREED, new Byte((byte)0)); this.dataWatcher.addObject(INDEX_COLLAR_COLOR, new Byte((byte)BlockColored.getBlockFromDye(1))); this.dataWatcher.addObject(INDEX_SADDLE, Byte.valueOf((byte)0)); addHelper(new JakanHacks(this)); // don't use this on server side or you're asking for troubles! /*if (isClient()) { animator = new JakanAnimator(this); }*/ }
/** * 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); } }
public boolean activate(EntityPlayer player, int side, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(); if (itemstack != null && fluid == FluidRegistry.WATER) { if (itemstack.getItem() instanceof ItemArmor && ((ItemArmor) itemstack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.CLOTH) { ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); itemarmor.removeColor(itemstack); return true; } if (itemstack.getItem() instanceof ItemBlock) { Block block = Block.getBlockFromItem(itemstack.getItem()); if (block instanceof BlockColored) { itemstack.setItemDamage(0); return true; } if (block == Blocks.stained_hardened_clay) player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Blocks.hardened_clay, itemstack.stackSize)); if (block == Blocks.stained_glass) player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Blocks.glass, itemstack.stackSize)); if (block == Blocks.stained_glass_pane) player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Blocks.glass_pane, itemstack.stackSize)); } } return false; }
@Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(DATA_BEG, new Byte((byte) 0)); this.dataWatcher.addObject(20, new Byte((byte) BlockColored.func_150032_b(1))); }
public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { if (p_111207_3_ instanceof EntitySheep) { EntitySheep entitysheep = (EntitySheep)p_111207_3_; int i = BlockColored.func_150032_b(p_111207_1_.getItemDamage()); if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { // CraftBukkit start byte bColor = (byte) i; SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor)); entitysheep.worldObj.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } i = (byte) event.getColor().getWoolData(); // CraftBukkit end entitysheep.setFleeceColor(i); --p_111207_1_.stackSize; } return true; } else { return false; } }
public static MapColor getMapColorForBlockColored(int p_151644_0_) { switch (BlockColored.func_150031_c(p_151644_0_)) { case 0: return blackColor; case 1: return redColor; case 2: return greenColor; case 3: return brownColor; case 4: return blueColor; case 5: return purpleColor; case 6: return cyanColor; case 7: return silverColor; case 8: return grayColor; case 9: return pinkColor; case 10: return limeColor; case 11: return yellowColor; case 12: return lightBlueColor; case 13: return magentaColor; case 14: return adobeColor; case 15: return snowColor; default: return airColor; } }