本文整理汇总了Java中org.bukkit.material.Dye类的典型用法代码示例。如果您正苦于以下问题:Java Dye类的具体用法?Java Dye怎么用?Java Dye使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dye类属于org.bukkit.material包,在下文中一共展示了Dye类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCraftingRecipes
import org.bukkit.material.Dye; //导入依赖的package包/类
@Override
public Iterable<Recipe> getCraftingRecipes()
{
ShapedRecipe portalRecipe = new ShapedRecipe(makeItem(getAmountPerCraft()));
portalRecipe.shape("BOB", "PCP", "OPO");
Dye purpleDye = new Dye(Material.INK_SACK);
purpleDye.setColor(DyeColor.PURPLE);
portalRecipe.setIngredient('B', Material.BLAZE_POWDER);
portalRecipe.setIngredient('O', Material.OBSIDIAN);
portalRecipe.setIngredient('P', Material.ENDER_PEARL);
portalRecipe.setIngredient('C', purpleDye.toItemStack(1).getData());
return Collections.singletonList((Recipe) portalRecipe);
}
示例2: isMiningDrop
import org.bukkit.material.Dye; //导入依赖的package包/类
/**
* Checks to see if an item is a mining drop.
*
* @param item Item to check
* @return true if the item is a mining drop, false otherwise
*/
public static boolean isMiningDrop(ItemStack item) {
switch (item.getType()) {
case COAL:
case COAL_ORE:
case DIAMOND:
case DIAMOND_ORE:
case EMERALD:
case EMERALD_ORE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE: // Should we also have Glowing Redstone Ore here?
case REDSTONE:
case GLOWSTONE_DUST: // Should we also have Glowstone here?
case QUARTZ:
case QUARTZ_ORE:
return true;
case INK_SACK:
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
default:
return false;
}
}
示例3: onInvOpen
import org.bukkit.material.Dye; //导入依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void onInvOpen(InventoryClickEvent event) {
Bukkit.getScheduler().scheduleSyncDelayedTask(ProtocolSupportLegacySupport.getInstance(), () -> {
Inventory topinv = event.getWhoClicked().getOpenInventory().getTopInventory();
if (!(topinv instanceof EnchantingInventory)) {
return;
}
EnchantingInventory enchinv = (EnchantingInventory) topinv;
Player player = (Player) event.getWhoClicked();
int lapisEnchAmount = enchinv.getSecondary() != null ? enchinv.getSecondary().getAmount() : 0;
ItemStack[] contents = player.getInventory().getStorageContents();
for (int i = 0; i < contents.length; i++) {
ItemStack itemstack = contents[i];
if (lapis.isSimilar(itemstack)) {
int lapisPlayerAmount = Math.min(itemstack.getAmount(), Material.INK_SACK.getMaxStackSize() - lapisEnchAmount);
itemstack.setAmount(itemstack.getAmount() - lapisPlayerAmount);
if (itemstack.getAmount() == 0) {
contents[i] = null;
}
lapisEnchAmount += lapisPlayerAmount;
if (lapisEnchAmount == Material.INK_SACK.getMaxStackSize()) {
break;
}
}
}
player.getInventory().setStorageContents(contents);
if (lapisEnchAmount != 0) {
enchinv.setSecondary(new Dye(DyeColor.BLUE).toItemStack(lapisEnchAmount));
}
player.updateInventory();
});
}
示例4: getBlockInHand
import org.bukkit.material.Dye; //导入依赖的package包/类
@Override
public BaseBlock getBlockInHand() throws WorldEditException {
ItemStack itemStack = player.getItemInHand();
if (itemStack == null) {
return EditSession.nullBlock;
}
final int typeId = itemStack.getTypeId();
switch (typeId) {
case 0:
return EditSession.nullBlock;
case ItemID.INK_SACK:
final Dye materialData = (Dye) itemStack.getData();
if (materialData.getColor() == DyeColor.BROWN) {
return FaweCache.getBlock(BlockID.COCOA_PLANT, 0);
}
break;
case ItemID.HEAD:
return new SkullBlock(0, (byte) itemStack.getDurability());
default:
final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
if (baseBlock != null) {
return baseBlock;
}
break;
}
BaseBlock block = FaweCache.getBlock(typeId, itemStack.getType().getMaxDurability() != 0 ? 0 : Math.max(0, itemStack.getDurability()));
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && Fawe.<FaweBukkit>imp().getItemUtil() != null) {
return new BrushBoundBaseBlock(this, WorldEdit.getInstance().getSession(this), itemStack);
}
return block;
}
示例5: getDrops
import org.bukkit.material.Dye; //导入依赖的package包/类
@Override
public Collection<ItemStack> getDrops() {
Dye dye = new Dye();
dye.setColor(DyeColor.BROWN);
ItemStack item = new ItemStack(Material.INK_SACK, 3, dye.getData());
return GenericCrop.getDrops(item);
}
示例6: isHerbalismDrop
import org.bukkit.material.Dye; //导入依赖的package包/类
/**
* Checks to see if an item is a herbalism drop.
*
* @param item Item to check
* @return true if the item is a herbalism drop, false otherwise
*/
public static boolean isHerbalismDrop(ItemStack item) {
switch (item.getType()) {
case WHEAT:
case SEEDS:
case CARROT_ITEM:
case POTATO_ITEM:
case NETHER_WARTS:
case BROWN_MUSHROOM:
case RED_MUSHROOM:
case RED_ROSE:
case YELLOW_FLOWER:
case CACTUS:
case SUGAR_CANE:
case MELON:
case MELON_SEEDS:
case PUMPKIN:
case PUMPKIN_SEEDS:
case WATER_LILY:
case VINE:
case LONG_GRASS:
case DOUBLE_PLANT:
return true;
case INK_SACK:
return ((Dye) item.getData()).getColor() == DyeColor.BROWN;
default:
return false;
}
}
示例7: onPlayerInteractEntityEvent
import org.bukkit.material.Dye; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event)
{
if (!(event.getRightClicked() instanceof LivingEntity))
{
return;
}
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
ActionPlayerEntity action;
if (player.getItemInHand().getType() == COAL && entity instanceof PoweredMinecart)
{
action = this.newAction(UseFurnaceMinecart.class, entity.getWorld());
}
else if (player.getItemInHand().getType() == INK_SACK && entity instanceof Sheep || entity instanceof Wolf)
{
action = this.newAction(EntityDye.class, entity.getWorld());
if (action != null)
{
((EntityDye)action).setColor(((Dye)player.getItemInHand().getData()).getColor());
}
}
else if (player.getItemInHand().getType().equals(BOWL) && entity instanceof MushroomCow)
{
action = this.newAction(EntityFillSoup.class, entity.getWorld());
}
else
{
return;
}
if (action != null)
{
action.setEntity(entity);
action.setPlayer(player);
action.setLocation(entity.getLocation());
this.logAction(action);
}
}
示例8: parseMatAndData
import org.bukkit.material.Dye; //导入依赖的package包/类
private static MaterialData parseMatAndData(String matData) {
String[] fields = matData.split("[:()]");
Material mat = Material.matchMaterial(fields[0]);
if (mat == null) {
throw new DHUtilsException("Unknown material " + fields[0]);
}
MaterialData res = new MaterialData(mat);
if (fields.length > 1) {
if (StringUtils.isNumeric(fields[1])) {
res.setData(Byte.parseByte(fields[1]));
} else {
switch (mat) {
case INK_SACK:
Dye dye = new Dye();
dye.setColor(DyeColor.valueOf(fields[1].toUpperCase()));
res = dye;
break;
case WOOL:
case CARPET:
case STAINED_GLASS:
case STAINED_GLASS_PANE:
case STAINED_CLAY:
// maybe one day these will all implement Colorable...
DyeColor dc2 = DyeColor.valueOf(fields[1].toUpperCase());
res.setData(dc2.getWoolData());
break;
case SAPLING:
case WOOD:
TreeSpecies ts = TreeSpecies.valueOf(fields[1].toUpperCase());
res.setData(ts.getData());
break;
}
}
}
return res;
}
示例9: getRecipe
import org.bukkit.material.Dye; //导入依赖的package包/类
@Override
public Recipe getRecipe() {
ShapedRecipe recipe = new ShapedRecipe(toItemStack());
Dye d = new Dye();
d.setColor(DyeColor.WHITE);
recipe.shape("SM ", "SBS", " S ");
recipe.setIngredient('S', Material.STONE);
recipe.setIngredient('M', d);
recipe.setIngredient('B', Material.BOWL);
return recipe;
}
示例10: getRecipe
import org.bukkit.material.Dye; //导入依赖的package包/类
@Override
public Recipe getRecipe() {
Dye greenDye = new Dye();
greenDye.setColor(DyeColor.GREEN);
ShapelessRecipe recipe = new ShapelessRecipe(toItemStack(2));
recipe.addIngredient(Material.STONE_PLATE);
recipe.addIngredient(greenDye);
return recipe;
}
示例11: prettyName
import org.bukkit.material.Dye; //导入依赖的package包/类
public static String prettyName(final ItemStack item) {
final Material mat = item.getType();
String out = prettyName(mat);
if ( mat == Material.WOOL )
out += " (" + prettyName(((Wool) item.getData()).getColor()) + ")";
else if ( mat == Material.INK_SACK )
out += " (" + prettyName(((Dye) item.getData()).getColor()) + ")";
else if ( item.getDurability() != 0 )
out += " (" + item.getDurability() + ")";
return out;
}
示例12: getLapis
import org.bukkit.material.Dye; //导入依赖的package包/类
private ItemStack getLapis(){
Dye dye = new Dye();
dye.setColor(DyeColor.BLUE);
return dye.toItemStack(64);
}
示例13: getDyeDyeColor
import org.bukkit.material.Dye; //导入依赖的package包/类
@Test
public void getDyeDyeColor() {
testColorable(new Dye(Material.INK_SACK, dye.getDyeData()));
}
示例14: checkPlantableItemData
import org.bukkit.material.Dye; //导入依赖的package包/类
/**
* Check if the dye is cocoa beans.
*/
@Override
public boolean checkPlantableItemData(MaterialData data) {
return ((Dye) data).getColor() == DyeColor.BROWN;
}
示例15: makeDye
import org.bukkit.material.Dye; //导入依赖的package包/类
protected static Dye makeDye(DyeColor color) {
Dye dye = new Dye();
dye.setColor(color);
return dye;
}