Posted September 20, 201510 yr I am having issues after i change the player's hitbox. Once i set the hitbox using EntityPlayer setEntityBoundingBox() the hitbox is set correctly and is shown correctly using f3 + b, But when i try going under a block if pushes me out like i was 2 blocks tall. If i sprint under i can manage to get though the issue, But if i get near the edge of the 1 block high area i get sucked out as though i was 2 blocks tall. Note i can move fine not near the edge of the 1 block high area. For those wondering i have also tried reflection to use the setSize Method but it doesn't even change the player's hitbox (I may be doing it incorrectly). Anyone have any Fixes or Suggestions? @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent e) { EntityPlayer player = e.player; float height = 0.9f; float width = 0.3f; player.height = height; player.width = width; player.eyeHeight = 0.8f; player.setEntityBoundingBox(new AxisAlignedBB(player.getEntityBoundingBox().minX, player.getEntityBoundingBox().minY, player.getEntityBoundingBox().minZ, player.getEntityBoundingBox().minX + width, player.getEntityBoundingBox().minY + height, player.getEntityBoundingBox().minZ + width)); if (getBlockAbove(player) != null && !(getBlockAbove(player) instanceof BlockAir && RaceManager.getPlayerRace(player).Height() <= 0.9f)) { // Player is 1 block high and a block is above } } private static Block getBlockAbove(Entity entity) { World world = entity.worldObj; return world.getBlockState(new BlockPos(entity.posX, entity.posY+1,entity.posZ)).getBlock(); } private static final String setSizeObf = "func_177725_a"; private static final String setSizeDeobf = "setSize"; public static Method setSizeMethod; public static void setSize(Entity entity, float width, float height) { try { Method m = EntityLivingBase.class.getDeclaredMethod(isObfuscation() ? setSizeObf : setSizeDeobf, float.class, float.class); setSizeMethod = m; } catch(NoSuchMethodException e) { entity.width = width; entity.height = height; } catch(Exception e) { e.printStackTrace(); } if(setSizeMethod != null) { try { setSizeMethod.setAccessible(true); setSizeMethod.invoke(entity, width, height); } catch(Exception e) { e.printStackTrace(); } } } public static boolean isObfuscation() { boolean obfuscation = true; try { Field[] fields = Class.forName("net.minecraft.world.World").getDeclaredFields(); for(Field f : fields) { f.setAccessible(true); if(f.getName().equalsIgnoreCase("loadedEntityList")) { obfuscation = false; } } } catch (Exception e) {} return obfuscation; } - Wurmatron
February 8, 20169 yr I have the same problem and I've asked on MinecraftForum...the issue is probably in pushOutOfBlocks in EntityPlayerSP, I'll let you know when I get it to work ^^
February 8, 20169 yr I had my fun with hitboxes and EVERYTHING worked. Since right now I have no clue what might be wrong (unless your event is somehow not called on server), I can only note few things: 1. ObfuscationReflectionHelper - it does whole reflection part for you. 2. When using reflection - get field/method once. Point of interest: Java 7 - MethodHandle (and yes, don't bother with java 6 compatibility, users should update their shit, seriously). 3. TickEvents have 2 phases, pick one (code will be ran twice otherwise) - if (event.phase == Phase.START). 4. It is entirely possible (and should be done that way) to setSize once, not every tick, but I understand this is a test code. 5. Finally - look for solution in PlayerAPI, more exact - SmartMoving mod. It allows players to crawl, so basically what you want. 1.7.10 is no longer supported by forge, you are on your own.
February 9, 20169 yr I tried it with PlayerAPI and the way SmartMoving does it and I can go under one block, but I still can't get in the near of a wall...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.