Paper/src/main/java/net/minecraft/server/BlockOre.java

84 Zeilen
2.8 KiB
Java

package net.minecraft.server;
import java.util.Random;
public class BlockOre extends Block {
2013-11-04 14:07:38 +01:00
public BlockOre() {
super(Material.STONE);
this.a(CreativeModeTab.b);
}
2013-11-04 14:07:38 +01:00
public Item getDropType(int i, Random random, int j) {
return this == Blocks.COAL_ORE ? Items.COAL : (this == Blocks.DIAMOND_ORE ? Items.DIAMOND : (this == Blocks.LAPIS_ORE ? Items.INK_SACK : (this == Blocks.EMERALD_ORE ? Items.EMERALD : (this == Blocks.QUARTZ_ORE ? Items.QUARTZ : Item.getItemOf(this)))));
}
public int a(Random random) {
2013-11-04 14:07:38 +01:00
return this == Blocks.LAPIS_ORE ? 4 + random.nextInt(5) : 1;
}
public int getDropCount(int i, Random random) {
2013-11-04 14:07:38 +01:00
if (i > 0 && Item.getItemOf(this) != this.getDropType(0, random, i)) {
int j = random.nextInt(i + 2) - 1;
if (j < 0) {
j = 0;
}
return this.a(random) * (j + 1);
} else {
return this.a(random);
}
}
public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
super.dropNaturally(world, i, j, k, l, f, i1);
2013-03-25 05:22:32 +01:00
/* CraftBukkit start - Delegated to getExpDrop
2013-11-04 14:07:38 +01:00
if (this.getDropType(l, world.random, i1) != Item.getItemOf(this)) {
int j1 = 0;
2013-11-04 14:07:38 +01:00
if (this == Blocks.COAL_ORE) {
j1 = MathHelper.nextInt(world.random, 0, 2);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.DIAMOND_ORE) {
j1 = MathHelper.nextInt(world.random, 3, 7);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.EMERALD_ORE) {
j1 = MathHelper.nextInt(world.random, 3, 7);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.LAPIS_ORE) {
j1 = MathHelper.nextInt(world.random, 2, 5);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.QUARTZ_ORE) {
2013-03-13 23:33:27 +01:00
j1 = MathHelper.nextInt(world.random, 2, 5);
}
2013-11-04 14:07:38 +01:00
this.dropExperience(world, i, j, k, j1);
}
// */
}
public int getExpDrop(World world, int l, int i1) {
2013-11-04 14:07:38 +01:00
if (this.getDropType(l, world.random, i1) != Item.getItemOf(this)) {
int j1 = 0;
2013-11-04 14:07:38 +01:00
if (this == Blocks.COAL_ORE) {
j1 = MathHelper.nextInt(world.random, 0, 2);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.DIAMOND_ORE) {
j1 = MathHelper.nextInt(world.random, 3, 7);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.EMERALD_ORE) {
j1 = MathHelper.nextInt(world.random, 3, 7);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.LAPIS_ORE) {
j1 = MathHelper.nextInt(world.random, 2, 5);
2013-11-04 14:07:38 +01:00
} else if (this == Blocks.QUARTZ_ORE) {
2013-03-13 23:33:27 +01:00
j1 = MathHelper.nextInt(world.random, 2, 5);
}
return j1;
}
return 0;
// CraftBukkit end
}
public int getDropData(int i) {
2013-11-04 14:07:38 +01:00
return this == Blocks.LAPIS_ORE ? 4 : 0;
}
}