Jump to content

Recommended Posts

Posted

Hi, I'm trying to create a spawning platform when players spawn in a custom dimension, so that they don't fall from a high area.

 

Travelling to and from the custom dimension and the overworld works, but the platform is being created in the overworld instead of the custom dimension.

 

The relevant code for the portal block (transfers player properly when right-clicked):

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float x2, float y2, float z2) {
  if (player instanceof EntityPlayerMP && !world.isRemote) { // Might be a bit redundant
    if (player.dimension == 0) {
      EntityPlayerMP serverPlayer = (EntityPlayerMP)player;
      serverPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(serverPlayer, CUSTOM_DIM_ID, new CustomTeleporter());
    }
    else {
      // ...
    }
  }
}

 

The CustomTeleporter class extends Teleporter, and I overrode 3 methods:

@Override
public void placeInPortal(Entity entity, double dX, double dY, double dZ, float f) {
  if (entity instanceof EntityPlayer) {
    makePortal(entity);
    placeInExistingPortal(entity, dX, dY, dZ, f);
  }
}

@Override
public boolean placeInExistingPortal(Entity entity, double dX, double dY, double dZ, float f) {
  if (entity instanceof EntityPlayerMP) {
    EntityPlayerMP player = (EntityPlayerMP)entity;
    player.setPosition(dX, dY, dZ);
    return true;
  }
  return false;
}

@Override
public boolean makePortal(Entity entity) {
  if (entity instanceof EntityPlayerMP) {
    EntityPlayerMP player = (EntityPlayerMP)entity;      
    
    System.out.println("making portal in dimension "+ player.dimension); // This prints out the ID of the custom dimension
      
    int pX = MathHelper.floor_double(player.posX);
    int pY = MathHelper.floor_double(player.posY);
    int pZ = MathHelper.floor_double(player.posZ);
   
    this.worldServerInstance.setBlock(pX, pY-1, pZ, Blocks.glowstone); // This sets the block in the overworld (or previous dimension) instead of the current one
    
    return true;
  }
  return false;
}

 

The Teleporter class seems to be the class that creates the nether portal when you travel to the nether, so I'm not sure why it's changing the blocks in the overworld instead of the custom dimension.

 

Is there any explanation of what the Teleporter class does, or any explanation of how custom dimensions work? (The tutorials that I've found show examples of code, but they don't really have much explanation.)

Posted

Hi

 

What WorldServer did you give Teleporter in your CustomTeleporter constructor?

serverPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(serverPlayer, CUSTOM_DIM_ID, new CustomTeleporter());

 

Each dimension has its own WorldServer.  So I'm guessing you've probably given your Teleporter the wrong one.

 

MinecraftServer.getServer().worldServerForDimension or DimensionManager.getWorld() might be of use.

 

-TGG

Posted

Ah, I gave the teleporter serverPlayer.getServerForPlayer(), but that's the WorldServer that the player was previously in.

 

I ended up adding the platform generation to the onBlockActivated() method after transferring the player to the new dimension:

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float x2, float y2, float z2) {
  if (player instanceof EntityPlayerMP && !world.isRemote) { // Might be a bit redundant
    if (player.dimension == 0) {
      EntityPlayerMP serverPlayer = (EntityPlayerMP)player;
      serverPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(serverPlayer, CUSTOM_DIM_ID, new CustomTeleporter());

      World customDimension = serverPlayer.getServerForPlayer(); // Is now the WorldServer for the custom dimension

      int pX = MathHelper.floor_double(serverPlayer.posX);
      int pY = MathHelper.floor_double(serverPlayer.posY);
      int pZ = MathHelper.floor_double(serverPlayer.posZ);

      customDimension.setBlock(pX, pY-1, pZ, Blocks.glowstone);
    }
    else {
      // ...
    }
  }
}

 

Which works.

 

Thanks!

