net.minecraft.util.ResourceLocation.toString()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(228)

本文整理了Java中net.minecraft.util.ResourceLocation.toString方法的一些代码示例,展示了ResourceLocation.toString的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceLocation.toString方法的具体详情如下:
包路径:net.minecraft.util.ResourceLocation
类名称:ResourceLocation
方法名:toString

ResourceLocation.toString介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Override
public BaseItemStack getItemInHand(HandSide handSide) {
  ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND);
  return new BaseItemStack(ItemTypes.get(ForgeRegistries.ITEMS.getKey(is.getItem()).toString()));
}

代码示例来源:origin: EngineHub/WorldEdit

@EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent event) {
  if (this.platform != null) {
    logger.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't");
    WorldEdit.getInstance().getPlatformManager().unregister(platform);
  }
  this.platform = new ForgePlatform(this);
  WorldEdit.getInstance().getPlatformManager().register(platform);
  if (Loader.isModLoaded("sponge")) {
    this.provider = new ForgePermissionsProvider.SpongePermissionsProvider();
  } else {
    this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
  }
  for (ResourceLocation name : Block.REGISTRY.getKeys()) {
    String nameStr = name.toString();
    if (!BlockType.REGISTRY.keySet().contains(nameStr)) {
      BlockTypes.register(new BlockType(nameStr));
    }
  }
  for (ResourceLocation name : Item.REGISTRY.getKeys()) {
    String nameStr = name.toString();
    if (!ItemType.REGISTRY.keySet().contains(nameStr)) {
      ItemTypes.register(new ItemType(nameStr));
    }
  }
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
public BlockState getBlock(BlockVector3 position) {
  World world = getWorld();
  BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
  IBlockState mcState = world.getBlockState(pos);
  BlockType blockType = BlockType.REGISTRY.get(Block.REGISTRY.getNameForObject(mcState.getBlock()).toString());
  return blockType.getState(adaptProperties(blockType, mcState.getProperties()));
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

/** Manual registration of a tool model. You probably shouldn't be using this. */
public static ResourceLocation registerToolModel(Item item, final ResourceLocation location) {
 if(!location.getResourcePath().endsWith(ToolModelLoader.EXTENSION)) {
  TConstruct.log.error("The material-model " + location.toString() + " does not end with '"
             + ToolModelLoader.EXTENSION
             + "' and will therefore not be loaded by the custom model loader!");
 }
 return registerIt(item, location);
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

public static String getTextureIdentifier(Item item) {
  String identifier = item.getRegistryName().toString();
  // sanitize it (remove modid)
  if(identifier.contains(":")) {
   identifier = identifier.substring(identifier.lastIndexOf(':') + 1);
  }

  return "_" + identifier;
 }
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

/** Manual registration of a material model. You probably shouldn't be using this. */
static ResourceLocation registerMaterialModel(Item item, final ResourceLocation location) {
 if(!location.getResourcePath().endsWith(MaterialModelLoader.EXTENSION)) {
  TConstruct.log.error("The material-model " + location.toString() + " does not end with '"
             + MaterialModelLoader.EXTENSION
             + "' and will therefore not be loaded by the custom model loader!");
 }
 return registerIt(item, location);
}

代码示例来源:origin: Vazkii/Botania

private static List<ResourceLocation> allOfGroup(ResourceLocation group) {
    String jsonGroup = group.toString();

    return ForgeRegistries.RECIPES.getEntries().stream()
        .filter(e -> jsonGroup.equals(e.getValue().getGroup()))
        .map(Map.Entry::getKey)
        .collect(Collectors.toList());
  }
}

代码示例来源:origin: Vazkii/Botania

@Override
public void writeToPacketNBT(NBTTagCompound cmp) {
  super.writeToPacketNBT(cmp);
  cmp.setString(TAG_LOOT_TABLE, lootTable.toString());
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

public static ItemStack setTagForPart(ItemStack stack, Item toolPart) {
 NBTTagCompound tag = TagUtil.getTagSafe(stack);
 tag.setString(TAG_PARTTYPE, toolPart.getRegistryName().toString());
 stack.setTagCompound(tag);
 return stack;
}

代码示例来源:origin: Vazkii/Botania

private boolean setBlock(ItemStack stack, Block block, int meta) {
  ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString());
  ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
  return true;
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

@SubscribeEvent
 public void onLootTableLoad(LootTableLoadEvent event) {
  if(SPAGHETTI_LOCATIONS.contains(event.getName().toString())) {
   event.getTable().addPool(pool);
  }
 }
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

private static IBakedModel getTexturedModel(IBakedModel original, ResourceLocation location, Fluid fluid) {
 try {
  IModel model = ModelLoaderRegistry.getModel(location);
  IModel retextured = model.retexture(ImmutableMap.of("fluid", fluid.getStill().toString()));
  return retextured.bake(retextured.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
 }
 catch(Exception e) {
  e.printStackTrace();
  return original;
 }
}

代码示例来源:origin: Vazkii/Botania

private boolean setBlock(ItemStack stack, Block block, int meta) {
  if(Item.getItemFromBlock(block) != Items.AIR) {
    ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString());
    ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
    return true;
  }
  return false;
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

protected void addChiselVariation(Block block, int meta, String groupName) {
  if(block != null) {
   NBTTagCompound nbt = new NBTTagCompound();
   nbt.setString("group", groupName);
   nbt.setTag("stack", new ItemStack(block, 1, meta).writeToNBT(new NBTTagCompound()));
   nbt.setString("block", block.getRegistryName().toString());
   nbt.setInteger("meta", meta);
   FMLInterModComms.sendMessage(modid, "add_variation", nbt);
  }
 }
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

@Override
 public TextureAtlasSprite getTexture(ResourceLocation baseTexture, String location) {
  TextureAtlasSprite blockTexture = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(texturePath.toString());
  if(blockTexture == null) {
   blockTexture = TinkerTexture.loadManually(texturePath);
  }
  TextureColoredTexture sprite = new TextureColoredTexture(new ResourceLocation(blockTexture.getIconName()), baseTexture, location);
  sprite.stencil = false;
  return sprite;
 }
}

代码示例来源:origin: Vazkii/Botania

private boolean setBlock(ItemStack stack, Block block, int meta) {
  if(Item.getItemFromBlock(block) != Items.AIR && (getBlock(stack) == null || getBlockCount(stack) == 0)) {
    ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, block.getRegistryName().toString());
    ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
    return true;
  }
  return false;
}

代码示例来源:origin: Vazkii/Botania

@Override
public void writePacketNBT(NBTTagCompound cmp) {
  if(camoState != null) {
    cmp.setString(TAG_CAMO, Block.REGISTRY.getNameForObject(camoState.getBlock()).toString());
    cmp.setInteger(TAG_CAMO_META, camoState.getBlock().getMetaFromState(camoState));
  }
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

public static void putTexturedCuboid(BufferBuilder renderer, ResourceLocation location, double x1, double y1, double z1, double x2, double y2, double z2,
                   int color, int brightness) {
 boolean flowing = false;
 TextureAtlasSprite sprite = mc.getTextureMapBlocks().getTextureExtry(location.toString());
 putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, flowing);
 putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, flowing);
 putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, flowing);
 putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness, flowing);
 putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, flowing);
 putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness, flowing);
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

