Posted October 13, 20195 yr I have tried using the FakePlayerFactory in 1.14, however upon using it, the game crashes: java.lang.NullPointerException: Exception ticking world at net.minecraft.world.TrackedEntity.func_219451_a(TrackedEntity.java:284) ~[?:?] {re:classloading} at net.minecraft.world.TrackedEntity.func_219457_c(TrackedEntity.java:256) ~[?:?] {re:classloading} at net.minecraft.world.TrackedEntity.func_219453_a(TrackedEntity.java:153) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219169_g(ChunkManager.java:978) ~[?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.func_217220_m(SourceFile:417) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerChunkProvider.func_217207_a(SourceFile:335) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.func_72835_b(ServerWorld.java:309) ~[?:?] {re:classloading} at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:829) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:764) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:112) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} I used: world.addEntity(FakePlayerFactory.get(ServerLifecycleHooks.getCurrentServer().getWorld(DimensionType.OVERWORLD), new GameProfile(UUID.randomUUID(), "Farmer")));
October 14, 20195 yr A fake player is not an Entity that can be added to the world. What are you trying to achieve? Edited October 14, 20195 yr by DavidM Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
October 14, 20195 yr Author 5 hours ago, DavidM said: A fake player is not an Entity that can be added to the world. What are you trying to achieve? Thanks for your response. I am trying to create player NPCs that function just like a real player but I am able to modify to open GUIs, set their AI goals etc. I tried creating a custom entity and setting the model as a player, however there is no player model in the minecraft render manager that supports Forge's IRenderFactory. I tried getting the entity to at least show by setting it to a rabbit but that just created an invisible entity with a shadow.
October 14, 20195 yr Author 4 hours ago, diesieben07 said: That's not what FakePlayer is for. You need to write your own entity. An NPC player functions nothing like a real player, most of the special functionality of a player is that it's controlled by a human, not AI. Please explain how to create my own entity then. As I stated, I tried this and it simply refuses to render via Minecraft's default renders.
October 14, 20195 yr 31 minutes ago, SamB440 said: I tried this and it simply refuses to render via Minecraft's default renders. Show what you tried. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 15, 20195 yr Author 22 hours ago, Animefan8888 said: Show what you tried. I created a class extending CreatureEntity: public class FarmerEntity extends CreatureEntity { public FarmerEntity(EntityType<? extends CreatureEntity> type, World worldIn) { super(type, worldIn); } @Override protected void registerGoals() { this.goalSelector.addGoal(1, new LookAtGoal(this, PlayerEntity.class, 10.0F)); this.goalSelector.addGoal(2, new LookRandomlyGoal(this)); applyEntityAI(); } protected void applyEntityAI() { this.goalSelector.addGoal(1, new SwimGoal(this)); this.goalSelector.addGoal(2, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); } @Override protected void registerAttributes() { super.registerAttributes(); this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); } } I then registered entity types: public class EntityTypes { public static final EntityType<FarmerEntity> FARMER = null; @Mod.EventBusSubscriber(modid = Utils.MODID, bus = Bus.MOD) public static class RegistrationHandler { /** * Register this mod's {@link Entity} types. * * @param event The event */ @SubscribeEvent public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) { final EntityType<FarmerEntity> farmer = build( "farmer", EntityType.Builder.<FarmerEntity>create((FarmerEntity::new), EntityClassification.MISC) .size(0.5f, 0.5f) ); event.getRegistry().registerAll( farmer ); } /** * Build an {@link EntityType} from a {@link EntityType.Builder} using the specified name. * * @param name The entity type name * @param builder The entity type builder to build * @return The built entity type */ private static <T extends Entity> EntityType<T> build(final String name, final EntityType.Builder<T> builder) { final ResourceLocation registryName = new ResourceLocation(Utils.MODID, name); final EntityType<T> entityType = builder .build(registryName.toString()); entityType.setRegistryName(registryName); return entityType; } } } And finally made a class implementing IRenderFactory: public class RenderFarmerEntity implements IRenderFactory<FarmerEntity> { @Override public EntityRenderer<? super FarmerEntity> createRenderFor(EntityRendererManager manager) { return Minecraft.getInstance().getRenderManager().getRenderer(RabbitEntity.class); } }
October 15, 20195 yr Author 2 hours ago, diesieben07 said: Thats not how that works. You have to actually write a renderer class. But I want to use Minecraft's player model lol. I don't fancy rewriting that.
October 15, 20195 yr 1 hour ago, SamB440 said: But I want to use Minecraft's player model lol. I don't fancy rewriting that. You can use the PlayerModel from Minecraft and even the BipedRenderer, but your are limited in what you can do with that. I did just test it, you can use RenderingRegistry.registerEntityRenderingHandler(FarmerEntity.class, (EntityRendererManager rendererManager) -> new BipedRenderer<>(rendererManager, new PlayerModel(modelSize, smallArms), shadowSize)); to register the BipedRenderer with the PlayerModel to your Entity.
October 16, 20195 yr Author 19 hours ago, Keitaro said: You can use the PlayerModel from Minecraft and even the BipedRenderer, but your are limited in what you can do with that. I did just test it, you can use RenderingRegistry.registerEntityRenderingHandler(FarmerEntity.class, (EntityRendererManager rendererManager) -> new BipedRenderer<>(rendererManager, new PlayerModel(modelSize, smallArms), shadowSize)); to register the BipedRenderer with the PlayerModel to your Entity. You are a saviour! Thank you so much.
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.