Would this code work, or am I on the wrong track

Started by Sir_sassypants on

Topic category: Help with MCreator software

Last seen on 05:50, 2. Jun 2023
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Would this code work, or am I on the wrong track
Thu, 01/07/2021 - 03:21 (edited)

I was messing around with some java (pretty new, meaning to learn), but in the code for structures I found this:

int i = ci + random.nextInt(16);
int k = ck + random.nextInt(16);
int j = world.getHeight(Heightmap.Type.OCEAN_FLOOR_WG, i, k);
j -= 1;

This looks like some code that finds the surface of the x z co-ordinates (i, k). Could I hook this up to a teleporting procedure that will teleport you somewhere else but on the surface?

If I can, what else do I need to add? There are a few variables that I might need to state and also some imports that I don't know the name of.

Edit: Maybe something like this:

int x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
int z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
int y = world.getHeight(Heightmap.Type.OCEAN_FLOOR_WG, x, z);
y -= 1;

// Maybe do something like this (obviously this bit isn't java)
// tp Event/Target entity to surface using (x) (z)
// if block there isn't air: x + 1, z + 1
// repeat

 

Edited by Sir_sassypants on Thu, 01/07/2021 - 03:21