Implemented BlockState.update(boolean), signs should now work, cleaned up some code a little
Dieser Commit ist enthalten in:
Ursprung
c9efe94545
Commit
d374bff8d0
@ -2,8 +2,8 @@ package net.minecraft.server;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Vector;
|
import org.bukkit.Vector;
|
||||||
import org.bukkit.craftbukkit.CraftEntity;
|
import org.bukkit.craftbukkit.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.CraftMappable;
|
import org.bukkit.craftbukkit.CraftMappable;
|
||||||
import org.bukkit.craftbukkit.CraftMinecart;
|
import org.bukkit.craftbukkit.CraftMinecart;
|
||||||
@ -14,7 +14,7 @@ import org.bukkit.event.vehicle.*;
|
|||||||
public class EntityMinecart extends Entity
|
public class EntityMinecart extends Entity
|
||||||
implements IInventory, CraftMappable {
|
implements IInventory, CraftMappable {
|
||||||
|
|
||||||
private CraftMinecart minecart;
|
private CraftMinecart minecart;
|
||||||
|
|
||||||
private ItemStack ak[];
|
private ItemStack ak[];
|
||||||
public int a;
|
public int a;
|
||||||
@ -94,18 +94,18 @@ public class EntityMinecart extends Entity
|
|||||||
private double aq;
|
private double aq;
|
||||||
private double ar;
|
private double ar;
|
||||||
private double as;
|
private double as;
|
||||||
|
|
||||||
private boolean slowWhenEmpty = true;
|
private boolean slowWhenEmpty = true;
|
||||||
private double derailedX = 0.5;
|
private double derailedX = 0.5;
|
||||||
private double derailedY = 0.5;
|
private double derailedY = 0.5;
|
||||||
private double derailedZ = 0.5;
|
private double derailedZ = 0.5;
|
||||||
private double flyingX = 0.94999998807907104;
|
private double flyingX = 0.94999998807907104;
|
||||||
private double flyingY = 0.94999998807907104;
|
private double flyingY = 0.94999998807907104;
|
||||||
private double flyingZ = 0.94999998807907104;
|
private double flyingZ = 0.94999998807907104;
|
||||||
|
|
||||||
public CraftEntity getCraftEntity() {
|
public CraftEntity getCraftEntity() {
|
||||||
return minecart;
|
return minecart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityMinecart(World world) {
|
public EntityMinecart(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -120,7 +120,7 @@ public class EntityMinecart extends Entity
|
|||||||
M = false;
|
M = false;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
handleCreation(world);
|
handleCreation(world);
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,19 +155,19 @@ public class EntityMinecart extends Entity
|
|||||||
d = i;
|
d = i;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
handleCreation(world);
|
handleCreation(world);
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
|
||||||
|
|
||||||
// CraftBukkit start
|
|
||||||
private void handleCreation(World world) {
|
|
||||||
CraftServer server = ((WorldServer) world).getServer();
|
|
||||||
minecart = CraftMinecart.getCraftMinecart(server, this);
|
|
||||||
VehicleCreateEvent event = new VehicleCreateEvent(
|
|
||||||
Type.VEHICLE_CREATE, minecart);
|
|
||||||
server.getPluginManager().callEvent(event);
|
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
|
||||||
|
// CraftBukkit start
|
||||||
|
private void handleCreation(World world) {
|
||||||
|
CraftServer server = ((WorldServer) world).getServer();
|
||||||
|
minecart = CraftMinecart.getCraftMinecart(server, this);
|
||||||
|
VehicleCreateEvent event = new VehicleCreateEvent(
|
||||||
|
Type.VEHICLE_CREATE, minecart);
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public double j() {
|
public double j() {
|
||||||
return (double) J * 0.0D - 0.30000001192092896D;
|
return (double) J * 0.0D - 0.30000001192092896D;
|
||||||
@ -176,14 +176,14 @@ public class EntityMinecart extends Entity
|
|||||||
public boolean a(Entity entity, int i) {
|
public boolean a(Entity entity, int i) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
VehicleDamageEvent event = new VehicleDamageEvent(
|
VehicleDamageEvent event = new VehicleDamageEvent(
|
||||||
Type.VEHICLE_DAMAGE, minecart,
|
Type.VEHICLE_DAMAGE, minecart,
|
||||||
((WorldServer)l).getWorld().toCraftEntity(entity), i);
|
((WorldServer)l).getWorld().toCraftEntity(entity), i);
|
||||||
((WorldServer)l).getServer().getPluginManager().callEvent(event);
|
((WorldServer)l).getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
i = event.getDamage();
|
i = event.getDamage();
|
||||||
|
|
||||||
@ -246,12 +246,12 @@ public class EntityMinecart extends Entity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void b_() {
|
public void b_() {
|
||||||
double prevX = p;
|
double prevX = p;
|
||||||
double prevY = q;
|
double prevY = q;
|
||||||
double prevZ = r;
|
double prevZ = r;
|
||||||
float prevYaw = v;
|
float prevYaw = v;
|
||||||
float prevPitch = w;
|
float prevPitch = w;
|
||||||
|
|
||||||
if (b > 0) {
|
if (b > 0) {
|
||||||
b--;
|
b--;
|
||||||
}
|
}
|
||||||
@ -380,7 +380,7 @@ public class EntityMinecart extends Entity
|
|||||||
} else if (ai[1][1] != 0 && MathHelper.b(p) - i == ai[1][0] && MathHelper.b(r) - i1 == ai[1][2]) {
|
} else if (ai[1][1] != 0 && MathHelper.b(p) - i == ai[1][0] && MathHelper.b(r) - i1 == ai[1][2]) {
|
||||||
a(p, q + (double) ai[1][1], r);
|
a(p, q + (double) ai[1][1], r);
|
||||||
}
|
}
|
||||||
if (j != null || !slowWhenEmpty) {
|
if (j != null || !slowWhenEmpty) {
|
||||||
s *= 0.99699997901916504D;
|
s *= 0.99699997901916504D;
|
||||||
t *= 0.0D;
|
t *= 0.0D;
|
||||||
u *= 0.99699997901916504D;
|
u *= 0.99699997901916504D;
|
||||||
@ -459,18 +459,18 @@ public class EntityMinecart extends Entity
|
|||||||
u = d6;
|
u = d6;
|
||||||
}
|
}
|
||||||
if (A) {
|
if (A) {
|
||||||
s *= derailedX;
|
s *= derailedX;
|
||||||
t *= derailedY;
|
t *= derailedY;
|
||||||
u *= derailedZ;
|
u *= derailedZ;
|
||||||
}
|
}
|
||||||
c(s, t, u);
|
c(s, t, u);
|
||||||
if (!A) {
|
if (!A) {
|
||||||
s *= flyingX;
|
s *= flyingX;
|
||||||
t *= flyingY;
|
t *= flyingY;
|
||||||
u *= flyingZ;
|
u *= flyingZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = 0.0F;
|
w = 0.0F;
|
||||||
double d28 = m - p;
|
double d28 = m - p;
|
||||||
double d29 = o - r;
|
double d29 = o - r;
|
||||||
@ -637,36 +637,36 @@ public class EntityMinecart extends Entity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
CraftServer server = ((WorldServer)l).getServer();
|
CraftServer server = ((WorldServer)l).getServer();
|
||||||
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(
|
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(
|
||||||
Type.VEHICLE_COLLISION_ENTITY, minecart,
|
Type.VEHICLE_COLLISION_ENTITY, minecart,
|
||||||
((WorldServer)l).getWorld().toCraftEntity(entity));
|
((WorldServer)l).getWorld().toCraftEntity(entity));
|
||||||
server.getPluginManager().callEvent(collsionEvent);
|
server.getPluginManager().callEvent(collsionEvent);
|
||||||
|
|
||||||
if (collsionEvent.isCancelled()) {
|
if (collsionEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
if (!collsionEvent.isPickupCancelled()
|
||||||
|
&& (entity instanceof EntityLiving) && !(entity instanceof EntityPlayer)
|
||||||
|
&& d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
|
||||||
|
// CraftBukkit start
|
||||||
|
VehicleEnterEvent enterEvent = new VehicleEnterEvent(
|
||||||
|
Type.VEHICLE_ENTER, minecart,
|
||||||
|
((WorldServer)l).getWorld().toCraftEntity(entity));
|
||||||
|
server.getPluginManager().callEvent(enterEvent);
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
if (!enterEvent.isCancelled()) {
|
||||||
|
entity.e(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
if (!collsionEvent.isPickupCancelled()
|
|
||||||
&& (entity instanceof EntityLiving) && !(entity instanceof EntityPlayer)
|
|
||||||
&& d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
|
|
||||||
// CraftBukkit start
|
|
||||||
VehicleEnterEvent enterEvent = new VehicleEnterEvent(
|
|
||||||
Type.VEHICLE_ENTER, minecart,
|
|
||||||
((WorldServer)l).getWorld().toCraftEntity(entity));
|
|
||||||
server.getPluginManager().callEvent(enterEvent);
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
if (!enterEvent.isCancelled()) {
|
|
||||||
entity.e(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
double d1 = entity.p - p;
|
double d1 = entity.p - p;
|
||||||
double d2 = entity.r - r;
|
double d2 = entity.r - r;
|
||||||
double d3 = d1 * d1 + d2 * d2;
|
double d3 = d1 * d1 + d2 * d2;
|
||||||
|
|
||||||
if (!collsionEvent.isCollisionCancelled() && d3 >= 9.9999997473787516E-005D) {
|
if (!collsionEvent.isCollisionCancelled() && d3 >= 9.9999997473787516E-005D) {
|
||||||
d3 = MathHelper.a(d3);
|
d3 = MathHelper.a(d3);
|
||||||
d1 /= d3;
|
d1 /= d3;
|
||||||
d2 /= d3;
|
d2 /= d3;
|
||||||
@ -760,7 +760,7 @@ public class EntityMinecart extends Entity
|
|||||||
|
|
||||||
public void d() {}
|
public void d() {}
|
||||||
|
|
||||||
public boolean a(EntityPlayer entityplayer) {
|
public boolean a(EntityPlayer entityplayer) {
|
||||||
if (d == 0) {
|
if (d == 0) {
|
||||||
if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
|
if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,6 +4,7 @@ package org.bukkit.craftbukkit;
|
|||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftSign;
|
||||||
|
|
||||||
public class CraftBlock implements Block {
|
public class CraftBlock implements Block {
|
||||||
private final CraftWorld world;
|
private final CraftWorld world;
|
||||||
@ -253,6 +254,15 @@ public class CraftBlock implements Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getState() {
|
public BlockState getState() {
|
||||||
return new CraftBlockState(world, x, y, z, type, data);
|
Material material = getType();
|
||||||
|
|
||||||
|
switch (material) {
|
||||||
|
case Sign:
|
||||||
|
case SignPost:
|
||||||
|
case WallSign:
|
||||||
|
return new CraftSign(this);
|
||||||
|
default:
|
||||||
|
return new CraftBlockState(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
import net.minecraft.server.EntityBoat;
|
import net.minecraft.server.EntityBoat;
|
||||||
import org.bukkit.Boat;
|
import org.bukkit.Boat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A minecart.
|
* A minecart.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class CraftBoat extends CraftVehicle implements Boat {
|
public class CraftBoat extends CraftVehicle implements Boat {
|
||||||
protected EntityBoat boat;
|
protected EntityBoat boat;
|
||||||
|
|
||||||
public CraftBoat(CraftServer server, EntityBoat entity) {
|
public CraftBoat(CraftServer server, EntityBoat entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
boat = entity;
|
boat = entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that an object has a method to get its CraftBukkit-equivalent
|
* Indicates that an object has a method to get its CraftBukkit-equivalent
|
||||||
* CraftEntity object from its Minecraft net.minecraft.server.Entity object.
|
* CraftEntity object from its Minecraft net.minecraft.server.Entity object.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public interface CraftMappable {
|
public interface CraftMappable {
|
||||||
/**
|
/**
|
||||||
* Gets the CraftEntity version.
|
* Gets the CraftEntity version.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CraftEntity getCraftEntity();
|
public CraftEntity getCraftEntity();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import net.minecraft.server.EntityPlayerMP;
|
|||||||
import net.minecraft.server.EntitySnowball;
|
import net.minecraft.server.EntitySnowball;
|
||||||
import net.minecraft.server.EntityArrow;
|
import net.minecraft.server.EntityArrow;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
import net.minecraft.server.WorldGenBigTree;
|
import net.minecraft.server.WorldGenBigTree;
|
||||||
import net.minecraft.server.WorldServer;
|
import net.minecraft.server.WorldServer;
|
||||||
import net.minecraft.server.WorldGenTrees;
|
import net.minecraft.server.WorldGenTrees;
|
||||||
@ -185,6 +186,10 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TileEntity getTileEntityAt(final int x, final int y, final int z) {
|
||||||
|
return world.l(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CraftWorld";
|
return "CraftWorld";
|
||||||
|
@ -19,15 +19,15 @@ public class CraftBlockState implements BlockState {
|
|||||||
protected byte data;
|
protected byte data;
|
||||||
protected byte light;
|
protected byte light;
|
||||||
|
|
||||||
public CraftBlockState(final CraftWorld world, final int x, final int y, final int z, final int type, final byte data) {
|
public CraftBlockState(final Block block) {
|
||||||
this.world = world;
|
this.world = (CraftWorld)block.getWorld();
|
||||||
this.x = x;
|
this.x = block.getX();
|
||||||
this.y = y;
|
this.y = block.getY();
|
||||||
this.z = z;
|
this.z = block.getZ();
|
||||||
this.type = type;
|
this.type = block.getTypeID();
|
||||||
this.data = data;
|
this.data = block.getData();
|
||||||
this.light = (byte)world.getHandle().i(x, y, z);
|
this.light = block.getLightLevel();
|
||||||
this.chunk = (CraftChunk)world.getChunkAt(x << 4, z << 4);
|
this.chunk = (CraftChunk)block.getChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,8 +153,14 @@ public class CraftBlockState implements BlockState {
|
|||||||
|
|
||||||
synchronized (block) {
|
synchronized (block) {
|
||||||
if (block.getType() != this.getType()) {
|
if (block.getType() != this.getType()) {
|
||||||
return false;
|
if (force) {
|
||||||
|
block.setTypeID(this.getTypeID());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block.setData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,27 +1,42 @@
|
|||||||
|
|
||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntitySign;
|
||||||
import org.bukkit.Block;
|
import org.bukkit.Block;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
public class CraftSign extends CraftBlockState implements Sign {
|
public class CraftSign extends CraftBlockState implements Sign {
|
||||||
public CraftSign(final CraftWorld world, final int x, final int y, final int z, final int type, final byte data) {
|
private final CraftWorld world;
|
||||||
super(world, x, y, z, type, data);
|
private final TileEntitySign sign;
|
||||||
|
|
||||||
|
public CraftSign(final Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
world = (CraftWorld)block.getWorld();
|
||||||
|
sign = (TileEntitySign)world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getLines() {
|
public String[] getLines() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
return sign.e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
return sign.e[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLine(int index, String line) throws IndexOutOfBoundsException {
|
public void setLine(int index, String line) throws IndexOutOfBoundsException {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
sign.e[index] = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(boolean force) {
|
||||||
|
boolean result = super.update(force);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
sign.d();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren