Posted October 17, 20205 yr I have an @SubscribeEvent method that is called whenever the AttackEntityEvent is called. Whenever it is called, the game crashes. Here is the code: @SubscribeEvent public static void onAttack(AttackEntityEvent event) { /* if the entity who attacked was a player and was holding a t3 core then it is set to t4 */ PlayerEntity player = event.getPlayer(); int count = player.getHeldItemMainhand().getCount(); ServerWorld world = (ServerWorld) event.getEntity().world; if (event.getPlayer().getHeldItemMainhand().getMaxDamage() >= 15) { ItemStack stack = ItemRegistryHandler.T4_CORE.get().getDefaultInstance(); stack.setCount(1); player.setItemStackToSlot(EquipmentSlotType.MAINHAND, stack); ItemEntity item = new ItemEntity(EntityType.ITEM, world); stack.setCount(count - 1); item.setItem(stack); world.summonEntity(item); } }
October 17, 20205 yr 12 minutes ago, ZygZagGaming said: ServerWorld world = (ServerWorld) event.getEntity().world; I'm going to guess the crash report says 'cannot cast ServerWorld to ClientWorld' or something like that. You need to check if you are on the correct side. Otherwise, it's a blind cast and will throw errors.
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.