Posted June 19, 20232 yr I want to spawn a wither for one of my mods but I don't know how. @SubscribeEvent public void WitherMake(BreakEvent event) { if(!event.getPlayer().level.isClientSide) { WitherBoss wither = new WitherBoss(null, event.getPlayer().level); event.getPlayer().level.gameEvent(wither, GameEvent.ENTITY_PLACE, event.getPos()); } } This is what im trying now but it dose not work. How would I spawn a wither i this placeholder method? I looked at the spawn egg code but it is really confusing
June 19, 20232 yr Author if(!event.getPlayer().level.isClientSide) { WitherBoss wither = new WitherBoss(null, event.getPlayer().level); event.getPlayer().level.addFreshEntity(wither); } I tried this too and it also doesn't work
June 20, 20232 yr 12 hours ago, Duck478 said: I tried this too and it also doesn't work maybe it does? or it doesn't? why did you expect to see result without specifying the location of the new entity? addFreshEntity should work. alternatively, entityType.spawn() will work too.
June 21, 20232 yr Author On 6/20/2023 at 7:04 AM, MFMods said: why did you expect to see result without specifying the location of the new entity? I don't know how to do that, how do I specify the location? Can you give me an example of code to create any entity in minecraft and I can follow that
June 22, 20232 yr entityType.spawn() has a BlockPos parameter. you can't miss it. if you want to go with addFreshEntity, set the location (x,y,z) of the entity (there are set methods for it, i think i was setPosRaw). then, after that, call addFreshEntity.
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.