public void downloadMap(@Nullable String fileName, @Nullable Integer scaledRes) { if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) return; ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem(); MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world); if (fileName == null) fileName = heldMapData.mapName; ResourceLocation location = findResourceLocation(heldMapData.mapName); if (location == null) { Helper.printMessage("Failed to find ResourceLocation"); return; } DynamicTexture texture = (DynamicTexture)MC.getTextureManager().getTexture(location); BufferedImage image = dynamicToImage(texture); if (scaledRes != null) image = createResizedCopy(image, scaledRes, scaledRes, true); saveImage(fileName, image); }
/** * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and * update it's contents. */ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (!worldIn.isRemote) { MapData mapdata = this.getMapData(stack, worldIn); if (entityIn instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityIn; mapdata.updateVisiblePlayers(entityplayer, stack); } if (isSelected) { this.updateMapData(worldIn, entityIn, mapdata); } } }
/** * Called when item is crafted/smelted. Used only by maps so far. */ public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) { if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("map_is_scaling")) { MapData mapdata = Items.filled_map.getMapData(stack, worldIn); stack.setItemDamage(worldIn.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + stack.getMetadata()); mapdata1.scale = (byte)(mapdata.scale + 1); if (mapdata1.scale > 4) { mapdata1.scale = 4; } mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale); mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); worldIn.setItemData("map_" + stack.getMetadata(), mapdata1); } }
/** * Sets new MapData from the packet to given MapData param */ public void setMapdataTo(MapData mapdataIn) { mapdataIn.scale = this.mapScale; mapdataIn.mapDecorations.clear(); for (int i = 0; i < this.mapVisiblePlayersVec4b.length; ++i) { Vec4b vec4b = this.mapVisiblePlayersVec4b[i]; mapdataIn.mapDecorations.put("icon-" + i, vec4b); } for (int j = 0; j < this.mapMaxX; ++j) { for (int k = 0; k < this.mapMaxY; ++k) { mapdataIn.colors[this.mapMinX + j + (this.mapMinY + k) * 128] = this.mapDataBytes[j + k * this.mapMaxX]; } } }
/** * allows items to add custom lines of information to the mouseover description */ public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { MapData mapdata = this.getMapData(stack, playerIn.worldObj); if (advanced) { if (mapdata == null) { tooltip.add("Unknown map"); } else { tooltip.add("Scaling at 1:" + (1 << mapdata.scale)); tooltip.add("(Level " + mapdata.scale + "/" + 4 + ")"); } } }
/** * Sets new MapData from the packet to given MapData param */ public void setMapdataTo(MapData mapdataIn) { mapdataIn.scale = this.mapScale; mapdataIn.trackingPosition = this.trackingPosition; mapdataIn.mapDecorations.clear(); for (int i = 0; i < this.icons.length; ++i) { MapDecoration mapdecoration = this.icons[i]; mapdataIn.mapDecorations.put("icon-" + i, mapdecoration); } for (int j = 0; j < this.columns; ++j) { for (int k = 0; k < this.rows; ++k) { mapdataIn.colors[this.minX + j + (this.minZ + k) * 128] = this.mapDataBytes[j + k * this.columns]; } } }
/** * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and * update it's contents. */ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (!worldIn.isRemote) { MapData mapdata = this.getMapData(stack, worldIn); if (entityIn instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityIn; mapdata.updateVisiblePlayers(entityplayer, stack); } if (isSelected || entityIn instanceof EntityPlayer && ((EntityPlayer)entityIn).getHeldItemOffhand() == stack) { this.updateMapData(worldIn, entityIn, mapdata); } } }
protected static void scaleMap(ItemStack p_185063_0_, World p_185063_1_, int p_185063_2_) { MapData mapdata = Items.FILLED_MAP.getMapData(p_185063_0_, p_185063_1_); p_185063_0_.setItemDamage(p_185063_1_.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + p_185063_0_.getMetadata()); if (mapdata != null) { mapdata1.scale = (byte)MathHelper.clamp(mapdata.scale + p_185063_2_, 0, 4); mapdata1.trackingPosition = mapdata.trackingPosition; mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale); mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); p_185063_1_.setItemData("map_" + p_185063_0_.getMetadata(), mapdata1); } }
protected static void enableMapTracking(ItemStack p_185064_0_, World p_185064_1_) { MapData mapdata = Items.FILLED_MAP.getMapData(p_185064_0_, p_185064_1_); p_185064_0_.setItemDamage(p_185064_1_.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + p_185064_0_.getMetadata()); mapdata1.trackingPosition = true; if (mapdata != null) { mapdata1.xCenter = mapdata.xCenter; mapdata1.zCenter = mapdata.zCenter; mapdata1.scale = mapdata.scale; mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); p_185064_1_.setItemData("map_" + p_185064_0_.getMetadata(), mapdata1); } }
/** * allows items to add custom lines of information to the mouseover description */ public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { MapData mapdata = this.getMapData(stack, playerIn.world); if (advanced) { if (mapdata == null) { tooltip.add("Unknown map"); } else { tooltip.add("Scaling at 1:" + (1 << mapdata.scale)); tooltip.add("(Level " + mapdata.scale + "/" + 4 + ")"); } } }
private void renderMapFirstPerson(ItemStack stack) { GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); GlStateManager.scale(0.38F, 0.38F, 0.38F); GlStateManager.disableLighting(); this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); GlStateManager.translate(-0.5F, -0.5F, 0.0F); GlStateManager.scale(0.0078125F, 0.0078125F, 0.0078125F); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos(-7.0D, 135.0D, 0.0D).tex(0.0D, 1.0D).endVertex(); vertexbuffer.pos(135.0D, 135.0D, 0.0D).tex(1.0D, 1.0D).endVertex(); vertexbuffer.pos(135.0D, -7.0D, 0.0D).tex(1.0D, 0.0D).endVertex(); vertexbuffer.pos(-7.0D, -7.0D, 0.0D).tex(0.0D, 0.0D).endVertex(); tessellator.draw(); MapData mapdata = Items.FILLED_MAP.getMapData(stack, this.mc.world); if (mapdata != null) { this.mc.entityRenderer.getMapItemRenderer().renderMap(mapdata, false); } GlStateManager.enableLighting(); }
/** * Sets new MapData from the packet to given MapData param */ @SideOnly(Side.CLIENT) public void setMapdataTo(MapData mapdataIn) { mapdataIn.scale = this.mapScale; mapdataIn.trackingPosition = this.trackingPosition; mapdataIn.mapDecorations.clear(); for (int i = 0; i < this.icons.length; ++i) { Vec4b vec4b = this.icons[i]; mapdataIn.mapDecorations.put("icon-" + i, vec4b); } for (int j = 0; j < this.columns; ++j) { for (int k = 0; k < this.rows; ++k) { mapdataIn.colors[this.minX + j + (this.minZ + k) * 128] = this.mapDataBytes[j + k * this.columns]; } } }
/** * allows items to add custom lines of information to the mouseover description */ @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { MapData mapdata = this.getMapData(stack, playerIn.worldObj); if (advanced) { if (mapdata == null) { tooltip.add("Unknown map"); } else { tooltip.add("Scaling at 1:" + (1 << mapdata.scale)); tooltip.add("(Level " + mapdata.scale + "/" + 4 + ")"); } } }
private void renderMapFirstPerson(ItemStack stack) { GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); GlStateManager.scale(0.38F, 0.38F, 0.38F); GlStateManager.disableLighting(); this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); GlStateManager.translate(-0.5F, -0.5F, 0.0F); GlStateManager.scale(0.0078125F, 0.0078125F, 0.0078125F); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos(-7.0D, 135.0D, 0.0D).tex(0.0D, 1.0D).endVertex(); vertexbuffer.pos(135.0D, 135.0D, 0.0D).tex(1.0D, 1.0D).endVertex(); vertexbuffer.pos(135.0D, -7.0D, 0.0D).tex(1.0D, 0.0D).endVertex(); vertexbuffer.pos(-7.0D, -7.0D, 0.0D).tex(0.0D, 0.0D).endVertex(); tessellator.draw(); MapData mapdata = Items.FILLED_MAP.getMapData(stack, this.mc.theWorld); if (mapdata != null) { this.mc.entityRenderer.getMapItemRenderer().renderMap(mapdata, false); } GlStateManager.enableLighting(); }
@SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean showAdvancedInfo) { if (!this.isMapReady(stack)) { info.add("It's currently blank. Use the"); info.add("map to start inscribing it."); } else { MapData mapData = this.getMapData(stack, player.worldObj); info.add("A map of the land."); //info.add("Center: x" + mapData.xCenter + " z" + mapData.zCenter); info.add("Dimension: " + mapData.dimension); if (showAdvancedInfo) { info.add("Scaling at 1:" + (1 << mapData.scale)); info.add("(Level " + mapData.scale + "/" + 4 + ")"); } } }
@Override public void render(MapView map, MapCanvas canvas, Player player) { // Map for (int x = 0; x < 128; ++x) { for (int y = 0; y < 128; ++y) { canvas.setPixel(x, y, worldMap.colors[y * 128 + x]); } } // Cursors MapCursorCollection cursors = canvas.getCursors(); while (cursors.size() > 0) { cursors.removeCursor(cursors.getCursor(0)); } for (Map.Entry<UUID, MapData.MapCoord> key : worldMap.playersVisibleOnMap.entrySet()) { // If this cursor is for a player check visibility with vanish system Player other = Bukkit.getPlayer(key.getKey()); if (other != null && !player.canSee(other)) { continue; } MapData.MapCoord decoration = key.getValue(); cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize); } }
/** * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and * update it's contents. */ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { if (!par2World.isClient) { MapData var6 = this.getMapData(par1ItemStack, par2World); if (par3Entity instanceof EntityPlayer) { EntityPlayer var7 = (EntityPlayer)par3Entity; var6.updateVisiblePlayers(var7, par1ItemStack); } if (par5) { this.updateMapData(par2World, par3Entity, var6); } } }
/** * Called when item is crafted/smelted. Used only by maps so far. */ public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().getBoolean("map_is_scaling")) { MapData var4 = Items.filled_map.getMapData(par1ItemStack, par2World); par1ItemStack.setItemDamage(par2World.getUniqueDataId("map")); MapData var5 = new MapData("map_" + par1ItemStack.getItemDamage()); var5.scale = (byte)(var4.scale + 1); if (var5.scale > 4) { var5.scale = 4; } var5.xCenter = var4.xCenter; var5.zCenter = var4.zCenter; var5.dimension = var4.dimension; var5.markDirty(); par2World.setItemData("map_" + par1ItemStack.getItemDamage(), var5); } }
/** * allows items to add custom lines of information to the mouseover description */ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { MapData var5 = this.getMapData(par1ItemStack, par2EntityPlayer.worldObj); if (par4) { if (var5 == null) { par3List.add("Unknown map"); } else { par3List.add("Scaling at 1:" + (1 << var5.scale)); par3List.add("(Level " + var5.scale + "/" + 4 + ")"); } } }
public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { if (!p_77663_2_.isRemote) { MapData mapdata = this.getMapData(p_77663_1_, p_77663_2_); if (p_77663_3_ instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)p_77663_3_; mapdata.updateVisiblePlayers(entityplayer, p_77663_1_); } if (p_77663_5_) { this.updateMapData(p_77663_2_, p_77663_3_, mapdata); } } }
public void onCreated(ItemStack p_77622_1_, World p_77622_2_, EntityPlayer p_77622_3_) { if (p_77622_1_.hasTagCompound() && p_77622_1_.getTagCompound().getBoolean("map_is_scaling")) { MapData mapdata = Items.filled_map.getMapData(p_77622_1_, p_77622_2_); p_77622_1_.setItemDamage(p_77622_2_.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + p_77622_1_.getItemDamage()); mapdata1.scale = (byte)(mapdata.scale + 1); if (mapdata1.scale > 4) { mapdata1.scale = 4; } mapdata1.xCenter = mapdata.xCenter; mapdata1.zCenter = mapdata.zCenter; mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); p_77622_2_.setItemData("map_" + p_77622_1_.getItemDamage(), mapdata1); // CraftBukkit start MapInitializeEvent event = new MapInitializeEvent(mapdata1.mapView); Bukkit.getServer().getPluginManager().callEvent(event); // CraftBukkit end } }
@SideOnly(Side.CLIENT) public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { MapData mapdata = this.getMapData(p_77624_1_, p_77624_2_.worldObj); if (p_77624_4_) { if (mapdata == null) { p_77624_3_.add("Unknown map"); } else { p_77624_3_.add("Scaling at 1:" + (1 << mapdata.scale)); p_77624_3_.add("(Level " + mapdata.scale + "/" + 4 + ")"); } } }
public void onCreated(ItemStack p_77622_1_, World p_77622_2_, EntityPlayer p_77622_3_) { if (p_77622_1_.hasTagCompound() && p_77622_1_.getTagCompound().getBoolean("map_is_scaling")) { MapData mapdata = Items.filled_map.getMapData(p_77622_1_, p_77622_2_); p_77622_1_.setItemDamage(p_77622_2_.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + p_77622_1_.getItemDamage()); mapdata1.scale = (byte)(mapdata.scale + 1); if (mapdata1.scale > 4) { mapdata1.scale = 4; } mapdata1.xCenter = mapdata.xCenter; mapdata1.zCenter = mapdata.zCenter; mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); p_77622_2_.setItemData("map_" + p_77622_1_.getItemDamage(), mapdata1); } }
public void func_77622_d(ItemStack p_77622_1_, World p_77622_2_, EntityPlayer p_77622_3_) { if(p_77622_1_.func_77942_o() && p_77622_1_.func_77978_p().func_74767_n("map_is_scaling")) { MapData var4 = Item.field_77744_bd.func_77873_a(p_77622_1_, p_77622_2_); p_77622_1_.func_77964_b(p_77622_2_.func_72841_b("map")); MapData var5 = new MapData("map_" + p_77622_1_.func_77960_j()); var5.field_76197_d = (byte)(var4.field_76197_d + 1); if(var5.field_76197_d > 4) { var5.field_76197_d = 4; } var5.field_76201_a = var4.field_76201_a; var5.field_76199_b = var4.field_76199_b; var5.field_76200_c = var4.field_76200_c; var5.func_76185_a(); p_77622_2_.func_72823_a("map_" + p_77622_1_.func_77960_j(), var5); } }