More WorldEvent work

This commit is contained in:
pahimar 2012-12-06 21:06:16 -05:00
parent 69293538b9
commit ae14f68167
4 changed files with 18 additions and 21 deletions

View file

@ -117,9 +117,9 @@ public class ClientProxy extends CommonProxy {
}
@Override
public void sendWorldEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, int targetID, int targetMeta) {
public void sendWorldEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketWorldEvent(eventType, originX, originY, originZ, sideHit, rangeX, rangeY, rangeZ, targetID, targetMeta)));
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketWorldEvent(eventType, originX, originY, originZ, sideHit, rangeX, rangeY, rangeZ, data)));
}
}

View file

@ -63,7 +63,7 @@ public class CommonProxy implements IGuiHandler {
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
}
public void sendWorldEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, int targetID, int targetMeta) {
public void sendWorldEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
}

View file

@ -80,14 +80,16 @@ public class ItemPhilosopherStone extends ItemEE
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ) {
boolean result = TransmutationHelper.transmuteInWorld(world, entityPlayer, itemStack, x, y, z);
EquivalentExchange3.proxy.sendWorldEventPacket(WorldEvents.TRANSMUTATION, x, y, z, (byte)sideHit, (byte)getCharge(itemStack), (byte)getCharge(itemStack), (byte)getCharge(itemStack), 50, 0);
//boolean result = TransmutationHelper.transmuteInWorld(world, entityPlayer, itemStack, x, y, z);
boolean result = true;
if (!world.isRemote) {
EquivalentExchange3.proxy.sendWorldEventPacket(WorldEvents.TRANSMUTATION, x, y, z, (byte)sideHit, (byte)getCharge(itemStack), (byte)getCharge(itemStack), (byte)getCharge(itemStack), "50:0");
}
/*
if (result) {
itemStack.damageItem(1, entityPlayer);
}
*/
return result;
}

View file

@ -13,14 +13,14 @@ public class PacketWorldEvent extends PacketEE {
public int originX, originY, originZ;
public byte sideHit;
public byte rangeX, rangeY, rangeZ;
public int targetID, targetMeta;
public String data;
public PacketWorldEvent() {
super(PacketTypeHandler.WORLD_EVENT, false);
}
public PacketWorldEvent(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, int targetID, int targetMeta) {
public PacketWorldEvent(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
super(PacketTypeHandler.WORLD_EVENT, false);
this.eventType = eventType;
@ -31,8 +31,7 @@ public class PacketWorldEvent extends PacketEE {
this.rangeX = rangeX;
this.rangeY = rangeY;
this.rangeZ = rangeZ;
this.targetID = targetID;
this.targetMeta = targetMeta;
this.data = data;
}
public void setEventType(byte eventType) {
@ -58,10 +57,9 @@ public class PacketWorldEvent extends PacketEE {
this.rangeZ = rangeZ;
}
public void setTransmutationTarget(int targetID, int targetMeta) {
public void setData(String data) {
this.targetID = targetID;
this.targetMeta = targetMeta;
this.data = data;
}
public void writeData(DataOutputStream data) throws IOException {
@ -74,8 +72,7 @@ public class PacketWorldEvent extends PacketEE {
data.writeByte(rangeX);
data.writeByte(rangeY);
data.writeByte(rangeZ);
data.writeInt(targetID);
data.writeInt(targetMeta);
data.writeUTF(this.data);
}
public void readData(DataInputStream data) throws IOException {
@ -88,8 +85,7 @@ public class PacketWorldEvent extends PacketEE {
this.rangeX = data.readByte();
this.rangeY = data.readByte();
this.rangeZ = data.readByte();
this.targetID = data.readInt();
this.targetMeta = data.readInt();
this.data = data.readUTF();
}
public void execute(INetworkManager manager, Player player) {
@ -102,8 +98,7 @@ public class PacketWorldEvent extends PacketEE {
System.out.println("rangeX: " + rangeX);
System.out.println("rangeY: " + rangeY);
System.out.println("rangeZ: " + rangeZ);
System.out.println("targetID: " + targetID);
System.out.println("targetMeta: " + targetMeta);
System.out.println("data: " + data);
}
}