diff --git a/src/main/java/twilightforest/TFMagicMapData.java b/src/main/java/twilightforest/TFMagicMapData.java index d81db470b8..94e7022742 100644 --- a/src/main/java/twilightforest/TFMagicMapData.java +++ b/src/main/java/twilightforest/TFMagicMapData.java @@ -7,12 +7,15 @@ import net.minecraft.world.World; import net.minecraft.world.storage.MapData; +import twilightforest.world.ChunkProviderTwilightForest; import twilightforest.world.TFWorldChunkManager; +import twilightforest.world.WorldProviderTwilightForest; public class TFMagicMapData extends MapData { private static final int FEATURE_DATA_BYTE = 18; public List featuresVisibleOnMap = new ArrayList<>(); + public static final byte CONQ_OFFSET = 80; public TFMagicMapData(String par1Str) { super(par1Str); @@ -51,7 +54,7 @@ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { /** * Adds a twilight forest feature to the map. */ - public void addFeatureToMap(TFFeature feature, int x, int z) { + public void addFeatureToMap(TFFeature feature, int x, int z, boolean conq) { byte relativeX = (byte) ((x - this.xCenter) >> this.scale); byte relativeZ = (byte) ((z - this.zCenter) >> this.scale); byte rangeX = 64; @@ -59,6 +62,7 @@ public void addFeatureToMap(TFFeature feature, int x, int z) { if (relativeX >= (-rangeX) && relativeZ >= (-rangeY) && relativeX <= rangeX && relativeZ <= rangeY) { byte markerIcon = (byte) feature.featureID; + markerIcon += conq ? CONQ_OFFSET : 0; byte mapX = (byte) (relativeX << 1); byte mapZ = (byte) (relativeZ << 1); byte mapRotation = 8; @@ -93,13 +97,18 @@ public void checkExistingFeatures(World world) { int worldZ = (coord.centerZ << this.scale - 1) + this.zCenter; if (world != null && world.getWorldChunkManager() instanceof TFWorldChunkManager tfManager) { - coord.iconSize = (byte) tfManager.getFeatureID(worldX, worldZ, world); - if (coord.iconSize == 0) { if (toRemove == null) { toRemove = new ArrayList<>(); } toRemove.add(coord); + } else if (coord.iconSize < CONQ_OFFSET) { + ChunkProviderTwilightForest chunkProvider = ((WorldProviderTwilightForest) world.provider) + .getChunkProvider(); + coord.iconSize = (byte) tfManager.getFeatureID(worldX, worldZ, world); + if (chunkProvider.isStructureConquered(worldX, 0, worldZ)) { + coord.iconSize += CONQ_OFFSET; + } } } } diff --git a/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java b/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java index 71c6cee857..77766ea4cd 100644 --- a/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java @@ -181,6 +181,7 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM par2TextureManager.bindTexture(twilightMapIcons); for (MapCoord mapCoord : magicMapData.featuresVisibleOnMap) { + int size = mapCoord.iconSize > 80 ? mapCoord.iconSize - 80 : mapCoord.iconSize; GL11.glPushMatrix(); GL11.glTranslatef( (float) var15 + (float) mapCoord.centerX / 2.0F + 64.0F, @@ -189,10 +190,10 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM GL11.glRotatef((float) (mapCoord.iconRotation * 360) / 16.0F, 0.0F, 0.0F, 1.0F); GL11.glScalef(4.0F, 4.0F, 3.0F); GL11.glTranslatef(-0.125F, 0.125F, 0.0F); - float var21 = (float) (mapCoord.iconSize % 8 + 0) / 8.0F; - float var23 = (float) (mapCoord.iconSize / 8 + 0) / 8.0F; - float var22 = (float) (mapCoord.iconSize % 8 + 1) / 8.0F; - float var24 = (float) (mapCoord.iconSize / 8 + 1) / 8.0F; + float var21 = (float) (size % 8 + 0) / 8.0F; + float var23 = (float) (size / 8 + 0) / 8.0F; + float var22 = (float) (size % 8 + 1) / 8.0F; + float var24 = (float) (size / 8 + 1) / 8.0F; tesselator.startDrawingQuads(); tesselator.addVertexWithUV(-1.0D, 1.0D, 0.0D, var21, var23); tesselator.addVertexWithUV(1.0D, 1.0D, 0.0D, var22, var23); @@ -202,11 +203,30 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM GL11.glPopMatrix(); } - // GL11.glPushMatrix(); - // GL11.glTranslatef(0.0F, 0.0F, -0.04F); - // GL11.glScalef(1.0F, 1.0F, 1.0F); - // this.fontRenderer.drawString(par3MapData.mapName, var15, var16, -16777216); - // GL11.glPopMatrix(); + par2TextureManager.bindTexture(vanillaMapIcons); + for (MapCoord mapCoord : magicMapData.featuresVisibleOnMap) { + if (mapCoord.iconSize > 80) { + GL11.glPushMatrix(); + GL11.glTranslatef( + (float) var15 + (float) mapCoord.centerX / 2.0F + 64.0F, + (float) var16 + (float) mapCoord.centerZ / 2.0F + 64.0F, + -0.02F); + GL11.glRotatef((float) (mapCoord.iconRotation * 360) / 16.0F, 0.0F, 0.0F, 1.0F); + GL11.glScalef(4.0F, 4.0F, 3.0F); + GL11.glTranslatef(-0.125F, 0.125F, 0.0F); + float var21 = (float) (4 % 4 + 0) / 4.0F; + float var23 = (float) (4 / 4 + 0) / 4.0F; + float var22 = (float) (4 % 4 + 1) / 4.0F; + float var24 = (float) (4 / 4 + 1) / 4.0F; + tesselator.startDrawingQuads(); + tesselator.addVertexWithUV(-1.0D, 0D, 0.0D, var21, var23); + tesselator.addVertexWithUV(0D, 0D, 0.0D, var22, var23); + tesselator.addVertexWithUV(0D, -1.0D, 0.0D, var22, var24); + tesselator.addVertexWithUV(-1.0D, -1.0D, 0.0D, var21, var24); + tesselator.draw(); + GL11.glPopMatrix(); + } + } } private void renderMapInFrame(ItemStack item, RenderManager renderManager, TFMagicMapData mapData) { diff --git a/src/main/java/twilightforest/item/ItemTFMagicMap.java b/src/main/java/twilightforest/item/ItemTFMagicMap.java index cf62227a85..eeec69c3d0 100644 --- a/src/main/java/twilightforest/item/ItemTFMagicMap.java +++ b/src/main/java/twilightforest/item/ItemTFMagicMap.java @@ -20,7 +20,9 @@ import twilightforest.TFMapPacketHandler; import twilightforest.TwilightForestMod; import twilightforest.biomes.TFBiomeBase; +import twilightforest.world.ChunkProviderTwilightForest; import twilightforest.world.TFWorldChunkManager; +import twilightforest.world.WorldProviderTwilightForest; public class ItemTFMagicMap extends ItemMap { @@ -65,6 +67,8 @@ public TFMagicMapData getMapData(ItemStack itemStack, World world) { public void updateMapData(World world, Entity entity, TFMagicMapData mapData) { if (world.provider.dimensionId == mapData.dimension && entity instanceof EntityPlayer) { + ChunkProviderTwilightForest chunkProvider = ((WorldProviderTwilightForest) world.provider) + .getChunkProvider(); short xSize = 128; short zSize = 128; int scaleFactor = 1 << mapData.scale; @@ -119,26 +123,16 @@ public void updateMapData(World world, Entity entity, TFMagicMapData mapData) { (zDraw2 + zStep2) >> 4, world), xDraw2, - zDraw2); + zDraw2, + chunkProvider + .isStructureConquered(xDraw2 + xStep2, 0, zDraw2 + zStep2)); } } - - // // mark features we find into the mapdata, provided they are within our draw area - // if (biomeID == TFBiomeBase.majorFeature.biomeID && zStep >= 0 && xOffset * - // xOffset + zOffset * zOffset < drawSize * drawSize) { - // par3MapData.addFeatureToMap(TFFeature.getNearestFeature((xDraw2 + xStep2) >> 4, - // (zDraw2 + zStep2) >> 4, par1World), xDraw2, zDraw2); - //// biomeFrequencies[biomeID] += 4096; // don't bother, now the icon will show - // } - - // // mark features we find into the mapdata, provided they are within our draw area - // if (biomeID == TFBiomeBase.minorFeature.biomeID) { - // biomeFrequencies[biomeID] += 4096; // don't bother, now the icon will show - // } } } - // figure out which color is the most prominent and make that one appear on the map + // figure out which color is the most prominent and make that one appear on the + // map byte biomeIDToShow = 0; int highestFrequency = 0;