Posted August 6, 20241 yr how could i tp the player to an unloaded dimension right after the clearInventory @Override public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) { player.playSound(Sounds.CORRUPT_CRYSTAL_USE.get(), 1f, 1f); player.getCooldowns().addCooldown(this, 100); player.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 150, 355)); player.getInventory().clearContent(); return super.use(level, player, usedHand); }
August 13, 20241 yr You need to create a class implementing the ITeleporter Interface, and override its placeEntity() method in which you'll have the logic to safely place the teleported entity in the inbound dimension. Whenever you need to use said class just create a new instance of it and call the changeDimension method of the entity you want to teleport with the ServerLevel instance of the target dimension and the teleporter class: MinecraftServer mcServer = level.getServer(); ServerLevel targetDimension = mcServer.getLevel(TARGETDIMENSIONLEVELKEY); if (targetDimension != null) { CustomITeleporter teleporter = new CustomITeleporter(. . .); entity.changeDimension(targetDimension, teleporter); } EDIT: As far as i can tell this works on 1.19+. You didn't specify your version so I defaulted to the most recent one(s) Edited August 13, 20241 yr by chxr Clarification
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.