cn.nukkit.utils.DyeColor Java Examples

The following examples show how to use cn.nukkit.utils.DyeColor. 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: BlockBed.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public DyeColor getDyeColor() {
    if (this.level != null) {
        BlockEntity blockEntity = this.level.getBlockEntity(this);

        if (blockEntity instanceof BlockEntityBed) {
            return ((BlockEntityBed) blockEntity).getDyeColor();
        }
    }

    return DyeColor.WHITE;
}
 
Example #2
Source File: BlockBed.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public DyeColor getDyeColor() {
    if (this.level != null) {
        BlockEntity blockEntity = this.level.getBlockEntity(this);

        if (blockEntity instanceof BlockEntityBed) {
            return ((BlockEntityBed) blockEntity).getDyeColor();
        }
    }

    return DyeColor.WHITE;
}
 
Example #3
Source File: BlockMushroomBrown.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #4
Source File: BlockMushroomRed.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #5
Source File: BlockBed.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public DyeColor getDyeColor() {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityBed) {
        return ((BlockEntityBed) blockEntity).getDyeColor();
    }
    return DyeColor.WHITE;
}
 
Example #6
Source File: BlockMushroomRed.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == DyeColor.WHITE.getDyeData()) {
        if (ThreadLocalRandom.current().nextFloat() < 0.4) {
            this.grow();
        }

        this.level.addParticle(new BoneMealParticle(this));
        return true;
    }
    return false;
}
 
Example #7
Source File: ItemDye.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public ItemDye(Integer meta, int amount) {
    super(DYE, meta, amount, "Dye");

    if (this.meta == DyeColor.BROWN.getDyeData()) {
        this.block = new BlockCocoa();
    }
}
 
Example #8
Source File: EntitySheep.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int randomColor() {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    double rand = random.nextDouble(1, 100);

    if (rand <= 0.164) {
        return DyeColor.PINK.getWoolData();
    }

    if (rand <= 15) {
        return random.nextBoolean() ? DyeColor.BLACK.getWoolData() : random.nextBoolean() ? DyeColor.GRAY.getWoolData() : DyeColor.LIGHT_GRAY.getWoolData();
    }

    return DyeColor.WHITE.getWoolData();
}
 
Example #9
Source File: EntitySheep.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int randomColor() {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    double rand = random.nextDouble(1, 100);

    if (rand <= 0.164) {
        return DyeColor.PINK.getWoolData();
    }

    if (rand <= 15) {
        return random.nextBoolean() ? DyeColor.BLACK.getWoolData() : random.nextBoolean() ? DyeColor.GRAY.getWoolData() : DyeColor.LIGHT_GRAY.getWoolData();
    }

    return DyeColor.WHITE.getWoolData();
}
 
Example #10
Source File: ItemFirework.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void addExplosion(FireworkExplosion explosion) {
    List<DyeColor> colors = explosion.getColors();
    List<DyeColor> fades = explosion.getFades();

    if (colors.isEmpty()) {
        return;
    }
    byte[] clrs = new byte[colors.size()];
    for (int i = 0; i < clrs.length; i++) {
        clrs[i] = (byte) colors.get(i).getDyeData();
    }

    byte[] fds = new byte[fades.size()];
    for (int i = 0; i < fds.length; i++) {
        fds[i] = (byte) fades.get(i).getDyeData();
    }

    ListTag<CompoundTag> explosions = this.getNamedTag().getCompound("Fireworks").getList("Explosions", CompoundTag.class);
    CompoundTag tag = new CompoundTag()
            .putByteArray("FireworkColor", clrs)
            .putByteArray("FireworkFade", fds)
            .putBoolean("FireworkFlicker", explosion.flicker)
            .putBoolean("FireworkTrail", explosion.trail)
            .putByte("FireworkType", explosion.type.ordinal());

    explosions.add(tag);
}
 
Example #11
Source File: BlockTerracottaGlazedBlack.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.BLACK;
}
 
Example #12
Source File: BlockTerracottaGlazedCyan.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.CYAN;
}
 
Example #13
Source File: BlockTerracottaStained.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public BlockTerracottaStained(DyeColor dyeColor) {
    this(dyeColor.getWoolData());
}
 
Example #14
Source File: BlockCarpet.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.getByWoolData(getDamage());
}
 
Example #15
Source File: BlockTerracottaGlazedPink.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.PINK;
}
 
Example #16
Source File: BlockConcrete.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockColor getColor() {
    return DyeColor.getByWoolData(getDamage()).getColor();
}
 
Example #17
Source File: BlockTerracottaStained.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.getByWoolData(getDamage());
}
 
Example #18
Source File: BlockTerracottaGlazedLightBlue.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.LIGHT_BLUE;
}
 
Example #19
Source File: BlockGlassPaneStained.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.getByWoolData(getDamage());
}
 
Example #20
Source File: BlockTerracottaGlazedGray.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.GRAY;
}
 
Example #21
Source File: BlockWool.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public BlockWool(DyeColor dyeColor) {
    this(dyeColor.getWoolData());
}
 
Example #22
Source File: BlockGlassPaneStained.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.getByWoolData(getDamage());
}
 
Example #23
Source File: BlockTerracottaGlazedGreen.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.GREEN;
}
 
Example #24
Source File: ItemBed.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public ItemBed(Integer meta, int count) {
    super(BED, meta, count, DyeColor.getByWoolData(meta).getName() + " Bed");
    this.block = Block.get(BlockID.BED_BLOCK);
}
 
Example #25
Source File: ItemFirework.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public FireworkExplosion addFade(DyeColor fade) {
    fades.add(fade);
    return this;
}
 
Example #26
Source File: BlockCocoa.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item toItem() {
    return new ItemDye(DyeColor.BROWN.getDyeData());
}
 
Example #27
Source File: ItemFirework.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public List<DyeColor> getColors() {
    return this.colors;
}
 
Example #28
Source File: BlockTerracotta.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.getByWoolData(getDamage());
}
 
Example #29
Source File: ItemDye.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public DyeColor getDyeColor() {
    return DyeColor.getByDyeData(meta);
}
 
Example #30
Source File: BlockWool.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockColor getColor() {
    return DyeColor.getByWoolData(getDamage()).getColor();
}