net.minecraft.util.ResourceLocation类的使用及代码示例

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

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

ResourceLocation介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public boolean accepts( ResourceLocation modelLocation )
{
  String modelPath = modelLocation.getResourcePath();
  if( modelLocation.getResourcePath().startsWith( "models/" ) )
  {
    modelPath = modelPath.substring( "models/".length() );
  }
  try( InputStreamReader io = new InputStreamReader( Minecraft.getMinecraft()
      .getResourceManager()
      .getResource( new ResourceLocation( modelLocation.getResourceDomain(), "models/" + modelPath + ".json" ) )
      .getInputStream() ) )
  {
    return gson.fromJson( io, UVLMarker.class ).ae2_uvl_marker;
  }
  catch( Exception e )
  {
    // Catch-all in case of any JSON parser issues.
  }
  return false;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public UVLModelWrapper( ResourceLocation modelLocation )
  String modelPath = modelLocation.getResourcePath();
  if( modelLocation.getResourcePath().startsWith( "models/" ) )
  ResourceLocation armatureLocation = new ResourceLocation( modelLocation.getResourceDomain(), "armatures/" + modelPath + ".json" );
  ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation( UVLModelLoader.this.resourceManager, armatureLocation );
  ModelBlock model;
      String s = modelLocation.getResourcePath();
              new ResourceLocation( modelLocation.getResourceDomain(), "models/" + modelPath + ".json" ) );
      reader = new InputStreamReader( iresource.getInputStream(), Charsets.UTF_8 );
      lvt_5_1_.name = modelLocation.toString();

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

@Override
public boolean equals(Object o) {
 if(this == o) {
  return true;
 }
 if(o == null || getClass() != o.getClass()) {
  return false;
 }
 TankCacheKey that = (TankCacheKey) o;
 return that.fluid == this.fluid && that.location.equals(this.location);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public boolean accepts( ResourceLocation modelLocation )
{
  if( !modelLocation.getResourceDomain().equals( AppEng.MOD_ID ) )
  {
    return false;
  }
  return this.builtInModels.containsKey( modelLocation.getResourcePath() );
}

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

@Override
public boolean accepts(ResourceLocation modelLocation) {
  return modelLocation.getNamespace().equals("botania_special") && (
      modelLocation.getPath().equals("specialflower") ||
      modelLocation.getPath().equals("models/block/specialflower") ||
      modelLocation.getPath().equals("models/item/specialflower"));
}

代码示例来源: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: EngineHub/WorldEdit

@Override
public boolean isValidMobType(String type) {
  return EntityList.isRegistered(new ResourceLocation(type));
}

代码示例来源: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: ForestryMC/ForestryMC

private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) {
    ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName());
    return new ResourceLocation(resourcelocation.getNamespace(), String.format("%s/%s%s", this.basePath, resourcelocation.getPath(), ".png"));
  }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

@Override
public ItemStack getMeal(String string) {
  ResourceLocation location = string.contains(":") ? new ResourceLocation(string) : new ResourceLocation(MODID, string);
  for (Recipe recipe : Recipe.REGISTRY.values()) {
    if (recipe.getResource().equals(location)) {
      return CookingHelper.makeRecipe(recipe);
    }
  }
  return null;
}

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

public static boolean shouldMoveTE(boolean te, IBlockState state) {
  if(!ModuleLoader.isFeatureEnabled(PistonsMoveTEs.class))
    return te;
  
  // Jukeboxes that are playing can't be moved so the music can be stopped
  if(state.getPropertyKeys().contains(BlockJukebox.HAS_RECORD) && state.getValue(BlockJukebox.HAS_RECORD))
    return true;
  
  ResourceLocation res = Block.REGISTRY.getNameForObject(state.getBlock());
  return PistonsMoveTEs.movementBlacklist.contains(res.toString()) || PistonsMoveTEs.movementBlacklist.contains(res.getResourceDomain());
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public IModel loadModel( ResourceLocation modelLocation ) throws Exception
{
  return this.builtInModels.get( modelLocation.getResourcePath() );
}

代码示例来源:origin: mezz/JustEnoughItems

@Override
public String getResourceId(FluidStack ingredient) {
  String defaultFluidName = FluidRegistry.getDefaultFluidName(ingredient.getFluid());
  if (defaultFluidName == null) {
    return "";
  }
  ResourceLocation fluidResourceName = new ResourceLocation(defaultFluidName);
  return fluidResourceName.getPath();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@SideOnly( Side.CLIENT )
public String getModID()
{
  if( this.uniqueID == null )
  {
    this.uniqueID = Item.REGISTRY.getNameForObject( this.getDefinition().getItem() );
  }
  if( this.uniqueID == null )
  {
    return "** Null";
  }
  return this.uniqueID.getResourceDomain() == null ? "** Null" : this.uniqueID.getResourceDomain();
}

代码示例来源:origin: SleepyTrousers/EnderIO

public @Nonnull ItemStack toGenericStack(@Nonnull Item item, int meta, int amount) {
 NBTTagCompound data = new NBTTagCompound();
 if (isUnspawnable(entityId)) {
  return toStack(item, meta, amount);
 }
 data.setString(ENTITY_ID_KEY, entityId.toString());
 if (item == itemSoulVial.getItem() && customName == null && PIG.equals(entityId) && Math.random() < 0.01) {
  data.setString(CUSTOM_NAME_KEY, Lang.EASTER_PIGGY.get());
 }
 ItemStack stack = new ItemStack(item, amount, meta);
 stack.setTagCompound(data);
 return stack;
}

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

public static void registerItemAllMeta(Item item, int range) {
  registerItemMetas(item, range, i -> item.getRegistryName().getPath());
}

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

@Nullable
@Override
public String getName(BlockType blockType) {
  return Block.REGISTRY.getObject(new ResourceLocation(blockType.getId())).getLocalizedName();
}

代码示例来源: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: mezz/JustEnoughItems

private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) {
    ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName());
    return new ResourceLocation(resourcelocation.getNamespace(), String.format("%s/%s%s", this.basePath, resourcelocation.getPath(), ".png"));
  }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

public Utensil(ResourceLocation resource) {
  this.resource = resource;
  this.unlocalized = resource.getResourceDomain() + ".cookware." + resource.getResourcePath().replace("_", ".");
  this.burntName = resource.getResourceDomain() + ".meal.burnt." + resource.getResourcePath().replace("_", ".");
  REGISTRY.put(resource, this);
}

相关文章