Merge remote-tracking branch 'remotes/origin/master' into virizion_speed_builder

This commit is contained in:
Virizion 2015-12-05 19:58:55 -05:00
commit 5b49c4adc3

View File

@ -19,13 +19,13 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
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.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -49,7 +49,7 @@ import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
private NautHashMap<String, NautHashMap<Integer, Integer[]>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer[]>>();
private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>();
private HashSet<String> _loggedIn = new HashSet<String>();
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
@ -63,7 +63,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class,
PacketPlayInUseEntity.class);
PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class);
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
@ -190,7 +190,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
if (owner.isOnline() && !_entityMap.containsKey(owner.getName()))
{
_entityMap.put(owner.getName(), new NautHashMap<Integer, Integer>());
_entityMap.put(owner.getName(), new NautHashMap<Integer, Integer[]>());
_entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>());
_loggedIn.add(owner.getName());
}
@ -217,10 +217,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[]
{
_entityMap.get(owner.getName()).get(spawnPacket.a)
}));
Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a);
int[] newIds = new int[ids.length];
for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
_entityMap.get(owner.getName()).remove(spawnPacket.a);
@ -236,9 +241,59 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
int newId = UtilEnt.getNewEntityId();
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
{
newId
});
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true);
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1);
break;
}
}
}
else if (packet instanceof PacketPlayOutNamedEntitySpawn)
{
PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet;
for (WatchableObject watchable : (List<WatchableObject>) spawnPacket.i.c())
{
if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1)
{
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{
Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a);
int[] newIds = new int[ids.length];
for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
_entityMap.get(owner.getName()).remove(spawnPacket.a);
}
final String entityName = spawnPacket.i.getString(2);
if (entityName.isEmpty())
{
return;
}
int newId = UtilEnt.getNewEntityId();
int newId2 = UtilEnt.getNewEntityId();
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
{
newId,
newId2
});
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, newId2);
break;
}
}
@ -247,7 +302,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet;
if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a) && metaPacket.a != owner.getEntityId())
{
boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a);
@ -279,7 +334,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
// If name is still being displayed
if (newDisplay)
{
int newId;
Integer[] newId;
if (isDisplaying) // Sending metadata
{
@ -288,22 +343,29 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
else
// Spawning new entity
{
newId = UtilEnt.getNewEntityId();
newId = new Integer[]
{
UtilEnt.getNewEntityId()
};
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
}
sendProtocolPackets(owner, metaPacket.a, newId, newName, verifier, !isDisplaying);
sendProtocolPackets(owner, metaPacket.a, newId[0], newName, verifier, !isDisplaying, -1);
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
}
else
{ // Lets delete it
int id = _entityMap.get(owner.getName()).get(metaPacket.a);
Integer[] ids = _entityMap.get(owner.getName()).get(metaPacket.a);
int[] newIds = new int[ids.length];
verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[]
{
id
}));
for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds));
_entityMap.get(owner.getName()).remove(metaPacket.a);
_entityNameMap.get(owner.getName()).remove(metaPacket.a);
@ -319,10 +381,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
if (_entityMap.get(owner.getName()).containsKey(id))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[]
{
_entityMap.get(owner.getName()).get(id)
}));
Integer[] ids = _entityMap.get(owner.getName()).get(id);
int[] newIds = new int[ids.length];
for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityMap.get(owner.getName()).remove(id);
_entityNameMap.get(owner.getName()).remove(id);
}
@ -345,19 +412,25 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet;
for (Entry<Integer, Integer> entry : _entityMap.get(owner.getName()).entrySet())
{
if (entry.getValue() == usePacket.a)
{
PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey();
newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK
: EnumEntityUseAction.INTERACT;
loop:
for (Entry<Integer, Integer[]> entry : _entityMap.get(owner.getName()).entrySet())
{
for (int id : entry.getValue())
{
if (id == usePacket.a)
{
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);
PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey();
newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK
: EnumEntityUseAction.INTERACT;
{
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);
}
break loop;
}
break;
}
}
}
@ -365,7 +438,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName,
final PacketVerifier packetList, final boolean newPacket)
final PacketVerifier packetList, final boolean newPacket, final int squidId)
{
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event);
@ -377,80 +450,46 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte) 0));
watcher.a(0, (byte) (0 | 1 << 5)); // Invisible
watcher.a(1, Short.valueOf((short) 300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(2, finalEntityName);
watcher.a(3, (byte) 1);
watcher.a(4, Byte.valueOf((byte) 0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte) 0));
// Set invisible
int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte) (i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte) (b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte) 1));
watcher.a(10, (byte) (0 | 0x1)); // Small
if (newPacket)
{
if (squidId >= 0)
{
watcher.watch(10, (byte) 16);
final DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld())
.getHandle()));
squidWatcher.a(0, (byte) (0 | 1 << 5));
final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = squidId;
spawnPacket.b = (byte) EntityType.SQUID.getTypeId();
spawnPacket.l = squidWatcher;
UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId;
UtilPlayer.sendPacket(owner, vehiclePacket);
}
final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId;
spawnPacket.b = (byte) 30;
spawnPacket.c = (int) MathHelper.floor(100 * 32);
spawnPacket.d = (int) MathHelper.floor(64 * 32.0D);
spawnPacket.e = (int) MathHelper.floor(100 * 32);
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));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
spawnPacket.f = (int) (var4 * 8000.0D);
spawnPacket.g = (int) (var6 * 8000.0D);
spawnPacket.h = (int) (var8 * 8000.0D);
spawnPacket.l = watcher;
@ -459,7 +498,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId;
vehiclePacket.c = squidId >= 0 ? squidId : entityId;
UtilPlayer.sendPacket(owner, vehiclePacket);
}