TallYate Posted June 11, 2020 Posted June 11, 2020 I have a projectile that I shoot out of my head, but it covers almost the whole screen so I want it to be invisible for like half a second in first person mode. How would I do this? Quote
TheGreyGhost Posted June 12, 2020 Posted June 12, 2020 Howdy I'd suggest you make your own EntityRenderer for your projectile. The renderer can check whether the player is in first person view, and if so, make sure that the entity is at least a given minimum distance away from the player's head before rendering it. Third person view (0, 1, 2) is accessible from GameSettings and ActiveRenderInfo (minecraft->gameRenderer->activerenderinfo) -TGG Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 Thank you for replying. This works perfectly, but I have another question. How do I get the player that is rendering the entity, because I would like the render to be cancelled only for the shooter. Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 if( Minecraft.getInstance().gameSettings.thirdPersonView==0 && entityIn.ticksExisted<20 && Minecraft.getInstance().player == entityIn.shootingEntity ) { return; } super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); This is now never true, but if I add .getEntity() to them the player and shootingEntity, it crashes, also, I tried using .getName but that also crashes the game. The crash occurs whenever the entity is rendered Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { if(player.isSneaking()) { Vec3d look = player.getLookVec(); Vec3d pos = player.getPositionVec(); AccurateSkull skull = new AccurateSkull(world, player, look.x*2, look.y*2, look.z*2); skull.setPosition(pos.x, player.getPosYEye(), pos.z); skull.addTag("shooter:"+player.getName().toString()); world.playSound(player, player.getPosition(), SoundEvents.ENTITY_WITHER_SHOOT, SoundCategory.PLAYERS , 1.0F, 1.0F); world.addEntity(skull); player.getHeldItem(hand).damageItem(100, player, Player -> {}); return ActionResult.resultSuccess(player.getHeldItem(hand)); } else { return ActionResult.resultFail(player.getHeldItem(hand)); } } Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 also I just noticed that I shouldn't add that tag because it's already in the entity, so just ignore that bit Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 AccurateSkull skull = new AccurateSkull(world, player, look.x*2, look.y*2, look.z*2); here are the constructors being used public AccurateSkull(World worldIn, LivingEntity shooter, double accelX, double accelY, double accelZ) { super(EntityType.WITHER_SKULL, shooter, accelX, accelY, accelZ, worldIn); } public AccurateProjectile(EntityType<?> p_i50175_1_, LivingEntity p_i50175_2_, double p_i50175_3_, double p_i50175_5_, double p_i50175_7_, World p_i50175_9_) { this(p_i50175_1_, p_i50175_9_); this.shootingEntity = p_i50175_2_; this.setLocationAndAngles(p_i50175_2_.getPosX(), p_i50175_2_.getPosY(), p_i50175_2_.getPosZ(), p_i50175_2_.rotationYaw, p_i50175_2_.rotationPitch); this.recenterBoundingBox(); this.setMotion(Vec3d.ZERO); p_i50175_3_ = p_i50175_3_ + this.rand.nextGaussian() * 0.02D; p_i50175_5_ = p_i50175_5_ + this.rand.nextGaussian() * 0.02D; p_i50175_7_ = p_i50175_7_ + this.rand.nextGaussian() * 0.02D; double d0 = (double)MathHelper.sqrt(p_i50175_3_ * p_i50175_3_ + p_i50175_5_ * p_i50175_5_ + p_i50175_7_ * p_i50175_7_); this.accelerationX = p_i50175_3_ / d0 * 0.1D; this.accelerationY = p_i50175_5_ / d0 * 0.1D; this.accelerationZ = p_i50175_7_ / d0 * 0.1D; } Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 AccurateProjectile extends Entity btw Quote
TallYate Posted June 13, 2020 Author Posted June 13, 2020 ok I checked if the entity is null and it is null, but that doesn't make sense because the constructor should set this.shootingEntity to the correct player Quote
CAS_ual_TY Posted June 13, 2020 Posted June 13, 2020 shootingEntity might be null on client side (havent checked). Extend your entity with IEntityAdditionalSpawnData if that is the case. Quote https://github.com/CAS-ual-TY/Visibilis [1.14] How to Villagers, Trades, Professions, Fix Trades https://minecraft.curseforge.com/projects/gun-customization-infinity / https://github.com/CAS-ual-TY/GunCus https://minecraft.curseforge.com/projects/ygo-dueling-mod https://minecraft.curseforge.com/projects/mundus-magicus https://minecraft.curseforge.com/projects/deuf-duplicate-entity-uuid-fix
TallYate Posted June 14, 2020 Author Posted June 14, 2020 so what do I do after I implement it? Quote
TallYate Posted June 14, 2020 Author Posted June 14, 2020 so in the writespawndata I can write down the entity with it's UniqueId or Id but in the readSpawnData, how would I convert it back into an entity from it's id, or is there a way to write the LivingEntity into the buffer Quote
TallYate Posted June 14, 2020 Author Posted June 14, 2020 It's still null, what am I doing wrong? @Override public void writeSpawnData(PacketBuffer buffer) { buffer.writeInt(this.shootingEntity.getEntityId()); } @Override public void readSpawnData(PacketBuffer additionalData) { this.shootingEntity=(LivingEntity) this.world.getEntityByID(additionalData.readInt()); } Quote
TallYate Posted June 14, 2020 Author Posted June 14, 2020 I made them log, but nothing is logged so I think I'm missing something Quote
TallYate Posted June 14, 2020 Author Posted June 14, 2020 return NetworkHooks.getEntitySpawningPacket(this); I overrided createSpawnPacket with this and now I see writeSpawnData from the server side, but readSpawnData doesn't do anything Quote
TallYate Posted June 15, 2020 Author Posted June 15, 2020 https://github.com/TallYate/Bedrock-Things-mod/tree/master/src/main/java/me/joshua/bedrockthings/util It's mostly just a copied version of the vanilla versions, but I turned the projectile randomness down. Quote
TallYate Posted June 15, 2020 Author Posted June 15, 2020 I want it to be a wither skull though, I just made the class because I didn't know another way to remove the randomness when spawning a wither skeleton skull Quote
TallYate Posted June 15, 2020 Author Posted June 15, 2020 Ok I registered an EntityType and readSpawnData is now being run on the client side, but right after it runs, the game crashes Quote
Ugdhar Posted June 15, 2020 Posted June 15, 2020 Just now, TallYate said: the game crashes When that happens, *always* post your debug.log, just saying it crashes doesn't really tell anyone anything Quote
TallYate Posted June 15, 2020 Author Posted June 15, 2020 [m[32m[08:59:51] [Server thread/INFO] [me.jo.be.BedrockThings/]: entitySpawningPacket created [m[32m[08:59:51] [Server thread/INFO] [me.jo.be.BedrockThings/]: false writing [m[32m[08:59:51] [Render thread/INFO] [me.jo.be.BedrockThings/]: true reading [m[1;31m[08:59:51] [Render thread/FATAL] [minecraft/Minecraft]: Unreported exception thrown! java.lang.NullPointerException: null at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:233) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:947) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:612) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:434) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:961) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:558) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231] {} at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231] {} at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_231] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.0.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {} Quote
TallYate Posted June 15, 2020 Author Posted June 15, 2020 opened with debugger [m[1;31m[09:07:28] [Server thread/ERROR] [minecraft/ChunkSerializer]: An Entity type net.minecraft.entity.EntityType@1d8ecb80 has thrown an exception trying to write state. It will not persist. Report this to the mod author net.minecraft.crash.ReportedException: Saving entity NBT at net.minecraft.entity.Entity.writeWithoutTypeId(Entity.java:1562) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.Entity.writeUnlessRemoved(Entity.java:1467) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.Entity.writeUnlessPassenger(Entity.java:1483) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:302) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:701) ~[?:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) [?:1.8.0_231] {} at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) [?:1.8.0_231] {} at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) [?:1.8.0_231] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) [?:1.8.0_231] {} at java.util.stream.AbstractPipeline.copyInto(Unknown Source) [?:1.8.0_231] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) [?:1.8.0_231] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) [?:1.8.0_231] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) [?:1.8.0_231] {} at java.util.stream.AbstractPipeline.evaluate(Unknown Source) [?:1.8.0_231] {} at java.util.stream.ReferencePipeline.forEach(Unknown Source) [?:1.8.0_231] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:355) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:317) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:778) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:544) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:587) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:241) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:701) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_231] {} Caused by: java.lang.NullPointerException at me.joshua.bedrockthings.util.AccurateProjectile.writeAdditional(AccurateProjectile.java:159) ~[?:?] {re:classloading} at net.minecraft.entity.Entity.writeWithoutTypeId(Entity.java:1541) ~[?:?] {re:classloading,pl:accesstransformer:B} Quote
Ugdhar Posted June 15, 2020 Posted June 15, 2020 42 minutes ago, TallYate said: Caused by: java.lang.NullPointerException at me.joshua.bedrockthings.util.AccurateProjectile.writeAdditional(AccurateProjectile.java:159) ~[?:?] {re:classloading} Track that NPE down I'd say, based on the partial logs you've shown, figure out what's null and why, and fix it if it shouldn't be Quote
TallYate Posted June 15, 2020 Author Posted June 15, 2020 I think this is what is crashing the game because if I removed the overrided createSpawnPacket, it doesn't crash, but the skull is invisible @Override public void writeSpawnData(PacketBuffer buffer) { BedrockThings.log( (this.world.isRemote()) + " writing"); buffer.writeInt(this.shootingEntity.getEntityId()); } @Override public void readSpawnData(PacketBuffer additionalData) { BedrockThings.log( (this.world.isRemote()) + " reading"); //this.shootingEntity=(LivingEntity) this.world.getEntityByID(additionalData.readInt()); } public IPacket<?> createSpawnPacket() { BedrockThings.log("entitySpawningPacket created"); return NetworkHooks.getEntitySpawningPacket(this); } Quote
Recommended Posts
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.