Nephroid

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • USA User You can get a 40 Off Temu Coupon code using the code ["aci789589"]. This Temu 40 Off code is specifically for new and existing customers both and can be redeemed to receive a 40% discount on your purchase. Our exclusive Temu Coupon code offers a flat 40 Off your purchase, plus an additional 30% discount on top of that. You can slash prices by up to 70% as a new Temu customer using code ["aci789589"]. Existing users can enjoy 40% off their next haul with this code. But that’s not all! With our Temu Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our Temu codes provide extra discounts tailored just for you. Save up to 30% with these current Temu Coupons ["^"aci789589"^"] for June 2025. The latest Temu coupon codes at here. Free Temu codes 40 Off — ["aci789589"] Temu Coupon 40 Off — ["aci789589"] Temu Coupon 30% off — ["aci789589"] Temu Memorial Day Sale 75% off — ["aci789589"] Temu Coupon code today — ["aci789589"] Temu free gift code — ["^"aci789589"^"](Without inviting friends or family member) Temu Coupon code for Canada - 30% Off— ["aci789589"] Temu Coupon code Australia - 30% Off— ["aci789589"] Temu Coupon code New Zealand - 30% Off — ["aci789589"] Temu Coupon code Japan - 30% Off — ["aci789589"] Temu Coupon code Mexico - 30% Off — ["aci789589"] Temu Coupon code Chile - 30% Off — ["aci789589"] Temu Coupon code Peru - 30% Off — ["aci789589"] Temu Coupon code Colombia - 30% Off — ["aci789589"] Temu Coupon code Malaysia - 30% Off — ["aci789589"] Temu Coupon code Philippines - 30% Off — ["aci789589"] Temu Coupon code South Korea - 30% Off — ["aci789589"] Redeem Free Temu Coupon Code ["^"aci789589"^"] for first-time users Get a $100 discount on your Temu order with the promo code "aci789589". You can get a discount by clicking on the item to purchase and entering this Temu Coupon code 40 Off ["aci789589"]. Temu New User Coupon ["aci789589"]: Up To 75% OFF For First-Time Users Our Temu first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu. To maximize your savings, download the Temu app and apply our Temu new user coupon during checkout. Temu Coupon Codes For Existing Users ["aci789589"]: 40% Price Slash Have you been shopping on Temu for a while? Our Temu Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. Temu Coupon For 40 Off ["aci789589"]: Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu Coupon for 40 Off! Our amazing Temu 40 Off coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Temu Coupon Code For 40% Off ["aci789589"]: For Both New And Existing Customers Our incredible Temu Coupon code for 40% off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our 40% off code for Temu will give you an additional discount! Temu Coupon Bundle ["aci789589"]: Flat 40 Off + Up To 70% Discount Get ready for an unbelievable deal with our Temu Coupon bundle for 2025! Our Temu Coupon bundles will give you a flat $100 discount and an additional 40% off on top of it. Free Temu Coupons ["aci789589"]: Unlock Unlimited Savings! Get ready to unlock a world of savings with our free Temu Coupons! We’ve got you covered with a wide range of Temu Coupon code options that will help you maximize your shopping experience. 30% Off Temu Coupons, Promo Codes + 25% Cash Back ["aci789589"] Redeem Temu Coupon Code ["aci789589"] Temu Coupon 40 Off ["aci789589"] Temu Coupon 40 Off FOR EXISTING CUSTOMERS ["aci789589"] Temu Coupon 40 Off FIRST ORDER ["aci789589"] Temu Coupon 40 Off REDDIT ["aci789589"] Temu Coupon 40 Off FOR EXISTING CUSTOMERS REDDIT ["aci789589"] Temu 40 Off CODE ["aci789589"] Temu 100 OFF COUPON 2025 ["aci789589"] DOMINOS 100 RS OFF COUPON CODE ["aci789589"] WHAT IS A COUPON RATE ["aci789589"] Temu 40 Off FOR EXISTING CUSTOMERS ["aci789589"] Temu 40 Off FIRST ORDER ["aci789589"] Temu 40 Off FREE SHIPPING ["aci789589"]
    • Make a test with another Launcher like MultiMC or AT Launcher
    • Add crash-reports with sites like https://mclo.gs/ Looks like immersiverailroading and Optifine are conflicting - make a test without Optifine
    • And without create_more_automation?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.