當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemDye類代碼示例

本文整理匯總了Java中net.minecraft.item.ItemDye的典型用法代碼示例。如果您正苦於以下問題:Java ItemDye類的具體用法?Java ItemDye怎麽用?Java ItemDye使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ItemDye類屬於net.minecraft.item包,在下文中一共展示了ItemDye類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: work

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;
    List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
    boolean needsToIncrease = true;
    if (pointer >= blockPos.size()) pointer = 0;
    if (pointer < blockPos.size()) {
        BlockPos pos = blockPos.get(pointer);
        if (!this.world.isAirBlock(pos)) {
            ItemStack stack = getFirstItem();
            if (!stack.isEmpty()) {
                FakePlayer player = IndustrialForegoing.getFakePlayer(this.world);
                if (ItemDye.applyBonemeal(stack, this.world, pos, player, EnumHand.MAIN_HAND))
                    needsToIncrease = false;
            }
        }
    } else {
        pointer = 0;
    }
    if (needsToIncrease) ++pointer;
    return 1;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:23,代碼來源:CropEnrichMaterialInjectorTile.java

示例2: onItemUse

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
		EnumFacing facing, float hitX, float hitY, float hitZ) {
	
	ItemStack stack = player.getHeldItem(hand);
	
	if (!player.canPlayerEdit(pos.offset(facing), facing, stack))
       {
           return EnumActionResult.FAIL;
           
       }else{
       	 if (ItemDye.applyBonemeal(stack, worldIn, pos, player, hand))
            {
                if (!worldIn.isRemote)
                {
                    worldIn.playEvent(2005, pos, 0);
                }

                return EnumActionResult.SUCCESS;
                
            }else{
           	 return EnumActionResult.PASS;
            }
       }
}
 
開發者ID:EnderiumSmith,項目名稱:CharcoalPit,代碼行數:26,代碼來源:ItemFertilizer.java

示例3: onItemUse

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override public EnumActionResult onItemUse(ItemStack srcItemStack, EntityPlayer playerEntity, World world, BlockPos target, EnumHand hand, EnumFacing face, float par8, float par9, float par10){
	boolean canUse = ItemDye.applyBonemeal(srcItemStack,world,target,playerEntity);
	if(canUse){
		phantomBonemeal.stackSize = 27;
		for(int dx = -2; dx <= 2; dx++){
			for(int dy = -2; dy <= 2; dy++){
				for(int dz = -1; dz <= 1; dz++){
					if((dx | dy | dz) == 0) continue;
					BlockPos t = target.add(dx, dy, dz);
					ItemDye.applyBonemeal(phantomBonemeal,world,t,playerEntity);
				}
			}
		}
		return EnumActionResult.SUCCESS;
	}
	return EnumActionResult.PASS;
}
 
開發者ID:cyanobacterium,項目名稱:Minecraft_Mineralogy,代碼行數:18,代碼來源:MineralFertilizer.java

示例4: applyEnrichment

import net.minecraft.item.ItemDye; //導入依賴的package包/類
public boolean applyEnrichment (ItemStack itemStack, World world, int x, int y, int z, EntityPlayer player) {
    ConfigManager config = GardenCore.config;
    Block block = world.getBlock(x, y, z);

    EnrichedSoilEvent event = new EnrichedSoilEvent(player, world, block, x, y, z);
    if (MinecraftForge.EVENT_BUS.post(event))
        return false;

    if (!config.enableCompostBonemeal)
        return false;

    if (event.getResult() == Event.Result.ALLOW) {
        if (!world.isRemote)
            itemStack.stackSize--;
        return true;
    }

    int prob = (config.compostBonemealStrength == 0) ? 0 : (int)(1 / config.compostBonemealStrength);
    if (world.rand.nextInt(prob) == 0)
        return ItemDye.applyBonemeal(itemStack, world, x, y, z, player);
    else
        --itemStack.stackSize;

    return true;
}
 
開發者ID:jaquadro,項目名稱:GardenCollection,代碼行數:26,代碼來源:ItemCompost.java

示例5: doWork

