2011-01-08 14:33:54 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-12 18:40:42 +01:00
|
|
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
2011-04-04 06:48:40 +02:00
|
|
|
import org.bukkit.event.entity.EntityInteractEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-08 14:33:54 +01:00
|
|
|
|
|
|
|
public class BlockPressurePlate extends Block {
|
|
|
|
|
|
|
|
private EnumMobType a;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
protected BlockPressurePlate(int i, int j, EnumMobType enummobtype, Material material) {
|
|
|
|
super(i, j, material);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a = enummobtype;
|
|
|
|
this.a(true);
|
2011-01-08 14:33:54 +01:00
|
|
|
float f = 0.0625F;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public int d() {
|
2011-01-08 14:33:54 +01:00
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
public AxisAlignedBB e(World world, int i, int j, int k) {
|
2011-01-08 14:33:54 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean b() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean canPlace(World world, int i, int j, int k) {
|
2011-09-15 02:23:52 +02:00
|
|
|
return world.e(i, j - 1, k) || world.getTypeId(i, j - 1, k) == Block.FENCE.id;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void onPlace(World world, int i, int j, int k) {}
|
2011-01-08 14:33:54 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
2011-01-08 14:33:54 +01:00
|
|
|
boolean flag = false;
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (!world.e(i, j - 1, k) && world.getTypeId(i, j - 1, k) != Block.FENCE.id) {
|
2011-01-08 14:33:54 +01:00
|
|
|
flag = true;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-08 14:33:54 +01:00
|
|
|
if (flag) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.b(world, i, j, k, world.getData(i, j, k), 0);
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!world.isStatic) {
|
|
|
|
if (world.getData(i, j, k) != 0) {
|
|
|
|
this.g(world, i, j, k);
|
|
|
|
}
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Entity entity) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!world.isStatic) {
|
|
|
|
if (world.getData(i, j, k) != 1) {
|
|
|
|
this.g(world, i, j, k);
|
|
|
|
}
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void g(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = world.getData(i, j, k) == 1;
|
2011-01-08 14:33:54 +01:00
|
|
|
boolean flag1 = false;
|
|
|
|
float f = 0.125F;
|
|
|
|
List list = null;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.a == EnumMobType.EVERYTHING) {
|
2012-03-01 11:49:23 +01:00
|
|
|
list = world.getEntities((Entity) null, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.a == EnumMobType.MOBS) {
|
|
|
|
list = world.a(EntityLiving.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.a == EnumMobType.PLAYERS) {
|
|
|
|
list = world.a(EntityHuman.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-08 14:33:54 +01:00
|
|
|
if (list.size() > 0) {
|
|
|
|
flag1 = true;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2011-03-16 21:27:24 +01:00
|
|
|
// CraftBukkit start - Interact Pressure Plate
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.World bworld = world.getWorld();
|
|
|
|
org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
|
|
|
|
|
2011-03-02 16:36:09 +01:00
|
|
|
if (flag != flag1) {
|
2011-03-16 21:27:24 +01:00
|
|
|
if (flag1) {
|
2012-01-14 23:02:10 +01:00
|
|
|
for (Object object : list) {
|
2011-04-04 06:48:40 +02:00
|
|
|
if (object != null) {
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.event.Cancellable cancellable;
|
2011-06-12 00:02:58 +02:00
|
|
|
|
2011-04-04 06:48:40 +02:00
|
|
|
if (object instanceof EntityHuman) {
|
2012-07-22 08:18:00 +02:00
|
|
|
cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
|
2011-06-12 00:02:58 +02:00
|
|
|
} else if (object instanceof Entity) {
|
2011-06-27 00:25:01 +02:00
|
|
|
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
|
|
|
|
manager.callEvent((EntityInteractEvent) cancellable);
|
2011-06-12 00:02:58 +02:00
|
|
|
} else {
|
|
|
|
continue;
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
if (cancellable.isCancelled()) {
|
2011-03-16 21:27:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
|
|
|
|
manager.callEvent(eventRedstone);
|
2011-03-16 21:27:24 +01:00
|
|
|
|
2011-03-02 16:36:09 +01:00
|
|
|
flag1 = eventRedstone.getNewCurrent() > 0;
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-02-19 16:55:47 +01:00
|
|
|
|
2011-01-08 14:33:54 +01:00
|
|
|
if (flag1 && !flag) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setData(i, j, k, 1);
|
|
|
|
world.applyPhysics(i, j, k, this.id);
|
|
|
|
world.applyPhysics(i, j - 1, k, this.id);
|
2011-01-08 14:33:54 +01:00
|
|
|
world.b(i, j, k, i, j, k);
|
2011-04-20 19:05:14 +02:00
|
|
|
world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-08 14:33:54 +01:00
|
|
|
if (!flag1 && flag) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setData(i, j, k, 0);
|
|
|
|
world.applyPhysics(i, j, k, this.id);
|
|
|
|
world.applyPhysics(i, j - 1, k, this.id);
|
2011-01-08 14:33:54 +01:00
|
|
|
world.b(i, j, k, i, j, k);
|
2011-04-20 19:05:14 +02:00
|
|
|
world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-08 14:33:54 +01:00
|
|
|
if (flag1) {
|
2011-11-20 09:01:14 +01:00
|
|
|
world.c(i, j, k, this.id, this.d());
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void remove(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
int l = world.getData(i, j, k);
|
2011-01-08 14:33:54 +01:00
|
|
|
|
|
|
|
if (l > 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.applyPhysics(i, j, k, this.id);
|
|
|
|
world.applyPhysics(i, j - 1, k, this.id);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
super.remove(world, i, j, k);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = iblockaccess.getData(i, j, k) == 1;
|
2011-01-08 14:33:54 +01:00
|
|
|
float f = 0.0625F;
|
|
|
|
|
|
|
|
if (flag) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
|
2011-01-08 14:33:54 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f);
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return iblockaccess.getData(i, j, k) > 0;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
public boolean d(World world, int i, int j, int k, int l) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return world.getData(i, j, k) == 0 ? false : l == 1;
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isPowerSource() {
|
2011-01-08 14:33:54 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-01 14:05:57 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void f() {
|
|
|
|
float f = 0.5F;
|
|
|
|
float f1 = 0.125F;
|
|
|
|
float f2 = 0.5F;
|
|
|
|
|
|
|
|
this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int g() {
|
2011-07-01 14:05:57 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2011-01-08 14:33:54 +01:00
|
|
|
}
|