Added ItemDye and WorldGenHugeMushroom for diff visibility

This commit is contained in:
Nathan Adams 2011-12-09 16:01:37 +00:00
parent d75d1660b3
commit 076460b419
2 changed files with 273 additions and 0 deletions

View File

@ -0,0 +1,112 @@
package net.minecraft.server;
public class ItemDye extends Item {
public static final String[] a = new String[] { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"};
public static final int[] b = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 2651799, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320};
public ItemDye(int i) {
super(i);
this.a(true);
this.f(0);
}
public String a(ItemStack itemstack) {
int i = MathHelper.a(itemstack.getData(), 0, 15);
return super.b() + "." + a[i];
}
public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
if (!entityhuman.d(i, j, k)) {
return false;
} else {
if (itemstack.getData() == 15) {
int i1 = world.getTypeId(i, j, k);
if (i1 == Block.SAPLING.id) {
if (!world.isStatic) {
((BlockSapling) Block.SAPLING).b(world, i, j, k, world.random);
--itemstack.count;
}
return true;
}
if (i1 == Block.BROWN_MUSHROOM.id || i1 == Block.RED_MUSHROOM.id) {
if (!world.isStatic && ((BlockMushroom) Block.byId[i1]).b(world, i, j, k, world.random)) {
--itemstack.count;
}
return true;
}
if (i1 == Block.MELON_STEM.id || i1 == Block.PUMPKIN_STEM.id) {
if (!world.isStatic) {
((BlockStem) Block.byId[i1]).g(world, i, j, k);
--itemstack.count;
}
return true;
}
if (i1 == Block.CROPS.id) {
if (!world.isStatic) {
((BlockCrops) Block.CROPS).g(world, i, j, k);
--itemstack.count;
}
return true;
}
if (i1 == Block.GRASS.id) {
if (!world.isStatic) {
--itemstack.count;
label73:
for (int j1 = 0; j1 < 128; ++j1) {
int k1 = i;
int l1 = j + 1;
int i2 = k;
for (int j2 = 0; j2 < j1 / 16; ++j2) {
k1 += c.nextInt(3) - 1;
l1 += (c.nextInt(3) - 1) * c.nextInt(3) / 2;
i2 += c.nextInt(3) - 1;
if (world.getTypeId(k1, l1 - 1, i2) != Block.GRASS.id || world.e(k1, l1, i2)) {
continue label73;
}
}
if (world.getTypeId(k1, l1, i2) == 0) {
if (c.nextInt(10) != 0) {
world.setTypeIdAndData(k1, l1, i2, Block.LONG_GRASS.id, 1);
} else if (c.nextInt(3) != 0) {
world.setTypeId(k1, l1, i2, Block.YELLOW_FLOWER.id);
} else {
world.setTypeId(k1, l1, i2, Block.RED_ROSE.id);
}
}
}
}
return true;
}
}
return false;
}
}
public void a(ItemStack itemstack, EntityLiving entityliving) {
if (entityliving instanceof EntitySheep) {
EntitySheep entitysheep = (EntitySheep) entityliving;
int i = BlockCloth.d(itemstack.getData());
if (!entitysheep.isSheared() && entitysheep.getColor() != i) {
entitysheep.setColor(i);
--itemstack.count;
}
}
}
}

View File

@ -0,0 +1,161 @@
package net.minecraft.server;
import java.util.Random;
public class WorldGenHugeMushroom extends WorldGenerator {
private int a = -1;
public WorldGenHugeMushroom(int i) {
this.a = i;
}
public WorldGenHugeMushroom() {}
public boolean a(World world, Random random, int i, int j, int k) {
int l = random.nextInt(2);
if (this.a >= 0) {
l = this.a;
}
int i1 = random.nextInt(3) + 4;
boolean flag = true;
if (j >= 1 && j + i1 + 1 <= world.height) {
int j1;
int k1;
int l1;
int i2;
for (j1 = j; j1 <= j + 1 + i1; ++j1) {
byte b0 = 3;
if (j1 == j) {
b0 = 0;
}
for (k1 = i - b0; k1 <= i + b0 && flag; ++k1) {
for (l1 = k - b0; l1 <= k + b0 && flag; ++l1) {
if (j1 >= 0 && j1 < world.height) {
i2 = world.getTypeId(k1, j1, l1);
if (i2 != 0 && i2 != Block.LEAVES.id) {
flag = false;
}
} else {
flag = false;
}
}
}
}
if (!flag) {
return false;
} else {
j1 = world.getTypeId(i, j - 1, k);
if (j1 != Block.DIRT.id && j1 != Block.GRASS.id && j1 != Block.MYCEL.id) {
return false;
} else if (!Block.BROWN_MUSHROOM.canPlace(world, i, j, k)) {
return false;
} else {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
int j2 = j + i1;
if (l == 1) {
j2 = j + i1 - 3;
}
for (k1 = j2; k1 <= j + i1; ++k1) {
l1 = 1;
if (k1 < j + i1) {
++l1;
}
if (l == 0) {
l1 = 3;
}
for (i2 = i - l1; i2 <= i + l1; ++i2) {
for (int k2 = k - l1; k2 <= k + l1; ++k2) {
int l2 = 5;
if (i2 == i - l1) {
--l2;
}
if (i2 == i + l1) {
++l2;
}
if (k2 == k - l1) {
l2 -= 3;
}
if (k2 == k + l1) {
l2 += 3;
}
if (l == 0 || k1 < j + i1) {
if ((i2 == i - l1 || i2 == i + l1) && (k2 == k - l1 || k2 == k + l1)) {
continue;
}
if (i2 == i - (l1 - 1) && k2 == k - l1) {
l2 = 1;
}
if (i2 == i - l1 && k2 == k - (l1 - 1)) {
l2 = 1;
}
if (i2 == i + (l1 - 1) && k2 == k - l1) {
l2 = 3;
}
if (i2 == i + l1 && k2 == k - (l1 - 1)) {
l2 = 3;
}
if (i2 == i - (l1 - 1) && k2 == k + l1) {
l2 = 7;
}
if (i2 == i - l1 && k2 == k + (l1 - 1)) {
l2 = 7;
}
if (i2 == i + (l1 - 1) && k2 == k + l1) {
l2 = 9;
}
if (i2 == i + l1 && k2 == k + (l1 - 1)) {
l2 = 9;
}
}
if (l2 == 5 && k1 < j + i1) {
l2 = 0;
}
if ((l2 != 0 || j >= j + i1 - 1) && !Block.o[world.getTypeId(i2, k1, k2)]) {
world.setRawTypeIdAndData(i2, k1, k2, Block.BIG_MUSHROOM_1.id + l, l2);
}
}
}
}
for (k1 = 0; k1 < i1; ++k1) {
l1 = world.getTypeId(i, j + k1, k);
if (!Block.o[l1]) {
world.setRawTypeIdAndData(i, j + k1, k, Block.BIG_MUSHROOM_1.id + l, 10);
}
}
return true;
}
}
} else {
return false;
}
}
}