Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventTarget
- public void onMotion(MotionUpdateEvent e) {
- if(!getState())
- return;
- switch(e.getState()) {
- case UPDATE:
- for (Object entity : mc.theWorld.loadedEntityList)
- if (((Entity)entity).isInvisible() && entity != mc.thePlayer)
- {
- mc.theWorld.removeEntity((Entity)entity);
- }
- break;
- }
- }
- @EventTarget
- public void onPacket(PacketEvent e) {
- if(!getState())
- return;
- for (Object entity : this.mc.theWorld.loadedEntityList) {
- if (!(entity instanceof EntityPlayer)) {
- return;
- }
- if (mc.thePlayer.equals(entity)) {
- continue;
- }
- if (((Entity)entity).isInvisible()) {
- this.mc.theWorld.removeEntity((Entity)entity);
- }
- }
- if ((e.getPacket() instanceof S0CPacketSpawnPlayer)) {
- S0CPacketSpawnPlayer packet = (S0CPacketSpawnPlayer) e.getPacket();
- final double posX = packet.func_148942_f() / 64.0;
- final double posY = packet.func_148949_g() / 64.0;
- final double posZ = packet.func_148946_h() / 64.0;
- final double difX = mc.thePlayer.posX - posX;
- final double difY = mc.thePlayer.posY - posY;
- final double difZ = mc.thePlayer.posZ - posZ;
- final double dist = Math.sqrt((difX * difX + difY * difY + difZ * difZ) * posX + posY + posZ);
- if (dist <=20.0) {
- final double n = posX;
- if (n != mc.thePlayer.posX) {
- final double n2 = posY;
- if (n2 != mc.thePlayer.posY) {
- final double n3 = posZ;
- if (n3 != mc.thePlayer.posZ) {
- e.setCancelled(true);
- }
- }
- }
- }
- }
- if(e.getPacket() instanceof S0CPacketSpawnPlayer) {
- //Creates a new variable based on the packet
- S0CPacketSpawnPlayer spawnedEntity = (S0CPacketSpawnPlayer) e.getPacket();
- //Creates an object for all the entites in the ArrayList. Doesn't use a lambda due to NullPointers
- for (EntityPlayer entity : entities) {
- //Checks if the name of the entity spawned is the same as an entity that already exists.
- if (mc.theWorld.getPlayerEntityByUUID(spawnedEntity.func_179819_c()).getName().equals(entity.getName())) {
- //Cancels the event so the entity does not spawn on the user's side.
- e.setCancelled(true);
- return;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement