Camellias_

Untitled

Nov 27th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1.     public static final Method setSize = ReflectionHelper.findMethod(Entity.class, "setSize", "func_70105_a", float.class, float.class);   
  2.  
  3.     @SubscribeEvent
  4.     public static void playerUpdate(TickEvent.PlayerTickEvent event)
  5.     {
  6.         EntityPlayer player = event.player;
  7.        
  8.         EntityEquipmentSlot head = EntityEquipmentSlot.HEAD;
  9.         EntityEquipmentSlot chest = EntityEquipmentSlot.CHEST;
  10.         EntityEquipmentSlot legs = EntityEquipmentSlot.LEGS;
  11.         EntityEquipmentSlot feet = EntityEquipmentSlot.FEET;
  12.        
  13.         Item helmet = ModItems.SPACE_SUIT_HELMET;
  14.         Item body = ModItems.SPACE_SUIT_CHEST;
  15.         Item leggings = ModItems.SPACE_SUIT_LEGS;
  16.         Item boots = ModItems.SPACE_SUIT_BOOTS;
  17.        
  18.         if(player.getItemStackFromSlot(head).getItem() == helmet &&
  19.                 player.getItemStackFromSlot(chest).getItem() == body &&
  20.                 player.getItemStackFromSlot(legs).getItem() == leggings &&
  21.                 player.getItemStackFromSlot(feet).getItem() == boots)
  22.         {
  23.             AxisAlignedBB aabb = player.getEntityBoundingBox();
  24.             float height = 1.8F;
  25.             float width = 0.6F;
  26.            
  27.             player.eyeHeight = height * 0.9F;
  28.             player.stepHeight = height / 3F;
  29.             player.setEntityBoundingBox(new AxisAlignedBB(aabb.minX, aabb.minY, aabb.minZ, aabb.minX + width,
  30.                     aabb.minY + height, aabb.minZ + width));
  31.            
  32.             if(!player.world.collidesWithAnyBlock(aabb))
  33.             {
  34.                 player.setEntityBoundingBox(new AxisAlignedBB(aabb.minX, aabb.minY, aabb.minZ, aabb.minX + width,
  35.                         aabb.minY + height, aabb.minZ + width));
  36.                
  37.                 try
  38.                 {
  39.                     setSize.invoke(player, width, height);
  40.                 }
  41.                 catch (IllegalAccessException e)
  42.                 {
  43.                     e.printStackTrace();
  44.                 }
  45.                 catch (IllegalArgumentException e)
  46.                 {
  47.                     e.printStackTrace();
  48.                 }
  49.                 catch (InvocationTargetException e)
  50.                 {
  51.                     e.printStackTrace();
  52.                 }
  53.             }
  54.         }
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment