-
Notifications
You must be signed in to change notification settings - Fork 78
Registerable WorldFormat api #1795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3fda32f
b7b0f7c
7e899da
2a58cab
84e3a01
23fe79e
5bed5f4
9e1c958
6a65f44
bf72013
aca6bb3
f7af0a2
73032d2
ea1dfd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,22 +19,16 @@ | |
|
|
||
| import javafx.application.Platform; | ||
| import javafx.geometry.Point2D; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.Scene; | ||
| import javafx.scene.canvas.Canvas; | ||
| import javafx.scene.canvas.GraphicsContext; | ||
| import javafx.scene.control.*; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.Dialog; | ||
| import javafx.scene.control.MenuItem; | ||
| import javafx.scene.image.Image; | ||
| import javafx.scene.image.ImageView; | ||
| import javafx.scene.input.KeyEvent; | ||
| import javafx.scene.input.MouseButton; | ||
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.input.ScrollEvent; | ||
| import javafx.scene.layout.Border; | ||
| import javafx.scene.layout.GridPane; | ||
| import javafx.stage.PopupWindow; | ||
| import se.llbit.chunky.map.MapBuffer; | ||
| import se.llbit.chunky.map.MapView; | ||
|
|
@@ -45,19 +39,17 @@ | |
| import se.llbit.chunky.renderer.scene.SceneManager; | ||
| import se.llbit.chunky.ui.controller.ChunkyFxController; | ||
| import se.llbit.chunky.ui.dialogs.SelectChunksInRadiusDialog; | ||
| import se.llbit.chunky.ui.elements.TextFieldLabelWrapper; | ||
| import se.llbit.chunky.world.*; | ||
| import se.llbit.chunky.world.Dimension; | ||
| import se.llbit.chunky.world.listeners.ChunkUpdateListener; | ||
| import se.llbit.chunky.world.region.MCRegion; | ||
| import se.llbit.chunky.world.region.Region; | ||
| import se.llbit.log.Log; | ||
| import se.llbit.math.*; | ||
|
|
||
| import java.awt.*; | ||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.Collection; | ||
| import java.util.Optional; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.ScheduledExecutorService; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
@@ -227,8 +219,8 @@ public ChunkMap(WorldMapLoader loader, ChunkyFxController controller, | |
| if (view.chunkScale >= 16) { | ||
| int minChunkX = region.x << 5; | ||
| int minChunkZ = region.z << 5; | ||
| for (int chunkX = minChunkX; chunkX < minChunkX + MCRegion.CHUNKS_X; chunkX++) { | ||
| for (int chunkZ = minChunkZ; chunkZ < minChunkZ + MCRegion.CHUNKS_Z; chunkZ++) { | ||
| for (int chunkX = minChunkX; chunkX < minChunkX + Region.CHUNKS_X; chunkX++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still assumes that all worlds are made out of regions with 32x32 chunks, doesn't it?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, currently I've got "virtual" regions in bedrock that just pass calls to the dimension. Any worldformat could use the virtual regions, and they aren't format specific (schematics/etc.). Maybe it's the simplest approach. It does mean every dimension needs to hold onto a bunch of virtual regions that don't do much, which is unfortunate |
||
| for (int chunkZ = minChunkZ; chunkZ < minChunkZ + Region.CHUNKS_Z; chunkZ++) { | ||
| mapBuffer.drawTile(mapLoader, new ChunkPosition(chunkX, chunkZ), chunkSelection); | ||
| } | ||
| } | ||
|
|
@@ -596,18 +588,16 @@ private void drawPlayers(GraphicsContext gc) { | |
| World world = mapLoader.getWorld(); | ||
| double blockScale = mapView.scale / 16.; | ||
| for (PlayerEntityData player : world.currentDimension().getPlayerPositions()) { | ||
| if (player.dimension.equals(world.currentDimension().getDimensionId())) { | ||
| int px = (int) QuickMath.floor(player.x * blockScale); | ||
| int py = (int) QuickMath.floor(player.y); | ||
| int pz = (int) QuickMath.floor(player.z * blockScale); | ||
| int ppx = px - (int) QuickMath.floor(mapView.x0 * mapView.scale); | ||
| int ppy = pz - (int) QuickMath.floor(mapView.z0 * mapView.scale); | ||
| int pw = (int) QuickMath.max(16, QuickMath.min(32, blockScale * 4)); | ||
| ppx = Math.min(mapView.width - pw, Math.max(0, ppx - pw / 2)); | ||
| ppy = Math.min(mapView.height - pw, Math.max(0, ppy - pw / 2)); | ||
|
|
||
| gc.drawImage(Icon.player.fxImage(), ppx, ppy, pw, pw); | ||
| } | ||
| int px = (int) QuickMath.floor(player.x * blockScale); | ||
| int py = (int) QuickMath.floor(player.y); | ||
| int pz = (int) QuickMath.floor(player.z * blockScale); | ||
| int ppx = px - (int) QuickMath.floor(mapView.x0 * mapView.scale); | ||
| int ppy = pz - (int) QuickMath.floor(mapView.z0 * mapView.scale); | ||
| int pw = (int) QuickMath.max(16, QuickMath.min(32, blockScale * 4)); | ||
| ppx = Math.min(mapView.width - pw, Math.max(0, ppx - pw / 2)); | ||
| ppy = Math.min(mapView.height - pw, Math.max(0, ppy - pw / 2)); | ||
|
|
||
| gc.drawImage(Icon.player.fxImage(), ppx, ppy, pw, pw); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the listeners, loading the same dimension again, and adding the listeners could be handled internally in e.g.
world.currentDimension().reload()orWorld.reloadCurrentDimension()WorldMapLoaderandWorldwere tightly coupled before, so this might be out-of-scope for this PR.