2011-08-10 04:25:33 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
import java.util.List;
|
2011-08-10 04:25:33 +02:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class BlockPistonExtension extends Block {
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public BlockPistonExtension() {
|
|
|
|
super(Material.PISTON);
|
|
|
|
this.a(i);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.c(0.5F);
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) {
|
|
|
|
if (entityhuman.abilities.canInstantlyBuild) {
|
2013-11-04 14:07:38 +01:00
|
|
|
int i1 = b(l);
|
|
|
|
Block block = world.getType(i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1]);
|
2013-07-09 01:43:37 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block == Blocks.PISTON || block == Blocks.PISTON_STICKY) {
|
2013-07-09 01:43:37 +02:00
|
|
|
world.setAir(i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.a(world, i, j, k, l, entityhuman);
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void remove(World world, int i, int j, int k, Block block, int l) {
|
|
|
|
super.remove(world, i, j, k, block, l);
|
|
|
|
if ((l & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue
|
|
|
|
int i1 = Facing.OPPOSITE_FACING[b(l)];
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
i += Facing.b[i1];
|
|
|
|
j += Facing.c[i1];
|
|
|
|
k += Facing.d[i1];
|
|
|
|
Block block1 = world.getType(i, j, k);
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block1 == Blocks.PISTON || block1 == Blocks.PISTON_STICKY) {
|
|
|
|
l = world.getData(i, j, k);
|
|
|
|
if (BlockPiston.c(l)) {
|
|
|
|
block1.b(world, i, j, k, l, 0);
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setAir(i, j, k);
|
2011-08-10 04:25:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public int b() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return 17;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean c() {
|
2011-08-10 04:25:33 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean d() {
|
2011-08-10 04:25:33 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canPlace(World world, int i, int j, int k) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canPlace(World world, int i, int j, int k, int l) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Random random) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List list, Entity entity) {
|
2011-08-10 04:25:33 +02:00
|
|
|
int l = world.getData(i, j, k);
|
2013-07-01 13:03:00 +02:00
|
|
|
float f = 0.25F;
|
|
|
|
float f1 = 0.375F;
|
|
|
|
float f2 = 0.625F;
|
|
|
|
float f3 = 0.25F;
|
|
|
|
float f4 = 0.75F;
|
2011-08-10 04:25:33 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
switch (b(l)) {
|
2011-08-10 04:25:33 +02:00
|
|
|
case 0:
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.a(0.375F, 0.25F, 0.375F, 0.625F, 1.0F, 0.625F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.a(0.375F, 0.0F, 0.375F, 0.625F, 0.75F, 0.625F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.a(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.a(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.a(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
this.a(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F);
|
2012-07-29 09:33:13 +02:00
|
|
|
super.a(world, i, j, k, axisalignedbb, list, entity);
|
2011-08-10 04:25:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
|
2011-08-10 04:25:33 +02:00
|
|
|
int l = iblockaccess.getData(i, j, k);
|
2013-07-01 13:03:00 +02:00
|
|
|
float f = 0.25F;
|
2011-08-10 04:25:33 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
switch (b(l)) {
|
2011-08-10 04:25:33 +02:00
|
|
|
case 0:
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void doPhysics(World world, int i, int j, int k, Block block) {
|
|
|
|
int l = b(world.getData(i, j, k));
|
|
|
|
if ((l & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue
|
|
|
|
Block block1 = world.getType(i - Facing.b[l], j - Facing.c[l], k - Facing.d[l]);
|
2011-08-10 04:25:33 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block1 != Blocks.PISTON && block1 != Blocks.PISTON_STICKY) {
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setAir(i, j, k);
|
2011-08-10 04:25:33 +02:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
block1.doPhysics(world, i - Facing.b[l], j - Facing.c[l], k - Facing.d[l], block);
|
2011-08-10 04:25:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public static int b(int i) {
|
2011-08-10 04:25:33 +02:00
|
|
|
return i & 7;
|
|
|
|
}
|
|
|
|
}
|