JustinB0406 Posted March 13, 2021 Posted March 13, 2021 (edited) I am trying to have a vanilla entity spawn at my position after I finish drinking a bucket of milk. However, the entity does not spawn when I finish drinking the bucket. public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) { if (entityLiving instanceof ServerPlayerEntity) { ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)entityLiving; CriteriaTriggers.CONSUME_ITEM.trigger(serverplayerentity, stack); serverplayerentity.addStat(Stats.ITEM_USED.get(this)); } if (entityLiving instanceof PlayerEntity) { stack.shrink(1); PlayerEntity p = (PlayerEntity)entityLiving; p.getFoodStats().addStats(4, 0.8f); } //Spawn entity if (worldIn.isRemote()) { Entity e = EntityType.create(12, worldIn); e.setLocationAndAngles(entityLiving.getPosX(), entityLiving.getPosY(), entityLiving.getPosZ(), 0, 0); worldIn.addEntity(e); } return stack.isEmpty() ? new ItemStack(Items.BUCKET) : stack; } I am new at modding, so can anyone help me fix this? Edited March 13, 2021 by JustinB0406 Quote
JustinB0406 Posted March 13, 2021 Author Posted March 13, 2021 (edited) 2 minutes ago, diesieben07 said: You need to spawn entities on the server only. Currently you are spawning it on the client only. And how do I spawn it on the server? I apologize if what I'm asking is obvious, but I just started modding today. Edited March 13, 2021 by JustinB0406 Quote
JustinB0406 Posted March 13, 2021 Author Posted March 13, 2021 1 minute ago, diesieben07 said: This checks that you are on the client. So should I delete that if statement? Quote
JustinB0406 Posted March 13, 2021 Author Posted March 13, 2021 2 minutes ago, diesieben07 said: That would make it run on both client and server. So then I should use if (!worldIn.isRemote()) instead. then? Quote
JustinB0406 Posted March 13, 2021 Author Posted March 13, 2021 40 minutes ago, diesieben07 said: Yes. That worked, thanks. 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.