本文整理汇总了Java中cn.nukkit.item.Item.DYE属性的典型用法代码示例。如果您正苦于以下问题:Java Item.DYE属性的具体用法?Java Item.DYE怎么用?Java Item.DYE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.DYE属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivate
@Override
public boolean onActivate(Item item, Player player) {
if (item.getId() == Item.DYE && item.getDamage() == 0x0F) {
item.count--;
ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom(), 15, 10);
return true;
} else if (item.isHoe()) {
item.useOn(this);
this.getLevel().setBlock(this, new BlockFarmland());
return true;
} else if (item.isShovel()) {
item.useOn(this);
this.getLevel().setBlock(this, new BlockGrassPath());
return true;
}
return false;
}
示例2: onActivate
@Override
public boolean onActivate(Item item, Player player) {
if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
Block block = this.clone();
if (this.meta / 4 < 2) {
block.meta += 4;
BlockGrowEvent ev = new BlockGrowEvent(this, block);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return false;
}
this.getLevel().setBlock(this, ev.getNewState(), true, true);
}
this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5)));
item.count--;
return true;
}
return false;
}
示例3: onEnchant
public void onEnchant(Player who, Item before, Item after) {
Item result = (before.getId() == Item.BOOK) ? new ItemBookEnchanted() : before;
if (!before.hasEnchantments() && after.hasEnchantments() && after.getId() == result.getId() && this.levels != null && this.entries != null) {
Enchantment[] enchantments = after.getEnchantments();
for (int i = 0; i < 3; i++) {
if (Arrays.equals(enchantments, this.entries[i].getEnchantments())) {
Item lapis = this.getItem(1);
int level = who.getExperienceLevel();
int exp = who.getExperience();
int cost = this.entries[i].getCost();
if (lapis.getId() == Item.DYE && lapis.getDamage() == DyeColor.BLUE.getDyeData() && lapis.getCount() > i && level >= cost) {
result.addEnchantment(enchantments);
this.setItem(0, result);
lapis.setCount(lapis.getCount() - i - 1);
this.setItem(1, lapis);
who.setExperience(exp, level - cost);
break;
}
}
}
}
}
示例4: onActivate
@Override
public boolean onActivate(Item item, Player player) {
//Bone meal
if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
BlockCrops block = (BlockCrops) this.clone();
block.meta += new Random().nextInt(3) + 2;
if (block.meta > 7) {
block.meta = 7;
}
BlockGrowEvent ev = new BlockGrowEvent(this, block);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return false;
}
this.getLevel().setBlock(this, ev.getNewState(), true, true);
item.count--;
return true;
}
return false;
}
示例5: onActivate
@Override
public boolean onActivate(Item item, Player player) {
if (item.getId() == Item.DYE && item.getDamage() == DyeColor.WHITE.getDyeData()) {
if (this.level.rand.nextFloat() < 0.4) {
this.grow();
}
this.level.addParticle(new BoneMealParticle(this));
return true;
}
return false;
}
示例6: onActivate
@Override
public boolean onActivate(Item item, Player player) {
if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //Bonemeal
int count = 1;
for (int i = 1; i <= 2; i++) {
int id = this.level.getBlockIdAt(this.getFloorX(), this.getFloorY() - i, this.getFloorZ());
if (id == SUGARCANE_BLOCK) {
count++;
}
}
if (count < 3) {
int toGrow = 3 - count;
for (int i = 1; i <= toGrow; i++) {
Block block = this.up(i);
if (block.getId() == 0) {
BlockGrowEvent ev = new BlockGrowEvent(block, new BlockSugarcane());
Server.getInstance().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
this.getLevel().setBlock(block, ev.getNewState(), true);
}
} else if (block.getId() != SUGARCANE_BLOCK) {
break;
}
}
}
if ((player.gamemode & 0x01) == 0) {
item.count--;
}
this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5)));
return true;
}
return false;
}
示例7: onActivate
@Override
public boolean onActivate(Item item, Player player) {
//Bone meal
if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
BlockCrops block = (BlockCrops) this.clone();
if (this.meta < 7) {
block.meta += new Random().nextInt(3) + 2;
if (block.meta > 7) {
block.meta = 7;
}
BlockGrowEvent ev = new BlockGrowEvent(this, block);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return false;
}
this.getLevel().setBlock(this, ev.getNewState(), true, true);
}
this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5)));
item.count--;
return true;
}
return false;
}
示例8: onInteract
@Override
public boolean onInteract(Player player, Item item) {
if (item.getId() == Item.DYE) {
this.setColor(((ItemDye) item).getDyeColor().getDyedData());
return true;
}
return item.getId() == Item.SHEARS && shear();
}
示例9: getDrops
@Override
public int[][] getDrops(Item item) {
if (this.meta >= 8) {
return new int[][]{
{Item.DYE, 3, 3}
};
} else {
return new int[][]{
{Item.DYE, 3, 1}
};
}
}
示例10: registerIngots
protected void registerIngots() {
int[][] ingots = new int[][]{
{Item.GOLD_BLOCK, Item.GOLD_INGOT},
{Item.GOLD_INGOT, Item.GOLD_NUGGET},
{Item.IRON_BLOCK, Item.IRON_INGOT},
{Item.DIAMOND_BLOCK, Item.DIAMOND},
{Item.EMERALD_BLOCK, Item.EMERALD},
{Item.REDSTONE_BLOCK, Item.REDSTONE_DUST},
{Item.COAL_BLOCK, Item.COAL},
{Item.HAY_BALE, Item.WHEAT},
{Item.LAPIS_BLOCK, Item.DYE, 4}
};
for (int[] e : ingots) {
int block = e[0];
int ingot = e[1];
int ingot_meta = e.length > 2 ? e[2] : 0;
this.registerRecipe((new ShapedRecipe(Item.get(ingot, ingot_meta, 9),
"X"
)).setIngredient("X", Item.get(block, 0, 1)));
this.registerRecipe((new BigShapedRecipe(Item.get(block, 0, 1),
"XXX",
"XXX",
"XXX"
)).setIngredient("X", Item.get(ingot, ingot_meta, 1)));
}
}
示例11: onActivate
@Override
public boolean onActivate(Item item, Player player) {
if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //Bonemeal
Block base = this;
// As sugarcane only grows to a height of three activating the
// lowest or middle block should cause growing. Here we drop
// down one if it's not already the base.
Block down = base.down();
if (down.getId() == SUGARCANE_BLOCK) {
base = down;
}
if (down.getId() != SUGARCANE_BLOCK) {
for (int y = 1; y < 3; ++y) {
Block b = base.getLevel().getBlock(new Vector3(base.x, base.y + y, base.z));
if (b.getId() == AIR) {
BlockGrowEvent ev = new BlockGrowEvent(b, new BlockSugarcane());
Server.getInstance().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
this.getLevel().setBlock(b, ev.getNewState(), true);
}
} else if (b.getId() != SUGARCANE_BLOCK) {
break;
}
}
base.meta = 0;
base.getLevel().setBlock(base, base, true);
}
if ((player.gamemode & 0x01) == 0) {
item.count--;
}
return true;
}
return false;
}