Posted April 5, 20178 yr Hello guys, In the past i have created mobs with random textures, it uses this function inside getentitytexture: int id = (int) ((par1Entity.getUniqueID().getLeastSignificantBits() ^ par1Entity.getUniqueID().getMostSignificantBits()) % 3); so it will basicly be able to use 3 textures at random. this works just fine. but, i recently created a mob wich has a total of 10 textures but when i change the modules to % 10 it works but isnt completely random anymore i spawned 100 mobs got 40 of texture wich corrosponds to id value 9 but none with value 1 and the rest just dont spawn that often. is this becouse of the way the uniqueid are made? What function is better to use? example:https://gyazo.com/c4c33d934749112dc726e65cdfc1aecb blue white shirts corrospond to value 9.
April 5, 20178 yr Author @SideOnly(Side.CLIENT) public void registerRenderers() { RenderLiving customRender = new RenderLiving(Minecraft.getMinecraft().getRenderManager(), new Civilian.ModelNew(), 0) { protected ResourceLocation getEntityTexture(Entity par1Entity) { int id = (int) ((par1Entity.getUniqueID().getLeastSignificantBits() ^ par1Entity.getUniqueID().getMostSignificantBits()) % 10); if(id == 0) { return new ResourceLocation("Civilian.png"); } else if(id == 1) { return new ResourceLocation("Civilian1.png"); } else if(id == 2) { return new ResourceLocation("Civilian2.png"); } else if(id == 3) { return new ResourceLocation("Civilian3.png"); } else if(id == 4) { return new ResourceLocation("Civilian4.png"); } else if(id == 5) { return new ResourceLocation("Civilian5.png"); } else if(id == 6) { return new ResourceLocation("Civilian6.png"); } else if(id == 7) { return new ResourceLocation("Civilian7.png"); } else if(id == 8) { return new ResourceLocation("Civilian8.png"); } else { return new ResourceLocation("Civilian9.png"); } } }; RenderingRegistry.registerEntityRenderingHandler(Civilian.EntityCivilian.class, customRender); }
April 5, 20178 yr Ew. That if-else block. Yuck. return new ResourceLocation("Civilian" + id + ".png"); //magic Also, the reason it isn't random is because the XOR operation isn't random. You're much more likely to get particular values than others. When I did something like this, I used a Mersenne twister. Nothing else got me close. https://github.com/Draco18s/HarderStuff/blob/master/src/main/java/com/draco18s/hazards/block/BlockUnstableStone.java#L175-L180 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.