Skip to content

Instantly share code, notes, and snippets.

@lukeeey
Created July 28, 2018 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeeey/b8ded6da7af366dfbc644b099ddd3461 to your computer and use it in GitHub Desktop.
Save lukeeey/b8ded6da7af366dfbc644b099ddd3461 to your computer and use it in GitHub Desktop.
package net.minecraft.server;
import java.util.Random;
public class BlockDragonEgg extends Block {
public BlockDragonEgg() {
super(Material.DRAGON_EGG);
this.a(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
}
public void onPlace(World world, int x, int y, int z) {
world.a(x, y, z, this, this.a(world));
}
public void doPhysics(World world, int x, int y, int z, Block block) {
world.a(x, y, z, this, this.a(world));
}
public void a(World world, int x, int y, int z, Random random) {
this.e(world, x, y, z);
}
private void e(World world, int i, int j, int k) {
if (BlockFalling.canFall(world, i, j - 1, k) && j >= 0) {
byte b0 = 32;
if (!BlockFalling.instaFall && world.b(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this);
world.addEntity(entityfallingblock);
} else {
world.setAir(i, j, k);
while (BlockFalling.canFall(world, i, j - 1, k) && j > 0) {
--j;
}
if (j > 0) {
world.setTypeAndData(i, j, k, this, 0, 2);
}
}
}
}
public boolean interact(World world, int x, int y, int z, EntityHuman entityhuman, int l, float f, float f1, float f2) {
this.doTeleport(world, x, y, z);
return true;
}
public void attack(World world, int x, int y, int z, EntityHuman entityhuman) {
this.doTeleport(world, x, y, z);
}
private void doTeleport(World world, int x, int y, int z) {
if (world.getType(x, y, z) == this) {
for (int l = 0; l < 1000; ++l) {
int i1 = x + world.random.nextInt(16) - world.random.nextInt(16);
int j1 = y + world.random.nextInt(8) - world.random.nextInt(8);
int k1 = z + world.random.nextInt(16) - world.random.nextInt(16);
if (world.getType(i1, j1, k1).material == Material.AIR) {
if (!world.isStatic) {
world.setTypeAndData(i1, j1, k1, this, world.getData(x, y, z), 2);
world.setAir(x, y, z);
} else {
short short1 = 128;
for (int l1 = 0; l1 < short1; ++l1) {
double d0 = world.random.nextDouble();
float f = (world.random.nextFloat() - 0.5F) * 0.2F;
float f1 = (world.random.nextFloat() - 0.5F) * 0.2F;
float f2 = (world.random.nextFloat() - 0.5F) * 0.2F;
double d1 = (double) i1 + (double) (i - i1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D;
double d2 = (double) j1 + (double) (j - j1) * d0 + world.random.nextDouble() * 1.0D - 0.5D;
double d3 = (double) k1 + (double) (k - k1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D;
world.addParticle("portal", d1, d2, d3, (double) f, (double) f1, (double) f2);
}
}
return;
}
}
}
}
public int a(World world) {
return 5;
}
public boolean c() {
return false;
}
public boolean d() {
return false;
}
public int b() {
return 27;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment