More updates for dual version

This commit is contained in:
libraryaddict 2015-11-29 02:54:16 +13:00
parent d4ab57e4e7
commit 28947643e0
15 changed files with 209 additions and 135 deletions

View File

@ -51,6 +51,11 @@ public class UtilPlayer
return true;
}
public static boolean is1_9(Player player)
{
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() > 47;
}
private static class Vector3D
{

View File

@ -1,5 +1,7 @@
package mineplex.core.common.util;
import java.util.UUID;
import mineplex.core.common.DummyEntity;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity;
@ -97,6 +99,7 @@ public class UtilTextTop
mobPacket.i = (short) 0; //X velocity
mobPacket.j = (short) 0; //Y velocity
mobPacket.k = (short) 0; //Z velocity
mobPacket.uuid = UUID.randomUUID();
//Health
double health = healthPercent * 199.9 + 0.1;
@ -125,6 +128,7 @@ public class UtilTextTop
mobPacket.i = (short) 0; //X velocity
mobPacket.j = (short) 0; //Y velocity
mobPacket.k = (short) 0; //Z velocity
mobPacket.uuid = UUID.randomUUID();
//Health
double health = healthPercent * 299.9 + 0.1;

View File

@ -29,6 +29,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -407,6 +408,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
spawnPacket.i = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.j = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.k = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.uuid = UUID.randomUUID();
double var2 = 3.9D;
double var4 = 0;
@ -451,6 +453,17 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
UtilPlayer.sendPacket(owner, spawnPacket);
if (UtilPlayer.is1_9(owner))
{
PacketPlayOutNewAttachEntity vehiclePacket = new PacketPlayOutNewAttachEntity(entityId, new int[]
{
spawnPacket.a
});
UtilPlayer.sendPacket(owner, vehiclePacket);
}
else
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
@ -458,6 +471,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
UtilPlayer.sendPacket(owner, vehiclePacket);
}
}
else
{
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();

View File

@ -58,6 +58,7 @@ public class DisguiseArmorStand extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D;
double var4 = 0;

View File

@ -43,18 +43,25 @@ public class DisguiseBlock extends DisguiseBase
packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F);
packet.j = 70;
packet.k = _blockId | _blockData << 12;
packet.uuid = Entity.getUniqueID();
double d1 = Entity.motX;
double d2 = Entity.motY;
double d3 = Entity.motZ;
double d4 = 3.9D;
if (d1 < -d4) d1 = -d4;
if (d2 < -d4) d2 = -d4;
if (d3 < -d4) d3 = -d4;
if (d1 > d4) d1 = d4;
if (d2 > d4) d2 = d4;
if (d3 > d4) d3 = d4;
if (d1 < -d4)
d1 = -d4;
if (d2 < -d4)
d2 = -d4;
if (d3 < -d4)
d3 = -d4;
if (d1 > d4)
d1 = d4;
if (d2 > d4)
d2 = d4;
if (d3 > d4)
d3 = d4;
packet.e = ((int) (d1 * 8000.0D));
packet.f = ((int) (d2 * 8000.0D));

View File

@ -33,6 +33,7 @@ public abstract class DisguiseCreature extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D;
double var4 = 0;

View File

@ -35,6 +35,7 @@ public class DisguiseMagmaCube extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D;
double var4 = 0;

View File

@ -29,6 +29,7 @@ public class DisguiseRabbit extends DisguiseAnimal
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D;
double var4 = 0;

View File

@ -35,6 +35,7 @@ public class DisguiseSlime extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D;
double var4 = 0;

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.UUID;
import java.util.Map.Entry;
import org.bukkit.Location;
@ -284,6 +285,7 @@ public class Hologram
packet.d = (int) ((getLocation().getY() + (_hideBoundingBox ? 0 : -2.1) + ((double) textRow * 0.285)) * 32);
packet.e = (int) (getLocation().getZ() * 32);
packet.l = watcher;
packet.uuid = UUID.randomUUID();
// Setup datawatcher for armor stand
watcher.a(0, (byte) 32, EntityArmorStand.META_ENTITYDATA, (byte) 0);

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.christmas;
import java.util.HashSet;
import java.util.UUID;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
@ -162,6 +163,8 @@ public class SleighHorse
packet.d = (int) (loc.getY() * 32);
packet.e = (int) (loc.getZ() * 32) + this._previousDir[(i * 2) + 1];
packet.f = ((byte) (int) (loc.getYaw() * 256.0F / 360.0F));
packet.uuid = UUID.randomUUID();
// Setup datawatcher for armor stand
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32);

