当前位置: 首页>>代码示例>>Java>>正文


Java ItemMap类代码示例

本文整理汇总了Java中net.minecraft.item.ItemMap的典型用法代码示例。如果您正苦于以下问题:Java ItemMap类的具体用法?Java ItemMap怎么用?Java ItemMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ItemMap类属于net.minecraft.item包,在下文中一共展示了ItemMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: downloadMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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);
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:21,代码来源:MapDownloader.java

示例2: updateHeldMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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

}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:32,代码来源:MapMod.java

示例3: updateHeldMapTexture

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:30,代码来源:MapMod.java

示例4: removeFrameFromMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:17,代码来源:EntityItemFrame.java

示例5: handleMaps

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:12,代码来源:NetHandlerPlayClient.java

示例6: handleMaps

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:11,代码来源:NetHandlerPlayClient.java

示例7: removeFrameFromMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:EntityItemFrame.java

示例8: func_190888_a

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:EntityVillager.java

示例9: removeFrameFromMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:EntityItemFrame.java

示例10: handleMaps

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:NetHandlerPlayClient.java

示例11: removeFrameFromMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:17,代码来源:EntityItemFrame.java

示例12: handleMaps

import net.minecraft.item.ItemMap; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:11,代码来源:NetHandlerPlayClient.java

示例13: removeFrameFromMap

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:14,代码来源:EntityItemFrame.java

示例14: func_110131_b

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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);
   }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:11,代码来源:EntityItemFrame.java

示例15: func_72494_a

import net.minecraft.item.ItemMap; //导入依赖的package包/类
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);
   }

}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:9,代码来源:NetClientHandler.java


注:本文中的net.minecraft.item.ItemMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。