Everything posted by Daniel366Cobra
-
[1.12.2] Registering a custom Player Renderer
Any help? Please?
-
[1.12.2] Registering a custom Player Renderer
Greetings, I have been experimenting with custom flying recently, enabling elytra-like flight when a certain piece of armor is worn by using a EntityPlayerMP.setElytraFlying() method called from a PlayerTickEvent. While this works, I believe it is not a good way to do that because every tick the player will check for worn elytra (Thanks, Mojang, for using == Items.ELYTRA instead of an instanceof()!) and unset the flag. As such, I want to calculate the physics independently. But this brings another problem: the vanilla RenderPlayer rotates the model by checking the isElytraFlying(). This means I'll need a custom player renderer to apply similar rotations to a non-Elytra flying player. I tried to create a "RenderPlayerCustom extends RenderPlayer" class, but cannot register it with the Rendering Registry - the "RenderPLayerCustom::new" part is erroring. Could you please give me a tip on how to substitute the vanilla player renderer?
-
[1.12.2] Help with onUsingTick
Well, guess full auto has to go because I have no other idea of how to store ammo and the animation gets on my nerves. Draco18s and Jabelar, thank you for your help!
-
[1.12.2] Help with onUsingTick
Thank you, I'll try lowering the rate of fire to around 2 per second and see what happens. So, lowering the rate helped a bit - the unexpected full auto happens around 1 in 5 times now. It also seems to happen almost exclusively after a short click, while click&hold allows for controllable firing. Also I detected that as long as I hold the RMB, after each shot a re-equipping animation plays. Is that because of the NBT update? Dan
-
[1.12.2] Help with onUsingTick
OK, So I added console outputs for onItemRightClick(), onUsingTick() and onPlayerStoppedUsing() and caught a very strange bug: The onPlayerStoppedUsing is never called. public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) { if (entityLiving instanceof EntityPlayer) { System.out.println("Stopped using"); } } I never saw it in the console. Also it looks like it is... unsynchronized? I can't understand why else I could get this kind of messages where it starts firing several times. [22:11:55] [main/INFO] [STDOUT]: [items.ItemSubmachineGun:onItemRightClick:126]: Starting firing [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onItemRightClick:126]: Starting firing [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 72000, 25 ammo left [22:11:55] [main/INFO] [STDOUT]: [items.ItemSubmachineGun:onItemRightClick:126]: Starting firing [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 71997, 24 ammo left [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onItemRightClick:126]: Starting firing [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 71994, 23 ammo left [22:11:55] [main/INFO] [STDOUT]: [items.ItemSubmachineGun:onItemRightClick:126]: Starting firing [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onItemRightClick:126]: Starting firing [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 71991, 22 ammo left [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 71988, 21 ammo left [22:11:55] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 71985, 20 ammo left [22:11:56] [Server thread/INFO] [STDOUT]: [items.ItemSubmachineGun:onUsingTick:163]: Shooting @ tick count 71982, 19 ammo left ...Firing, firing, firing, although I already let go of the RMB... ...No "Stopped Using" message... I am sorry for being bothersome, but I just can't understand why onPlayerStoppedUsing() is never called.
-
[1.12.2] Help with onUsingTick
Greetings everyone, I've been trying to code an automatic shooting weapon recently, and encountered a problem. My weapon uses an NBT integer tag to store the current magazine contents, and should fire as long as the RMB is held and there is ammo in the magazine. I use this code: public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {//Every 3rd tick... if (count % 3 == 0) {//...get the world we are in... World world = player.world; //...get magazine contents... int magCount = stack.getTagCompound().getInteger("magazine"); //...if the magazine has ammo... if (magCount > 0) { if (!world.isRemote) { //decrease the ammo... stack.getTagCompound().setInteger("magazine", magCount - 1); //...create and spawn the bullet, play shot sound. EntityGenericBullet bullet = new EntityGenericBullet(world, player, 6.0D, 0.5D, false); bullet.shoot(player, player.rotationPitch, player.rotationYaw, 5.0F, 1.0F); world.spawnEntity(bullet); world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.submachinegunfire, SoundCategory.PLAYERS, 6.0F, 1.0F / (itemRand.nextFloat() * 0.2F + 0.8F)); } //Small recoil player.setLocationAndAngles(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch - (itemRand.nextFloat() + 1.0F)); } } } And for some reason, it gives a weird bug: sometimes upon a short RMB press, instead of a short burst, the weapon empties the entire magazine. That does not always happen though. What am I doing wrong? Thanks in advance, Dan
IPS spam blocked by CleanTalk.