-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
168 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/klaxon/klaxon/goverlays/navigator/PollutionButtonManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package klaxon.klaxon.goverlays.navigator; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
import com.gtnewhorizons.navigator.api.model.SupportedMods; | ||
import com.gtnewhorizons.navigator.api.model.buttons.ButtonManager; | ||
|
||
import klaxon.klaxon.goverlays.GregtorioOverlays; | ||
|
||
public class PollutionButtonManager extends ButtonManager { | ||
|
||
public static final PollutionButtonManager INSTANCE = new PollutionButtonManager(); | ||
|
||
@Override | ||
public ResourceLocation getIcon(SupportedMods mod, String theme) { | ||
return new ResourceLocation(GregtorioOverlays.MODID, "textures/icons/pollution.png"); | ||
} | ||
|
||
@Override | ||
public String getButtonText() { | ||
return "goverlays.button.pollution"; | ||
} | ||
} |
19 changes: 9 additions & 10 deletions
19
...pecting/model/PollutionChunkLocation.java → ...ays/navigator/PollutionChunkLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/klaxon/klaxon/goverlays/navigator/PollutionLayerManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package klaxon.klaxon.goverlays.navigator; | ||
|
||
import static com.gtnewhorizons.navigator.api.util.Util.coordBlockToChunk; | ||
import static klaxon.klaxon.goverlays.utils.ChunkPos.pack; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.client.Minecraft; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import com.gtnewhorizons.navigator.api.model.SupportedMods; | ||
import com.gtnewhorizons.navigator.api.model.layers.LayerManager; | ||
import com.gtnewhorizons.navigator.api.model.layers.LayerRenderer; | ||
import com.gtnewhorizons.navigator.api.model.locations.ILocationProvider; | ||
|
||
import it.unimi.dsi.fastutil.objects.ObjectArrayList; | ||
import klaxon.klaxon.goverlays.GregtorioOverlays; | ||
import klaxon.klaxon.goverlays.navigator.journeymap.PollutionLayerRenderer; | ||
|
||
public class PollutionLayerManager extends LayerManager { | ||
|
||
public static final PollutionLayerManager INSTANCE = new PollutionLayerManager(); | ||
|
||
public PollutionLayerManager() { | ||
super(PollutionButtonManager.INSTANCE); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected LayerRenderer addLayerRenderer(LayerManager manager, SupportedMods mod) { | ||
if (mod == SupportedMods.JourneyMap) return PollutionLayerRenderer.INSTANCE; | ||
return null; | ||
} | ||
|
||
/** | ||
* Generates list of location providers for rendering. | ||
* Takes in a rectangle bounded by minBlockX, maxBlockX, minBlockZ, and maxBlockZ. | ||
* This assumes the player is in the dimension being mapped. | ||
*/ | ||
@Override | ||
protected List<? extends ILocationProvider> generateVisibleElements(int minBlockX, int minBlockZ, int maxBlockX, | ||
int maxBlockZ) { | ||
|
||
// Convert to chunk coords | ||
final int minCX = coordBlockToChunk(minBlockX); | ||
final int minCZ = coordBlockToChunk(minBlockZ); | ||
final int maxCX = coordBlockToChunk(maxBlockX); | ||
final int maxCZ = coordBlockToChunk(maxBlockZ); | ||
|
||
// Get dimension | ||
final int dimId = Minecraft.getMinecraft().thePlayer.dimension; | ||
final var pollution = GregtorioOverlays.proxy.pollution.getCache(dimId); | ||
final var locations = new ObjectArrayList<PollutionChunkLocation>(); | ||
|
||
if (pollution.isEmpty()) return locations; | ||
|
||
// Go through chunks one at a time | ||
for (int cX = minCX; cX <= maxCX; ++cX) { | ||
for (int cZ = minCZ; cZ <= maxCZ; ++cZ) { | ||
// Get the pollution chunk and add it if it exists | ||
final long k = pack(cX, cZ); | ||
final int p = pollution.get(k); | ||
if (p > 0) { | ||
locations.add(new PollutionChunkLocation(dimId, k, p)); | ||
} | ||
} | ||
} | ||
|
||
return locations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/klaxon/klaxon/goverlays/navigator/journeymap/PollutionLayerRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package klaxon.klaxon.goverlays.navigator.journeymap; | ||
|
||
import java.util.List; | ||
|
||
import com.gtnewhorizons.navigator.api.journeymap.render.JMLayerRenderer; | ||
import com.gtnewhorizons.navigator.api.model.locations.ILocationProvider; | ||
import com.gtnewhorizons.navigator.api.model.steps.RenderStep; | ||
|
||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList; | ||
import klaxon.klaxon.goverlays.navigator.PollutionChunkLocation; | ||
import klaxon.klaxon.goverlays.navigator.PollutionLayerManager; | ||
|
||
public class PollutionLayerRenderer extends JMLayerRenderer { | ||
|
||
public static final PollutionLayerRenderer INSTANCE = new PollutionLayerRenderer(); | ||
|
||
public PollutionLayerRenderer() { | ||
super(PollutionLayerManager.INSTANCE); | ||
} | ||
|
||
@Override | ||
protected List<? extends RenderStep> generateRenderSteps(List<? extends ILocationProvider> visibleElements) { | ||
return visibleElements.stream() | ||
.map(element -> new PollutionDrawStep((PollutionChunkLocation) element)) | ||
.collect(ObjectImmutableList.toListWithExpectedSize(visibleElements.size())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.