import net.minecraft.item.ItemDye; //導入依賴的package包/類
private void doWork(TileEmcCapacitor emcCap)
{
    for (int x = -4; x <= 4; x++)
    {
        for (int z = -4; z <= 4; z++)
        {
            if (!(Block.blocksList[worldObj.getBlockId(xCoord + x, yCoord,
                    zCoord + z)] == Block.grass))
            {
                if (ItemDye.applyBonemeal(new ItemStack(Item.dyePowder),
                        worldObj, xCoord + x, yCoord, zCoord + z,
                        FakePlayerFactory.getMinecraft(worldObj)))
                {
                    emcCap.useEmc(new EmcValue(1.0F, EmcType.ESSENTIA),
                            xCoord, yCoord, zCoord);
                }
            }
        }
    }
}
 
開發者ID:Dynious,項目名稱:EnergyFromMatter,代碼行數:21,代碼來源:TileCropRipener.java

示例6: processInteract

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
    ItemStack equippedItem = player.getHeldItemMainhand();
    if (!world.isRemote && !equippedItem.isEmpty()) {
        if (equippedItem.getItem() == Itemss.GPS_TOOL) {
            BlockPos gpsLoc = ItemGPSTool.getGPSLocation(equippedItem);
            if (gpsLoc != null) {
                getNavigator().tryMoveToXYZ(gpsLoc.getX(), gpsLoc.getY(), gpsLoc.getZ(), 0.1D);
            }
        } else {
            int dyeIndex = TileEntityPlasticMixer.getDyeIndex(equippedItem);
            if (dyeIndex >= 0) {
                setDroneColor(ItemDye.DYE_COLORS[dyeIndex]);
                equippedItem.shrink(1);
                if (equippedItem.getCount() <= 0) {
                    player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
                }
            }
        }
    }
    return false;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:23,代碼來源:EntityDrone.java

示例7: getFireworkCharge

