Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to change player's eyeheight.

I think it's impossible without replacing a vanilla method.

So I used coremod, but my cord caused error.

I think this cause is that 0.5 is double, but I don't know to define float value on JavaScript.

How do I solve this?

 

I have bad English, so I apologize if I say something strange.

 

Vanilla Method:

public float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) {
      switch(poseIn) {
      case SWIMMING:
      case FALL_FLYING:
      case SPIN_ATTACK:
         return 0.4F;
      case CROUCHING:
         return 1.27F;
      default:
         return 1.62F;
      }
   }

 

Byte Code of Vanilla Method:

public getStandingEyeHeight(Lnet/minecraft/entity/Pose;Lnet/minecraft/entity/EntitySize;)F
   L0
    LINENUMBER 1771 L0
    GETSTATIC net/minecraft/entity/player/PlayerEntity$1.$SwitchMap$net$minecraft$entity$Pose : [I
    ALOAD 1
    INVOKEVIRTUAL net/minecraft/entity/Pose.ordinal ()I
    IALOAD
    TABLESWITCH
      1: L1
      2: L1
      3: L1
      4: L2
      default: L3
   L1
    LINENUMBER 1775 L1
   FRAME SAME
    LDC 0.4
    FRETURN
   L2
    LINENUMBER 1777 L2
   FRAME SAME
    LDC 1.27
    FRETURN
   L3
    LINENUMBER 1779 L3
   FRAME SAME
    LDC 1.62
    FRETURN
   L4
    LOCALVARIABLE this Lnet/minecraft/entity/player/PlayerEntity; L0 L4 0
    LOCALVARIABLE p_213348_1_ Lnet/minecraft/entity/Pose; L0 L4 1
    LOCALVARIABLE p_213348_2_ Lnet/minecraft/entity/EntitySize; L0 L4 2
    MAXSTACK = 2
    MAXLOCALS = 3

 

Transformer.js:

var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI');
var Opcodes = Java.type('org.objectweb.asm.Opcodes');

var mappedMethodName = ASMAPI.mapMethod("func_213348_b");

function initializeCoreMod() {
    return {
        'coremodmethod': {
            'target': {
                'type': 'METHOD',
                'class': 'net.minecraft.entity.player.PlayerEntity',
                'methodName': mappedMethodName,
                'methodDesc': '(Lnet/minecraft/entity/Pose;Lnet/minecraft/entity/EntitySize;)F'
            },
            'transformer': function(method) {
                var arrayLength = method.instructions.size();
                for (var i = arrayLength - 1; i >= 0; --i) {
                     var instruction = method.instructions.get(i);
                     if (instruction.getOpcode() == Opcodes.LDC) {
                        var LdcInsnNode = Java.type('org.objectweb.asm.tree.LdcInsnNode');
                        var newInstruction = new LdcInsnNode(0.5);
                        method.instructions.insertBefore(instruction, newInstruction);
                        method.instructions.remove(instruction);
                        print("Transformed!");
                        break;
                     }
                }
                return method;
            }
        }
    }
}

 

Error:

[main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    net/minecraft/entity/player/PlayerEntity.getStandingEyeHeight(Lnet/minecraft/entity/Pose;Lnet/minecraft/entity/EntitySize;)F @51: freturn
  Reason:
    Type double_2nd (current frame, stack[1]) is not assignable to float
  Current Frame:
    bci: @51
    flags: { }
    locals: { 'net/minecraft/entity/player/PlayerEntity', 'net/minecraft/entity/Pose', 'net/minecraft/entity/EntitySize' }
    stack: { double, double_2nd }

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.