public static void renderTiledFluid(int x, int y, int width, int height, float depth, FluidStack fluidStack) {
 TextureAtlasSprite fluidSprite = mc.getTextureMapBlocks().getAtlasSprite(fluidStack.getFluid().getStill(fluidStack).toString());
 RenderUtil.setColorRGBA(fluidStack.getFluid().getColor(fluidStack));
 renderTiledTextureAtlas(x, y, width, height, depth, fluidSprite, fluidStack.getFluid().isGaseous(fluidStack));
}

代码示例来源:origin: Vazkii/Botania

public void renderIcon(int par1, int par2, ResourceLocation loc, int par4, int par5, int brightness) {
  TextureAtlasSprite par3Icon = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(loc.toString());
  Tessellator tessellator = Tessellator.getInstance();
  tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
  //if(brightness != -1)
  //tessellator.getBuffer().putBrightness4(brightness, brightness, brightness, brightness);
  tessellator.getBuffer().pos(par1 + 0, par2 + par5, 0).tex(par3Icon.getMinU(), par3Icon.getMaxV()).endVertex();
  tessellator.getBuffer().pos(par1 + par4, par2 + par5, 0).tex(par3Icon.getMaxU(), par3Icon.getMaxV()).endVertex();
  tessellator.getBuffer().pos(par1 + par4, par2 + 0, 0).tex(par3Icon.getMaxU(), par3Icon.getMinV()).endVertex();
  tessellator.getBuffer().pos(par1 + 0, par2 + 0, 0).tex(par3Icon.getMinU(), par3Icon.getMinV()).endVertex();
  tessellator.draw();
}

相关文章