import net.minecraft.item.ItemDye; //導入依賴的package包/類
private static ItemStack getFireworkCharge() {
    ItemStack charge = new ItemStack(Items.FIREWORK_CHARGE);
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    ArrayList<Integer> arraylist = new ArrayList<>();

    arraylist.add(ItemDye.DYE_COLORS[rand.nextInt(16)]);

    if (rand.nextBoolean()) nbttagcompound1.setBoolean("Flicker", true);

    if (rand.nextBoolean()) nbttagcompound1.setBoolean("Trail", true);

    byte b0 = (byte) rand.nextInt(5);

    int[] aint = new int[arraylist.size()];

    for (int j2 = 0; j2 < aint.length; ++j2) {
        aint[j2] = arraylist.get(j2);
    }

    nbttagcompound1.setIntArray("Colors", aint);
    nbttagcompound1.setByte("Type", b0);
    nbttagcompound.setTag("Explosion", nbttagcompound1);
    charge.setTagCompound(nbttagcompound);
    return charge;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:27,代碼來源:DateEventHandler.java

示例8: addInfo

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public void addInfo(List<String> curInfo) {
    super.addInfo(curInfo);
    String status;
    if (ticksSinceAction >= 0) {
        status = "waila.logisticsModule.transporting";
    } else if (ticksSinceNotEnoughAir >= 0) {
        status = "waila.logisticsModule.notEnoughAir";
    } else if (hasPower()) {
        status = "waila.logisticsModule.powered";
    } else {
        status = "waila.logisticsModule.noPower";
    }
    curInfo.add(I18n.format("hud.msg.state") + ": " + I18n.format(status));
    curInfo.add(I18n.format("waila.logisticsModule.channel") + " " + TextFormatting.YELLOW + I18n.format("item.fireworksCharge." + ItemDye.DYE_COLORS[colorChannel]));
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:17,代碼來源:ModuleLogistics.java

示例9: run

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public boolean run(@Nonnull SpellData spell) {
	World world = spell.world;
	BlockPos targetPos = spell.getData(BLOCK_HIT);
	Entity targetEntity = spell.getData(ENTITY_HIT);
	Entity caster = spell.getData(CASTER);
	Vec3d pos = spell.getData(TARGET_HIT);

	if (pos != null)
		spell.world.playSound(null, new BlockPos(pos), ModSounds.HEAL, SoundCategory.NEUTRAL, 1, 1);
	if (targetEntity instanceof EntityLivingBase) {
		double strength = getModifier(spell, Attributes.POTENCY, 3, 20) / 10.0;

		if (!tax(this, spell)) return false;

		((EntityLivingBase) targetEntity).heal((float) strength);
	}

	if (targetPos != null) {
		if (world.getBlockState(targetPos).getBlock() instanceof IGrowable) {
			if (!tax(this, spell)) return false;
			if (caster == null || (caster instanceof EntityPlayer && BlockUtils.hasEditPermission(targetPos, (EntityPlayerMP) caster)))
				ItemDye.applyBonemeal(new ItemStack(Items.DYE), world, targetPos);
		} else if (world.getBlockState(targetPos).getBlock() instanceof IPlantable) {
			IBlockState state = world.getBlockState(targetPos);
			Block block = state.getBlock();
			if (!tax(this, spell)) return false;
			if (caster == null || (caster instanceof EntityPlayer && BlockUtils.hasEditPermission(targetPos, (EntityPlayerMP) caster))) {
				while (world.getBlockState(targetPos.up()).getBlock() == block) {
					targetPos = targetPos.up();
					state = world.getBlockState(targetPos);
					block = state.getBlock();
				}
				world.immediateBlockTick(targetPos, state, RandUtil.random);
			}
		}
	}
	return true;
}
 
開發者ID:TeamWizardry,項目名稱:Wizardry,代碼行數:40,代碼來源:ModuleEffectThrive.java

示例10: onBonemealUse

import net.minecraft.item.ItemDye; //導入依賴的package包/類
private boolean onBonemealUse( final ItemStack stack, int x, final int y, int z, final World world ) {
	for ( int a = 0; a < 3; a++ ) {
		final Block i = world.getBlock( x, y + 1, z );
		final int j = world.getBlockMetadata( x, y + 1, z );

		if ( i == Blocks.wheat && j < 7 ) {
			final Block block = Blocks.wheat;
			world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getBreakSound(),
					(block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F );

			ItemDye.applyBonemeal(stack, world, x, y, z, null);

			fairy.armSwing( !fairy.didSwing );
			fairy.setTempItem( stack.getItem() );
			fairy.attackTime = 30;

			if ( fairy.flymode() && fairy.getFlyTime() > 0 ) {
				fairy.setFlyTime( 0 );
			}

			return true;
		}

		x += fairy.getRNG().nextInt( 3 ) - 1;
		z += fairy.getRNG().nextInt( 3 ) - 1;
	}

	return false;
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:30,代碼來源:FairyJob.java

示例11: clOnBlockActivated

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public boolean clOnBlockActivated(World worldIn, BlockPos pos,
		IBlockState state, EntityPlayer playerIn, EnumHand hand,
		EnumFacing side, float hitX, float hitY, float hitZ) {
	TileEntitySofa sofa = (TileEntitySofa) worldIn.getTileEntity(pos);
	
	if (playerIn.getHeldItem(hand) != ItemStackTools.getEmptyStack()) {
		ItemStack heldItem = playerIn.getHeldItem(hand);
		if (heldItem.getItem() instanceof ItemDye && sofa.getColor() != 15 - heldItem.getItemDamage()) {
			sofa.setColor(heldItem.getItemDamage());
			if (!playerIn.capabilities.isCreativeMode) {
				ItemStackTools.incStackSize(playerIn.getHeldItem(hand), -1);
			}
			if (worldIn.isRemote) {
				worldIn.setBlockState(pos, state.withProperty(COLOR, sofa.getColor()));
			}
			return true;
		}
	}
	
	return SittableUtil.sitOnBlock(worldIn, pos.getX(), pos.getY(), pos.getZ(), playerIn, 0.351);
}
 
開發者ID:Zundrel,項目名稱:How-Bout-That-Furniture,代碼行數:23,代碼來源:BlockSofa.java

示例12: clOnBlockActivated

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public boolean clOnBlockActivated(World worldIn, BlockPos pos,
		IBlockState state, EntityPlayer playerIn, EnumHand hand,
		EnumFacing side, float hitX, float hitY, float hitZ) {
	if (playerIn.getHeldItem(hand) != ItemStackTools.getEmptyStack()) {
		ItemStack heldItem = playerIn.getHeldItem(hand);
		if (heldItem.getItem() instanceof ItemDye && state.getValue(COLOR) != 15 - heldItem.getItemDamage()) {
			if (!playerIn.capabilities.isCreativeMode) {
				ItemStackTools.incStackSize(playerIn.getHeldItem(hand), -1);
			}
			worldIn.setBlockState(pos, state.withProperty(COLOR, 15 - heldItem.getItemDamage()), 2);
			return true;
		}
	}
	
	return SittableUtil.sitOnBlock(worldIn, pos.getX(), pos.getY(), pos.getZ(), playerIn, 0.351);
}
 
開發者ID:Zundrel,項目名稱:How-Bout-That-Furniture,代碼行數:18,代碼來源:BlockStool.java

示例13: clOnBlockActivated

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public boolean clOnBlockActivated(World worldIn, BlockPos pos,
		IBlockState state, EntityPlayer playerIn, EnumHand hand,
		EnumFacing side, float hitX, float hitY, float hitZ) {
	TileEntityChair chair = (TileEntityChair) worldIn.getTileEntity(pos);
	
	if (playerIn.getHeldItem(hand) != ItemStackTools.getEmptyStack()) {
		ItemStack heldItem = playerIn.getHeldItem(hand);
		if (heldItem.getItem() instanceof ItemDye && chair.getColor() != 15 - heldItem.getItemDamage()) {
			System.out.println(chair.getColor());
			chair.setColor(heldItem.getItemDamage());
			if (!playerIn.capabilities.isCreativeMode) {
				ItemStackTools.incStackSize(playerIn.getHeldItem(hand), -1);
			}
			if (worldIn.isRemote) {
				worldIn.setBlockState(pos, state.withProperty(COLOR, chair.getColor()), 2);
			}
			return true;
		}
	}
	
	return SittableUtil.sitOnBlock(worldIn, pos.getX(), pos.getY(), pos.getZ(), playerIn, 0.351);
}
 
開發者ID:Zundrel,項目名稱:How-Bout-That-Furniture,代碼行數:24,代碼來源:BlockChair.java

示例14: setTexture

import net.minecraft.item.ItemDye; //導入依賴的package包/類
public boolean setTexture(ItemStack stack) 
{
	if(stack != null && stack.getItem() instanceof ItemDye)
	{
		EnumDyeColor colour = EnumDyeColor.byDyeDamage(stack.getMetadata());
		texture = new ResourceLocation("textures/blocks/hardened_clay_stained_" + colour.getName() + ".png");
		return true;
	}
	if(stack != null && stack.getItem() instanceof ItemBlock)
	{
		System.out.println("called");
		Block block = ((ItemBlock) stack.getItem()).block;
		if(block.isNormalCube(block.getDefaultState()) || block instanceof BlockGlass)
		{
			IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(block.getStateFromMeta(stack.getMetadata()));
			texture = new ResourceLocation(model.getParticleTexture().getIconName());
			return true;
		}
	}
	return false;
}
 
開發者ID:MrCrayfish,項目名稱:MrCrayfishSkateboardingMod,代碼行數:22,代碼來源:TileEntityTextureable.java

示例15: drawButton

import net.minecraft.item.ItemDye; //導入依賴的package包/類
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
  super.drawButton(mc, mouseX, mouseY);
  if (visible) {
    Tessellator tes = Tessellator.instance;
    tes.startDrawingQuads();

    int x = xPosition + 2;
    int y = yPosition + 2;

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int col = ItemDye.field_150922_c[colorIndex];
    tes.setColorOpaque_I(col);
    tes.addVertex(x, y + height - 4, zLevel);
    tes.addVertex(x + width - 4, y + height - 4, zLevel);
    tes.addVertex(x + width - 4, y + 0, zLevel);
    tes.addVertex(x, y + 0, zLevel);

    tes.draw();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

  }
}
 
開發者ID:SleepyTrousers,項目名稱:EnderCore,代碼行數:26,代碼來源:ColorButton.java


注:本文中的net.minecraft.item.ItemDye類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。