Improve Energy Teleporter Y
All checks were successful
EnergonRelics/pipeline/head This commit looks good
All checks were successful
EnergonRelics/pipeline/head This commit looks good
This commit is contained in:
parent
f6e94963d2
commit
f4bb60b819
@ -13,7 +13,6 @@ import net.minecraft.server.world.ServerWorld;
|
|||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
import net.minecraft.world.Heightmap;
|
import net.minecraft.world.Heightmap;
|
||||||
@ -54,30 +53,13 @@ class EnergyTeleporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int convertY(int y, int oldHeight, int newHeight) {
|
private static int convertY(int y, int oldHeight, int newHeight) {
|
||||||
|
int newY = (int) (((float) y / (float) oldHeight) * (float) newHeight);
|
||||||
|
|
||||||
int bottomPadding = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
|
int bottomPadding = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
|
||||||
int topPadding = bottomPadding + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP;
|
int topPadding = bottomPadding + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP;
|
||||||
|
newY = Math.max(bottomPadding, Math.min(topPadding, newY));
|
||||||
|
|
||||||
int oldMax = oldHeight - topPadding;
|
return newY;
|
||||||
|
|
||||||
y = MathHelper.clamp(y, bottomPadding, oldMax);
|
|
||||||
|
|
||||||
int totalPadding = bottomPadding + topPadding;
|
|
||||||
int oldPaddedHeight = oldHeight - totalPadding;
|
|
||||||
int newPaddedHeight = newHeight - totalPadding;
|
|
||||||
|
|
||||||
float multiplier = (float) newPaddedHeight / (float) oldPaddedHeight;
|
|
||||||
|
|
||||||
y = y - bottomPadding;
|
|
||||||
|
|
||||||
y = (int) (y * multiplier);
|
|
||||||
|
|
||||||
int newMax = newHeight - topPadding;
|
|
||||||
|
|
||||||
y = y + bottomPadding;
|
|
||||||
|
|
||||||
y = MathHelper.clamp(y, bottomPadding, newMax);
|
|
||||||
|
|
||||||
return y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void teleportWithMultiplier(ServerWorld world, Entity entity, BlockPos center, Vec3d offset, RegistryKey<World> toKey, double multiplier) {
|
private static void teleportWithMultiplier(ServerWorld world, Entity entity, BlockPos center, Vec3d offset, RegistryKey<World> toKey, double multiplier) {
|
||||||
|
Reference in New Issue
Block a user