View File

@ -259,7 +259,7 @@ public class HideSeek extends TeamGame
.sendPacket(
player,
blockForm
.getBlockPackets());
.getBlockPackets(UtilPlayer.is1_9(player)));
}
});
break;

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade.game.games.hideseek.forms;
import java.util.UUID;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
@ -20,6 +22,7 @@ import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
@ -106,17 +109,30 @@ public class BlockForm extends Form
watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32);
watcher.a(1, 0, Entity.META_AIR, 0);
packet1.l = watcher;
packet1.uuid = UUID.randomUUID();
packets[0] = packet1;
if (UtilPlayer.is1_9(Player))
{
packets[2] = new PacketPlayOutNewAttachEntity(_selfEntityId1, new int[]
{
_selfEntityId2
});
}
else
{
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
packet3.b = _selfEntityId2;
packet3.c = _selfEntityId1;
packets[2] = packet3;
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player,
70, _mat.getId());
packets[2] = packet3;
}
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId());
packet2.a = _selfEntityId2;
packet2.uuid = UUID.randomUUID();
packets[1] = packet2;
UtilPlayer.sendPacket(Player, packets);
@ -143,18 +159,34 @@ public class BlockForm extends Form
Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
}
public Packet[] getBlockPackets()
public Packet[] getBlockPackets(boolean is19)
{
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftPlayer) Player).getHandle(),
70, _mat.getId());
packet2.a = _blockId;
Packet[] packets = new Packet[2];
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftPlayer) Player).getHandle(), 70, _mat.getId());
packet2.a = _blockId;
packet2.uuid = UUID.randomUUID();
packets[0] = packet2;
if (is19)
{
packets[2] = new PacketPlayOutNewAttachEntity(_blockId, new int[]
{
Player.getEntityId()
});
}
else
{
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
packet3.b = _blockId;
packet3.c = Player.getEntityId();
packets[1] = packet3;
}
return new Packet[] {packet2, packet3};
return packets;
}
public int getBlockId()
@ -171,11 +203,12 @@ public class BlockForm extends Form
UtilPlayer.sendPacket(Player, new PacketPlayOutEntityDestroy(new int[]
{
_selfEntityId1, _selfEntityId2, _blockId
_selfEntityId1,
_selfEntityId2,
_blockId
}));
((CraftEntity) Player).getHandle().getDataWatcher()
.watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0);
((CraftEntity) Player).getHandle().getDataWatcher().watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0);
}
public void SolidifyUpdate()
@ -200,8 +233,7 @@ public class BlockForm extends Form
if (Host.GetKit(Player) instanceof KitHiderQuick)
hideBoost = 0.1;
Player.setExp((float) Math.min(0.999f, Player.getExp()
+ hideBoost));
Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost));
// Set Block
if (Player.getExp() >= 0.999f)
@ -209,25 +241,20 @@ public class BlockForm extends Form
Block block = Player.getLocation().getBlock();
// Not Able
if (block.getType() != Material.AIR
|| !UtilBlock.solid(block
.getRelative(BlockFace.DOWN)))
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
{
UtilPlayer.message(Player, F.main("Game",
"You cannot become a Solid Block here."));
UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here."));
Player.setExp(0f);
return;
}
Bukkit.getPluginManager().callEvent(
new HideSeek.PlayerSolidifyEvent(Player));
Bukkit.getPluginManager().callEvent(new HideSeek.PlayerSolidifyEvent(Player));
// Set Block
_block = block;
// Effect
Player.playEffect(Player.getLocation(), Effect.STEP_SOUND,
_mat);
Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat);
// block.getWorld().playEffect(block.getLocation(),
// Effect.STEP_SOUND, _mat);
@ -239,19 +266,16 @@ public class BlockForm extends Form
// Player, Player, 60000, false, false);
// Sound
Player.playSound(Player.getLocation(), Sound.NOTE_PLING,
1f, 2f);
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
// Teleport falling block to the position.
Vector blockLoc = _block.getLocation()
.add(0.5, -.21875, 0.5).toVector();
Vector blockLoc = _block.getLocation().add(0.5, -.21875, 0.5).toVector();
_sawDiff.add(blockLoc.clone().subtract(_lastSaw));
Packet packet = this.getPacket(_sawDiff, blockLoc);
_lastSaw = Player.getLocation().toVector()
.subtract(new Vector(0, 0.15625, 0));
_lastSaw = Player.getLocation().toVector().subtract(new Vector(0, 0.15625, 0));
_sawDiff = _lastSaw.clone().subtract(blockLoc);
if (packet != null)
@ -261,14 +285,12 @@ public class BlockForm extends Form
_sawDiff = new Vector();
}
((CraftPlayer) Player).getHandle().playerConnection
.sendPacket(packet);
((CraftPlayer) Player).getHandle().playerConnection.sendPacket(packet);
}
for (Player player : UtilServer.getPlayers())
{
UtilPlayer.sendPacket(player,
new PacketPlayOutEntityDestroy(new int[]
UtilPlayer.sendPacket(player, new PacketPlayOutEntityDestroy(new int[]
{
getBlockId()
}));
@ -299,16 +321,14 @@ public class BlockForm extends Form
MapUtil.QuickChangeBlockAt(_block.getLocation(), 0, (byte) 0);
_block = null;
EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) Player)
.getHandle().world).tracker.trackedEntities.get(Player
.getEntityId());
EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) Player).getHandle().world).tracker.trackedEntities
.get(Player.getEntityId());
if (tracker != null)
{
for (EntityPlayer entity : tracker.trackedPlayers)
{
UtilPlayer.sendPacket(entity.getBukkitEntity(),
getBlockPackets());
UtilPlayer.sendPacket(entity.getBukkitEntity(), getBlockPackets(UtilPlayer.is1_9(entity.getBukkitEntity())));
}
}
}
@ -349,13 +369,10 @@ public class BlockForm extends Form
if (_lastSaw != null)
{
this._sawDiff.add(Player.getLocation()
.subtract(0, 0.15625, 0).toVector()
.subtract(_lastSaw));
this._sawDiff.add(Player.getLocation().subtract(0, 0.15625, 0).toVector().subtract(_lastSaw));
}
_lastSaw = Player.getLocation().subtract(0, 0.15625, 0)
.toVector();
_lastSaw = Player.getLocation().subtract(0, 0.15625, 0).toVector();
Packet packet = this.getPacket(_sawDiff, _lastSaw);
@ -364,8 +381,7 @@ public class BlockForm extends Form
if (packet instanceof PacketPlayOutRelEntityMove)
{
PacketPlayOutRelEntityMove relPacket = (PacketPlayOutRelEntityMove) packet;
_sawDiff.subtract(new Vector(relPacket.b / 32D,
relPacket.c / 32D, relPacket.d / 32D));
_sawDiff.subtract(new Vector(relPacket.b / 32D, relPacket.c / 32D, relPacket.d / 32D));
}
else
{
@ -385,8 +401,7 @@ public class BlockForm extends Form
if (x != 0 || y != 0 || z != 0)
{
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128
&& z <= 127)
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
relMove.a = this._selfEntityId1;

View File

@ -17,6 +17,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -180,6 +181,7 @@ public class Wall
watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32);
watcher.a(1, 0, Entity.META_AIR, 0);
packet1.l = watcher;
packet1.uuid = UUID.randomUUID();
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftPlayer) player).getHandle(), 70,
Material.STAINED_GLASS.getId() | ids.data << 16);
@ -187,11 +189,26 @@ public class Wall
packet2.b = (int) Math.floor(entry.getKey().getX() * 32);
packet2.c = (int) Math.floor(entry.getKey().getY() * 32);
packet2.d = (int) Math.floor(entry.getKey().getZ() * 32);
packet2.uuid = UUID.randomUUID();
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
Packet packet3;
packet3.b = ids.block;
packet3.c = ids.chicken;
if (UtilPlayer.is1_9(player))
{
packet3 = new PacketPlayOutNewAttachEntity( ids.chicken, new int[]
{
ids.block
});
}
else
{
PacketPlayOutAttachEntity packet = new PacketPlayOutAttachEntity();
packet.b = ids.block;
packet.c = ids.chicken;
packet3 = packet;
}
packets[i++] = packet1;
packets[i++] = packet2;

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.ArrayList;
import java.util.UUID;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
@ -325,6 +326,7 @@ public class SpellRumble extends Spell implements SpellClickBlock, SpellClick
fallingSpawn.i = 70;
fallingSpawn.k = block.getTypeId() | block.getData() << 16;
fallingSpawn.f = 10000;
fallingSpawn.uuid = UUID.randomUUID();
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();