Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
Add redstone events to common blocks
Dieser Commit ist enthalten in:
Ursprung
39acc5817e
Commit
9428907e62
25
src/main/java/net/minecraft/server/BlockBloodStone.java
Normale Datei
25
src/main/java/net/minecraft/server/BlockBloodStone.java
Normale Datei
@ -0,0 +1,25 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
public class BlockBloodStone extends Block {
|
||||
|
||||
public BlockBloodStone(int i, int j) {
|
||||
super(i, j, Material.STONE);
|
||||
}
|
||||
|
||||
//Craftbukkit start
|
||||
public void a(World world, int i, int j, int k, int l) {
|
||||
if(net.minecraft.server.Block.byId[l].c()) {
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);
|
||||
int power = block.getBlockPower();
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
|
||||
server.getPluginManager().callEvent(eventRedstone);
|
||||
}
|
||||
}
|
||||
//Craftbukkit end
|
||||
}
|
@ -1,15 +1,9 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
// CraftBukkit end
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
public class BlockDoor extends Block {
|
||||
|
||||
@ -100,25 +94,6 @@ public class BlockDoor extends Block {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start - Interact Door
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
// The client updates the doors before the server does it's thing.
|
||||
// Forcibly send correct data.
|
||||
if (event.isCancelled()) {
|
||||
((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
|
||||
((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j + 1, k, (WorldServer) world));
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (world.getTypeId(i, j + 1, k) == this.id) {
|
||||
world.c(i, j + 1, k, (l ^ 4) + 8);
|
||||
}
|
||||
@ -196,7 +171,15 @@ public class BlockDoor extends Block {
|
||||
} else if (l > 0 && Block.byId[l].c()) {
|
||||
boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k);
|
||||
|
||||
this.a(world, i, j, k, flag1);
|
||||
//Craftbukkit start
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);
|
||||
int power = block.getBlockPower();
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, flag1 ? 15 : 0);
|
||||
server.getPluginManager().callEvent(eventRedstone);
|
||||
this.a(world, i, j, k, eventRedstone.getNewCurrent());
|
||||
//Craftbukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
66
src/main/java/net/minecraft/server/BlockPumpkin.java
Normale Datei
66
src/main/java/net/minecraft/server/BlockPumpkin.java
Normale Datei
@ -0,0 +1,66 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
public class BlockPumpkin extends Block {
|
||||
|
||||
private boolean a;
|
||||
|
||||
protected BlockPumpkin(int i, int j, boolean flag) {
|
||||
super(i, Material.PUMPKIN);
|
||||
this.textureId = j;
|
||||
this.a(true);
|
||||
this.a = flag;
|
||||
}
|
||||
|
||||
public int a(int i, int j) {
|
||||
if (i == 1) {
|
||||
return this.textureId;
|
||||
} else if (i == 0) {
|
||||
return this.textureId;
|
||||
} else {
|
||||
int k = this.textureId + 1 + 16;
|
||||
|
||||
if (this.a) {
|
||||
++k;
|
||||
}
|
||||
|
||||
return j == 0 && i == 2 ? k : (j == 1 && i == 5 ? k : (j == 2 && i == 3 ? k : (j == 3 && i == 4 ? k : this.textureId + 16)));
|
||||
}
|
||||
}
|
||||
|
||||
public int a(int i) {
|
||||
return i == 1 ? this.textureId : (i == 0 ? this.textureId : (i == 3 ? this.textureId + 1 + 16 : this.textureId + 16));
|
||||
}
|
||||
|
||||
public void e(World world, int i, int j, int k) {
|
||||
super.e(world, i, j, k);
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k) {
|
||||
int l = world.getTypeId(i, j, k);
|
||||
|
||||
return (l == 0 || Block.byId[l].material.isLiquid()) && world.d(i, j - 1, k);
|
||||
}
|
||||
|
||||
public void a(World world, int i, int j, int k, EntityLiving entityliving) {
|
||||
int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
world.c(i, j, k, l);
|
||||
}
|
||||
|
||||
//Craftbukkit start
|
||||
public void a(World world, int i, int j, int k, int l) {
|
||||
if(net.minecraft.server.Block.byId[l].c()) {
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);
|
||||
int power = block.getBlockPower();
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
|
||||
server.getPluginManager().callEvent(eventRedstone);
|
||||
}
|
||||
}
|
||||
//Craftbukkit end
|
||||
}
|
119
src/main/java/net/minecraft/server/BlockSign.java
Normale Datei
119
src/main/java/net/minecraft/server/BlockSign.java
Normale Datei
@ -0,0 +1,119 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
public class BlockSign extends BlockContainer {
|
||||
|
||||
private Class a;
|
||||
private boolean b;
|
||||
|
||||
protected BlockSign(int i, Class oclass, boolean flag) {
|
||||
super(i, Material.WOOD);
|
||||
this.b = flag;
|
||||
this.textureId = 4;
|
||||
this.a = oclass;
|
||||
float f = 0.25F;
|
||||
float f1 = 1.0F;
|
||||
|
||||
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
|
||||
}
|
||||
|
||||
public AxisAlignedBB d(World world, int i, int j, int k) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
|
||||
if (!this.b) {
|
||||
int l = iblockaccess.getData(i, j, k);
|
||||
float f = 0.28125F;
|
||||
float f1 = 0.78125F;
|
||||
float f2 = 0.0F;
|
||||
float f3 = 1.0F;
|
||||
float f4 = 0.125F;
|
||||
|
||||
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (l == 2) {
|
||||
this.a(f2, f, 1.0F - f4, f3, f1, 1.0F);
|
||||
}
|
||||
|
||||
if (l == 3) {
|
||||
this.a(f2, f, 0.0F, f3, f1, f4);
|
||||
}
|
||||
|
||||
if (l == 4) {
|
||||
this.a(1.0F - f4, f, f2, 1.0F, f1, f3);
|
||||
}
|
||||
|
||||
if (l == 5) {
|
||||
this.a(0.0F, f, f2, f4, f1, f3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected TileEntity a_() {
|
||||
try {
|
||||
return (TileEntity) this.a.newInstance();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public int a(int i, Random random) {
|
||||
return Item.SIGN.id;
|
||||
}
|
||||
|
||||
public void a(World world, int i, int j, int k, int l) {
|
||||
boolean flag = false;
|
||||
|
||||
if (this.b) {
|
||||
if (!world.getMaterial(i, j - 1, k).isBuildable()) {
|
||||
flag = true;
|
||||
}
|
||||
} else {
|
||||
int i1 = world.getData(i, j, k);
|
||||
|
||||
flag = true;
|
||||
if (i1 == 2 && world.getMaterial(i, j, k + 1).isBuildable()) {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (i1 == 3 && world.getMaterial(i, j, k - 1).isBuildable()) {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (i1 == 4 && world.getMaterial(i + 1, j, k).isBuildable()) {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (i1 == 5 && world.getMaterial(i - 1, j, k).isBuildable()) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
this.b_(world, i, j, k, world.getData(i, j, k));
|
||||
world.e(i, j, k, 0);
|
||||
}
|
||||
|
||||
super.a(world, i, j, k, l);
|
||||
|
||||
//Craftbukkit start
|
||||
if(net.minecraft.server.Block.byId[l].c()) {
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Block block = craftWorld.getBlockAt(i, j, k);
|
||||
int power = block.getBlockPower();
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
|
||||
server.getPluginManager().callEvent(eventRedstone);
|
||||
}
|
||||
//Craftbukkit end
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren