zhuowei / MCPELauncher

Source code for BlockLauncher, a launcher that patches Minecraft for Android
Apache License 2.0
675 stars 191 forks source link

EntityRenderType for cow is incorrect #282

Closed duggum closed 8 years ago

duggum commented 8 years ago

BlockLauncher Pro v1.10.3 MCPE v0.12.2

The render type id for cow (7) is incorrect. It should be 6; 7 is for Mooshrooms. Run the following code and look at a cow to confirm:

var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
function modTick() {
  if (ctx != null) {
    ctx.runOnUiThread(new java.lang.Runnable({
      run: function() {
        try {
          // this prints 6 if you look at a cow; 7 for a mooshroom
          ModPE.showTipMessage(Entity.getRenderType(Player.getPointedEntity()));
        } catch (err) {
          print(err);
        }
      }
    }));
  }
}

cows

slice commented 8 years ago

Might be off topic, but why are you running this in the UI thread? I believe it is not required.

duggum commented 8 years ago

@sliceofcode The code and images above are just a means of demonstrating that the EntityRenderType for 'cow' is 6, not '7' as it is assigned in EntityRenderType.cow.

The code I was running that brought this to my attention is:

// make all pigs look like cows
function entityAddedHook(entity) {
  if (Entity.getEntityTypeId(entity) === EntityType.PIG) {
    Entity.setRenderType(entity, EntityRenderType.cow);
  }
}

I was just running some test code to help me learn the API, and I was surprised to see all new pigs rendering as Mooshrooms, not Cows. pigshroom

zhuowei commented 8 years ago

re UI thread: yeah, please don't run that on the UI thread (technically all Minecraft methods should be accessed on game thread, not UI thread; however, I don't think Minecraft cares) Thank you so much - fixed in latest beta.