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); }
private void updateHeldMap(String url) { if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) return; BufferedImage image = getImageFromUrl(url); if (image == null) { Helper.printMessage("Failed to download image"); return; } image = createResizedCopy(image, 128, 128, false); int[][] imageColors = imageToArray(image); // convert image into a 2d array of rgba integers byte[] convertedMapColors = new byte[128 * 128]; // create a 1d array 128^2 in length that will be used to hold the final map data int count = 0; for (int x = 0; x < 128; x++) { // iterate vertically for (int y = 0; y < 128; y++) { // iterate through row of pixels imageColors[y][x] = closest_color_RGB(imageColors[y][x]); // each color in the image data now a color in COLOR_LIST that is the closest match convertedMapColors[count] = (byte) imageColors[y][x]; // convert the 2d array into a 1d array count++; } // normally would do [x][y] but that appears to cause a rotation problem that is fixed by doing [j][i] } ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem(); MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world); heldMapData.colors = convertedMapColors; // set the colors of the map to the colors of the image }
private void updateHeldMapTexture(String url) { if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) return; MC.addScheduledTask(() -> { // allows DynamicTexture to work ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem(); MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world); try { BufferedImage image = getImageFromUrl(url); DynamicTexture dynamicTexture = new DynamicTexture(image); dynamicTexture.loadTexture(MC.getResourceManager()); Map<ResourceLocation, ITextureObject> mapTextureObjects = FastReflection.Fields.TextureManager_mapTextureObjects.get(MC.getTextureManager()); ResourceLocation textureLocation = mapTextureObjects.keySet() .stream() .filter(k -> k.getResourcePath().contains(heldMapData.mapName)) .findFirst() .orElse(null); mapTextureObjects.put(textureLocation, dynamicTexture); // overwrite old texture with our custom one } catch (Exception e) { e.printStackTrace(); } }); }
/** * Removes the dot representing this frame's position from the map when the item frame is broken. */ private void removeFrameFromMap(ItemStack p_110131_1_) { if (p_110131_1_ != null) { if (p_110131_1_.getItem() == Items.filled_map) { MapData mapdata = ((ItemMap)p_110131_1_.getItem()).getMapData(p_110131_1_, this.worldObj); mapdata.mapDecorations.remove("frame-" + this.getEntityId()); } p_110131_1_.setItemFrame((EntityItemFrame)null); } }
/** * Updates the worlds MapStorage with the specified MapData for the specified map-identifier and invokes a * MapItemRenderer for it */ public void handleMaps(S34PacketMaps packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); MapData mapdata = ItemMap.loadMapData(packetIn.getMapId(), this.gameController.theWorld); packetIn.setMapdataTo(mapdata); this.gameController.entityRenderer.getMapItemRenderer().updateMapTexture(mapdata); }
/** * Updates the worlds MapStorage with the specified MapData for the specified * map-identifier and invokes a MapItemRenderer for it */ public void handleMaps(S34PacketMaps packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); MapData mapdata = ItemMap.loadMapData(packetIn.getMapId(), this.gameController.theWorld); packetIn.setMapdataTo(mapdata); this.gameController.entityRenderer.getMapItemRenderer().updateMapTexture(mapdata); }
/** * Removes the dot representing this frame's position from the map when the item frame is broken. */ private void removeFrameFromMap(ItemStack stack) { if (!stack.func_190926_b()) { if (stack.getItem() == Items.FILLED_MAP) { MapData mapdata = ((ItemMap)stack.getItem()).getMapData(stack, this.world); mapdata.mapDecorations.remove("frame-" + this.getEntityId()); } stack.setItemFrame((EntityItemFrame)null); } }
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_) { int i = this.field_190889_a.getPrice(p_190888_3_); World world = p_190888_1_.func_190670_t_(); BlockPos blockpos = world.func_190528_a(this.field_190890_b, p_190888_1_.func_190671_u_(), true); if (blockpos != null) { ItemStack itemstack = ItemMap.func_190906_a(world, (double)blockpos.getX(), (double)blockpos.getZ(), (byte)2, true, true); ItemMap.func_190905_a(world, itemstack); MapData.func_191094_a(itemstack, blockpos, "+", this.field_190891_c); itemstack.func_190924_f("filled_map." + this.field_190890_b.toLowerCase(Locale.ROOT)); p_190888_2_.add(new MerchantRecipe(new ItemStack(Items.EMERALD, i), new ItemStack(Items.COMPASS), itemstack)); } }
/** * Removes the dot representing this frame's position from the map when the item frame is broken. */ private void removeFrameFromMap(ItemStack stack) { if (stack != null) { if (stack.getItem() instanceof net.minecraft.item.ItemMap) { MapData mapdata = ((ItemMap)stack.getItem()).getMapData(stack, this.worldObj); mapdata.mapDecorations.remove("frame-" + this.getEntityId()); } stack.setItemFrame((EntityItemFrame)null); } }
/** * Updates the worlds MapStorage with the specified MapData for the specified map-identifier and invokes a * MapItemRenderer for it */ public void handleMaps(SPacketMaps packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); MapData mapdata = ItemMap.loadMapData(packetIn.getMapId(), this.gameController.theWorld); packetIn.setMapdataTo(mapdata); this.gameController.entityRenderer.getMapItemRenderer().updateMapTexture(mapdata); }
/** * Removes the dot representing this frame's position from the map when the item frame is broken. */ private void removeFrameFromMap(ItemStack par1ItemStack) { if (par1ItemStack != null) { if (par1ItemStack.getItem() == Items.filled_map) { MapData var2 = ((ItemMap)par1ItemStack.getItem()).getMapData(par1ItemStack, this.worldObj); var2.playersVisibleOnMap.remove("frame-" + this.getEntityId()); } par1ItemStack.setItemFrame((EntityItemFrame)null); } }
/** * Updates the worlds MapStorage with the specified MapData for the specified map-identifier and invokes a * MapItemRenderer for it */ public void handleMaps(S34PacketMaps p_147264_1_) { MapData var2 = ItemMap.func_150912_a(p_147264_1_.func_149188_c(), this.gameController.theWorld); var2.updateMPMapData(p_147264_1_.func_149187_d()); this.gameController.entityRenderer.getMapItemRenderer().func_148246_a(var2); }
private void removeFrameFromMap(ItemStack p_110131_1_) { if (p_110131_1_ != null) { if (p_110131_1_.getItem() == Items.filled_map) { MapData mapdata = ((ItemMap)p_110131_1_.getItem()).getMapData(p_110131_1_, this.worldObj); mapdata.playersVisibleOnMap.remove("frame-" + this.getEntityId()); } p_110131_1_.setItemFrame((EntityItemFrame)null); } }
private void func_110131_b(ItemStack p_110131_1_) { if(p_110131_1_ != null) { if(p_110131_1_.field_77993_c == Item.field_77744_bd.field_77779_bT) { MapData var2 = ((ItemMap)p_110131_1_.func_77973_b()).func_77873_a(p_110131_1_, this.field_70170_p); var2.field_76203_h.remove("frame-" + this.field_70157_k); } p_110131_1_.func_82842_a((EntityItemFrame)null); } }
public void func_72494_a(Packet131MapData p_72494_1_) { if(p_72494_1_.field_73438_a == Item.field_77744_bd.field_77779_bT) { ItemMap.func_77874_a(p_72494_1_.field_73436_b, this.field_72563_h.field_71441_e).func_76192_a(p_72494_1_.field_73437_c); } else { this.field_72563_h.func_98033_al().func_98236_b("Unknown itemid: " + p_72494_1_.field_73436_b); } }
/** * Removes the dot representing this frame's position from the map when the item frame is broken. */ private void removeFrameFromMap(ItemStack par1ItemStack) { if (par1ItemStack != null) { if (par1ItemStack.itemID == Item.map.itemID) { MapData mapdata = ((ItemMap)par1ItemStack.getItem()).getMapData(par1ItemStack, this.worldObj); mapdata.playersVisibleOnMap.remove("frame-" + this.entityId); } par1ItemStack.setItemFrame((EntityItemFrame)null); } }
public void fmlPacket131Callback(Packet131MapData par1Packet131MapData) { if (par1Packet131MapData.itemID == Item.map.itemID) { ItemMap.getMPMapData(par1Packet131MapData.uniqueID, this.mc.theWorld).updateMPMapData(par1Packet131MapData.itemData); } else { this.mc.getLogAgent().logWarning("Unknown itemid: " + par1Packet131MapData.uniqueID); } }
/** * Renders the active item in the player's hand when in first person mode. Args: partialTickTime */ public void renderItemInFirstPerson(float partialTicks) { float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks); EntityPlayerSP entityplayersp = this.mc.thePlayer; float f1 = entityplayersp.getSwingProgress(partialTicks); float f2 = entityplayersp.prevRotationPitch + (entityplayersp.rotationPitch - entityplayersp.prevRotationPitch) * partialTicks; float f3 = entityplayersp.prevRotationYaw + (entityplayersp.rotationYaw - entityplayersp.prevRotationYaw) * partialTicks; this.func_178101_a(f2, f3); this.func_178109_a(entityplayersp); this.func_178110_a(entityplayersp, partialTicks); GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); if (this.itemToRender != null) { if (this.itemToRender.getItem() instanceof ItemMap) { this.renderItemMap(entityplayersp, f2, f, f1); } else if (entityplayersp.getItemInUseCount() > 0) { EnumAction enumaction = this.itemToRender.getItemUseAction(); switch (ItemRenderer.ItemRenderer$1.field_178094_a[enumaction.ordinal()]) { case 1: this.transformFirstPersonItem(f, 0.0F); break; case 2: case 3: this.func_178104_a(entityplayersp, partialTicks); this.transformFirstPersonItem(f, 0.0F); break; case 4: this.transformFirstPersonItem(f, 0.0F); this.func_178103_d(); break; case 5: this.transformFirstPersonItem(f, 0.0F); this.func_178098_a(partialTicks, entityplayersp); } } else { this.func_178105_d(f1); this.transformFirstPersonItem(f, f1); } this.renderItem(entityplayersp, this.itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON); } else if (!entityplayersp.isInvisible()) { this.func_178095_a(entityplayersp, f, f1); } GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); }
private void renderItem(EntityItemFrame itemFrame) { ItemStack itemstack = itemFrame.getDisplayedItem(); if (!itemstack.func_190926_b()) { if (!Config.zoomMode) { Entity entity = this.mc.player; double d0 = itemFrame.getDistanceSq(entity.posX, entity.posY, entity.posZ); if (d0 > 4096.0D) { return; } } EntityItem entityitem = new EntityItem(itemFrame.world, 0.0D, 0.0D, 0.0D, itemstack); Item item = entityitem.getEntityItem().getItem(); entityitem.getEntityItem().func_190920_e(1); entityitem.hoverStart = 0.0F; GlStateManager.pushMatrix(); GlStateManager.disableLighting(); int i = itemFrame.getRotation(); if (item instanceof ItemMap) { i = i % 4 * 2; } GlStateManager.rotate((float)i * 360.0F / 8.0F, 0.0F, 0.0F, 1.0F); if (!Reflector.postForgeBusEvent(Reflector.RenderItemInFrameEvent_Constructor, new Object[] {itemFrame, this})) { if (item instanceof ItemMap) { this.renderManager.renderEngine.bindTexture(MAP_BACKGROUND_TEXTURES); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); float f = 0.0078125F; GlStateManager.scale(0.0078125F, 0.0078125F, 0.0078125F); GlStateManager.translate(-64.0F, -64.0F, 0.0F); MapData mapdata = Items.FILLED_MAP.getMapData(entityitem.getEntityItem(), itemFrame.world); GlStateManager.translate(0.0F, 0.0F, -1.0F); if (mapdata != null) { this.mc.entityRenderer.getMapItemRenderer().renderMap(mapdata, true); } } else { GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.pushAttrib(); RenderHelper.enableStandardItemLighting(); this.itemRenderer.renderItem(entityitem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); RenderHelper.disableStandardItemLighting(); GlStateManager.popAttrib(); } } GlStateManager.enableLighting(); GlStateManager.popMatrix(); } if (Config.isShaders()) { ShadersTex.updatingTex = null; } }
public void handleMaps(S34PacketMaps p_147264_1_) { MapData mapdata = ItemMap.func_150912_a(p_147264_1_.func_149188_c(), this.gameController.theWorld); mapdata.updateMPMapData(p_147264_1_.func_149187_d()); this.gameController.entityRenderer.getMapItemRenderer().func_148246_a(mapdata); }