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

153 Zeilen
4.5 KiB
Java

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-03-13 23:33:27 +01:00
private IIcon a = null;
2011-08-10 04:25:33 +02:00
2013-03-13 23:33:27 +01:00
public BlockPistonExtension(int i) {
super(i, Material.PISTON);
this.a(j);
2011-08-10 04:25:33 +02:00
this.c(0.5F);
}
2012-07-29 09:33:13 +02:00
public void remove(World world, int i, int j, int k, int l, int i1) {
super.remove(world, i, j, k, l, i1);
if ((i1 & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue
2013-03-13 23:33:27 +01:00
int j1 = Facing.OPPOSITE_FACING[d(i1)];
2012-07-29 09:33:13 +02:00
i += Facing.b[j1];
j += Facing.c[j1];
k += Facing.d[j1];
int k1 = world.getTypeId(i, j, k);
if (k1 == Block.PISTON.id || k1 == Block.PISTON_STICKY.id) {
i1 = world.getData(i, j, k);
2013-03-13 23:33:27 +01:00
if (BlockPiston.e(i1)) {
2012-07-29 09:33:13 +02:00
Block.byId[k1].c(world, i, j, k, i1, 0);
2013-03-13 23:33:27 +01:00
world.setAir(i, j, k);
2011-08-10 04:25:33 +02:00
}
}
}
public int d() {
2011-11-20 09:01:14 +01:00
return 17;
}
public boolean c() {
2011-08-10 04:25:33 +02:00
return false;
}
public boolean b() {
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-03-13 23:33:27 +01:00
switch (d(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);
}
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-03-13 23:33:27 +01:00
switch (d(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);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
2013-03-13 23:33:27 +01:00
int i1 = d(world.getData(i, j, k));
if ((i1 & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue
int j1 = world.getTypeId(i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1]);
2011-08-10 04:25:33 +02:00
if (j1 != Block.PISTON.id && j1 != Block.PISTON_STICKY.id) {
2013-03-13 23:33:27 +01:00
world.setAir(i, j, k);
2011-08-10 04:25:33 +02:00
} else {
Block.byId[j1].doPhysics(world, i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1], l);
2011-08-10 04:25:33 +02:00
}
}
2013-03-13 23:33:27 +01:00
public static int d(int i) {
2011-08-10 04:25:33 +02:00
return i & 7;
}
}