类net.minecraft.util.ResourceLocation源码实例Demo

下面列出了怎么用net.minecraft.util.ResourceLocation的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MediaMod   文件: DynamicTextureWrapper.java
/**
 * Get resource location from url
 *
 * @param url - url to get the file from
 * @return ResourceLocation
 */
public static ResourceLocation getTexture(URL url) {
    init();
    if (!URL_TEXTURES.containsKey(url)) {
        URL_TEXTURES.put(url, new WrappedResource(null));
        queueImage(url);
    }

    WrappedResource wr = URL_TEXTURES.get(url);
    if (wr.location == null) {
        if (URL_IMAGES.get(url) != null && URL_IMAGES.get(url).image != null) {
            DynamicTexture texture = new DynamicTexture(URL_IMAGES.get(url).image);
            WrappedResource wr2 = new WrappedResource(FMLClientHandler.instance().getClient().getTextureManager().getDynamicTextureLocation(url.toString(), texture));
            URL_TEXTURES.put(url, wr2);
            return wr2.location;
        } else {
            return FULLY_TRANSPARENT_TEXTURE;
        }
    }

    return wr.location;
}
 
源代码2 项目: BigReactors   文件: GuiReactorRedstonePort.java
public GuiReactorRedstonePort(Container container, TileEntityReactorRedstonePort tileentity) {
	super(container);
	_guiBackground = new ResourceLocation(BigReactors.GUI_DIRECTORY + "RedstonePort.png");
	port = tileentity;
	
	ySize = 204;
	
	btnMap = new HashMap<CircuitType, GuiSelectableButton>();
	outputLevel = tileentity.getOutputLevel();
	greaterThan = tileentity.getGreaterThan();
	activeOnPulse = tileentity.isInputActiveOnPulse();
	
	if(outputLevel < 0) {
		retract = true; 
		outputLevel = Math.abs(outputLevel);
	}
	else {
		retract = false;
	}
}
 
源代码3 项目: AgriCraft   文件: IconHelper.java
@Nonnull
public static TextureAtlasSprite registerIcon(@Nonnull ResourceLocation texturePath) {
    // Validate parameters.
    Preconditions.checkNotNull(texturePath, "IconHelper cannot register an icon with a null texture path!");
    
    // The icon to be returned.
    TextureAtlasSprite ret = null;
    
    // Attempt to register the sprite to the MineCraft texture map.
    try {
        ret = Minecraft.getMinecraft().getTextureMapBlocks().registerSprite(texturePath);
    } catch (Exception e) {
        AgriCore.getLogger("agricraft").debug(e.getLocalizedMessage());
    }
    
    // Return the icon, or the default icon in the case that the icon was null.
    if (ret != null) {
        return ret;
    } else {
        return getDefaultIcon();
    }
}
 
源代码4 项目: NOVA-Core   文件: NovaFolderResourcePack.java
@Override
public Set<ResourceLocation> getLanguageFiles() {
	Pattern langPattern = Pattern.compile("^[a-zA-Z0-9-]+\\.lang$", Pattern.CASE_INSENSITIVE);

	Set<ResourceLocation> langFiles = new HashSet<>();

	for (String domain : getResourceDomains()) {
		findFileCaseInsensitive("assets/" + domain + "/lang/").filter(File::isDirectory).ifPresent(file -> {
			Arrays.stream(file.listFiles((dir, name) -> langPattern.asPredicate().test(name)))
				.map(File::getName)
				.forEach(name -> langFiles.add(new ResourceLocation(domain, name)));
		});
	}

	return langFiles;
}
 
源代码5 项目: YUNoMakeGoodMap   文件: StructureLoader.java
@Override
public void generate(World world, BlockPos pos)
{
    PlacementSettings settings = new PlacementSettings();
    Template temp = null;
    String suffix = world.provider.getDimensionType().getSuffix();
    String opts = world.getWorldInfo().getGeneratorOptions() + suffix;

    if (!Strings.isNullOrEmpty(opts))
        temp = StructureUtil.loadTemplate(new ResourceLocation(opts), (WorldServer)world, true);
    if (temp == null)
        temp = StructureUtil.loadTemplate(new ResourceLocation("/config/", this.fileName + suffix), (WorldServer)world, !Strings.isNullOrEmpty(suffix));
    if (temp == null)
        return; //If we're not in the overworld, and we don't have a template...

    BlockPos spawn = StructureUtil.findSpawn(temp, settings);
    if (spawn != null)
    {
        pos = pos.subtract(spawn);
        world.setSpawnPoint(pos);
    }

    temp.addBlocksToWorld(world, pos, settings, 0); //Push to world, with no neighbor notifications!
    world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!
}
 
源代码6 项目: GT-Classic   文件: GTEventLootTableLoad.java
@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
	/*
	 * Iterates both the stack array and resource location array to create a 2d
	 * table
	 */
	if (GTConfig.general.addLootItems) {
		for (ItemStack item : lootpool) {
			for (ResourceLocation table : loottable) {
				if (event.getName().equals(table)) {
					event.getTable().getPool("main").addEntry(new LootEntryItem(item.getItem(), 16, 0, new LootFunction[] {
							createCountFunction(1, 6) }, NO_CONDITIONS, getStackResourceName(item)));
				}
			}
		}
	}
}
 
源代码7 项目: enderutilities   文件: EntityFallingBlockEU.java
@Override
protected void writeEntityToNBT(NBTTagCompound compound)
{
    Block block = this.blockState != null ? this.blockState.getBlock() : Blocks.AIR;
    ResourceLocation rl = Block.REGISTRY.getNameForObject(block);
    compound.setString("Block", rl == null ? "" : rl.toString());
    compound.setByte("Data", this.blockState != null ? (byte) block.getMetaFromState(this.blockState) : 0);
    compound.setInteger("Time", this.fallTime);
    compound.setBoolean("DropItem", this.shouldDropItem);
    compound.setBoolean("HurtEntities", this.hurtEntities);
    compound.setFloat("FallHurtAmount", this.fallHurtAmount);
    compound.setInteger("FallHurtMax", this.fallHurtMax);

    if (this.tileEntityData != null)
    {
        compound.setTag("TileEntityData", this.tileEntityData);
    }
}
 
源代码8 项目: Hyperium   文件: TabCompletionUtil.java
public static List<String> getListOfStringsMatchingLastWord(String[] p_175762_0_, Collection<?> p_175762_1_) {
    String s = p_175762_0_[p_175762_0_.length - 1];
    List<String> list = new ArrayList<>();
    if (!p_175762_1_.isEmpty()) {
        list = p_175762_1_.stream().map(Functions.toStringFunction()::apply).collect(Collectors.toList()).stream().filter(s2 ->
            doesStringStartWith(s, s2)).collect(Collectors.toList());

        if (list.isEmpty()) {
            for (Object object : p_175762_1_) {
                if (object instanceof ResourceLocation && doesStringStartWith(s, ((ResourceLocation) object).getResourcePath())) {
                    list.add(String.valueOf(object));
                }
            }
        }
    }

    return list;
}
 
源代码9 项目: enderutilities   文件: TargetData.java
public boolean isTargetBlockUnchanged()
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null)
    {
        return false;
    }

    World world = server.getWorld(this.dimension);
    if (world == null)
    {
        return false;
    }

    IBlockState iBlockState = world.getBlockState(this.pos);
    Block block = iBlockState.getBlock();
    ResourceLocation rl = ForgeRegistries.BLOCKS.getKey(block);
    int meta = block.getMetaFromState(iBlockState);

    // The target block unique name and metadata matches what we have stored
    return this.blockMeta == meta && rl != null && this.blockName.equals(rl.toString());
}
 
源代码10 项目: Production-Line   文件: ItemPLRecord.java
public ItemPLRecord(String name, SoundEvent soundEvent) {
    super(name, soundEvent);
    this.name = name;
    this.setCreativeTab(ProductionLine.creativeTabPL);
    this.setUnlocalizedName(MOD_ID + "." + name);
    GameRegistry.<Item>register(this, new ResourceLocation(MOD_ID, name));
}
 
源代码11 项目: Wizardry   文件: ModuleEffectFrost.java
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Vec3d position = spell.getTarget(world);

	if (position == null) return;

	ParticleBuilder glitter = new ParticleBuilder(1);
	glitter.setAlphaFunction(new InterpFloatInOut(0.0f, 0.1f));
	glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
	glitter.enableMotionCalculation();
	glitter.setScaleFunction(new InterpScale(1, 0));
	glitter.setAcceleration(new Vec3d(0, -0.02, 0));
	glitter.setCollision(true);
	glitter.setCanBounce(true);
	ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), RandUtil.nextInt(5, 15), 0, (aFloat, particleBuilder) -> {
		double radius = 2;
		double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
		double r = radius * RandUtil.nextFloat();
		double x = r * MathHelper.cos((float) theta);
		double z = r * MathHelper.sin((float) theta);
		glitter.setScale(RandUtil.nextFloat());
		glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-2, 2), z));
		glitter.setLifetime(RandUtil.nextInt(50, 100));
		Vec3d direction = position.add(glitter.getPositionOffset()).subtract(position).normalize().scale(1 / 5);
		glitter.addMotion(direction.scale(RandUtil.nextDouble(0.5, 1)));
	});

}
 
源代码12 项目: enderutilities   文件: ClientProxy.java
private static void registerItemModelWithNamePrefix(ItemEnderUtilities item, int meta, String namePrefix)
{
    if (item.isEnabled())
    {
        ResourceLocation rl = item.getRegistryName();
        ModelLoader.setCustomModelResourceLocation(item, meta,
                new ModelResourceLocation(rl.getNamespace() + ":" + namePrefix + rl.getPath(), "inventory"));
    }
}
 
源代码13 项目: GregTech   文件: MetaTileEntityItemCollector.java
public MetaTileEntityItemCollector(ResourceLocation metaTileEntityId, int tier, int maxItemSuckingRange) {
    super(metaTileEntityId, tier);
    this.maxItemSuckingRange = maxItemSuckingRange;
    this.itemSuckingRange = maxItemSuckingRange;
    this.itemFilter = new ItemFilterContainer(this::markDirty);
    initializeInventory();
}
 
源代码14 项目: TFC2   文件: RenderTiger.java
@Override
protected ResourceLocation getEntityTexture(EntityTiger entity) 
{
	if(entity.getTigerType() == TigerType.Snow)
		return texTigerSnow;
	return texTiger;
}
 
源代码15 项目: enderutilities   文件: ItemBuildersWand.java
private TemplateEnderUtilities getTemplate(World world, EntityPlayer player, ItemStack stack, PlacementSettings placement)
{
    TemplateManagerEU templateManager = this.getTemplateManager();
    ResourceLocation rl = this.getTemplateResource(stack, player);
    TemplateEnderUtilities template = templateManager.getTemplate(rl);
    template.setPlacementSettings(placement);

    return template;
}
 
源代码16 项目: AdvancedMod   文件: ResearchItem.java
public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ResourceLocation icon)
{
	this.key = key;
	this.category = category;
	this.tags = tags;    	
    this.icon_resource = icon;
    this.icon_item = null;
    this.displayColumn = col;
    this.displayRow = row;
    this.complexity = complex;
    if (complexity < 1) this.complexity = 1;
    if (complexity > 3) this.complexity = 3;
}
 
源代码17 项目: Wizardry   文件: ModuleEffectPoisonCloud.java
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Vec3d position = spell.getTarget(world);

	if (position == null) return;

	ParticleBuilder glitter = new ParticleBuilder(0);
	if (RandUtil.nextInt(5) != 0)
		glitter.setColor(instance.getPrimaryColor());
	else glitter.setColor(instance.getSecondaryColor());
	glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SMOKE));

	ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 20, 0, (aFloat, particleBuilder) -> {
		particleBuilder.setLifetime(RandUtil.nextInt(10, 40));
		particleBuilder.setScale(RandUtil.nextFloat(5, 10));
		particleBuilder.setAlpha(RandUtil.nextFloat(0.3f, 0.5f));
		particleBuilder.setAlphaFunction(new InterpFloatInOut(0.3f, 0.4f));
		double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell);
		double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
		double r = area * RandUtil.nextFloat();
		double x = r * MathHelper.cos((float) theta);
		double z = r * MathHelper.sin((float) theta);
		particleBuilder.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-r, r), z));
		particleBuilder.setMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
		//	particleBuilder.setAcceleration(new Vec3d(0, -0.015, 0));
	});
}
 
源代码18 项目: CommunityMod   文件: RegUtil.java
public static <T extends Item> T registerItem(IForgeRegistry<Item> reg, T item, String name) {
	item.setRegistryName(new ResourceLocation(CommunityGlobals.MOD_ID, name));
	item.setTranslationKey(CommunityGlobals.MOD_ID + '.' + name);
	item.setCreativeTab(CommunityGlobals.TAB);
	
	reg.register(item);
	
	return item;
}
 
源代码19 项目: NOVA-Core   文件: FWBlockSound.java
@Override
public SoundEvent getBreakSound() {
	return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK)
		.map(sound -> (sound.domain.isEmpty() && !sound.name.contains(".")) ? "dig." + sound.name : sound.getID())
		.map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID)))
		.orElseGet(super::getBreakSound);
}
 
源代码20 项目: OpenModsLib   文件: TexturedItemModel.java
private static IModel getModel(Optional<ResourceLocation> model) {
	if (model.isPresent()) {
		ResourceLocation location = model.get();
		return ModelLoaderRegistry.getModelOrLogError(location, "Couldn't load base-model dependency: " + location);
	} else {
		return ModelLoaderRegistry.getMissingModel();
	}
}
 
源代码21 项目: YUNoMakeGoodMap   文件: GuiCustomizeWorld.java
public Info(int width, List<String> lines, ResourceLocation logoPath, Dimension logoDims)
{
    super(GuiCustomizeWorld.this.mc,
          width,
          GuiCustomizeWorld.this.height,
          32, GuiCustomizeWorld.this.height - 68 + 4,
          LIST_WIDTH + 20, 60,
          GuiCustomizeWorld.this.width,
          GuiCustomizeWorld.this.height);
    this.lines    = resizeContent(lines);
    this.logoPath = logoPath;
    this.logoDims = logoDims;

    this.setHeaderInfo(true, getHeaderHeight());
}
 
源代码22 项目: TofuCraftReload   文件: RenderTofuCow.java
/**
 * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
 */
protected ResourceLocation getEntityTexture(EntityTofuCow entity) {
    if(entity.getVariant() == 1){
        return ZUNDACOW_TEXTURES;
    }else {
        return COW_TEXTURES;
    }
}
 
源代码23 项目: CommunityMod   文件: BlockTraverseSapling.java
public BlockTraverseSapling(String name, TraverseTreeGenerator generator) {
    super();
    this.generator = generator;
    setRegistryName(new ResourceLocation(TraverseConstants.MOD_ID, name + "_sapling"));
    setTranslationKey(getRegistryName().toString());
    setCreativeTab(TraverseTab.TAB);
    setSoundType(SoundType.PLANT);
    ShootingStar.registerModel(new ModelCompound(TraverseConstants.MOD_ID, this, "sapling", STAGE, TYPE));
}
 
源代码24 项目: Artifacts   文件: ParticleUtils.java
public static ResourceLocation getParticleTexture()
{
	try
	{
		return (ResourceLocation)ReflectionHelper.getPrivateValue(EffectRenderer.class, null, new String[] { "particleTextures", "b", "field_110737_b" }); } catch (Exception e) {
		}
	return null;
}
 
源代码25 项目: enderutilities   文件: BakedModelInserter.java
@Override
public Collection<ResourceLocation> getTextures()
{
    List<ResourceLocation> textures = Lists.newArrayList();

    for (String name : this.getTextureMapping().values())
    {
        textures.add(new ResourceLocation(name));
    }

    return textures;
}
 
源代码26 项目: CodeChickenLib   文件: TextureUtils.java
public static Colour[] loadTextureColours(ResourceLocation resource) {
    int[] idata = loadTextureData(resource);
    Colour[] data = new Colour[idata.length];
    for (int i = 0; i < data.length; i++)
        data[i] = new ColourARGB(idata[i]);
    return data;
}
 
源代码27 项目: Wizardry   文件: ModuleShapeTouch.java
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
	if (overrides.onRenderTouch(world, spell, spellRing)) return;

	Entity targetEntity = spell.getVictim(world);

	if (targetEntity == null) return;

	ParticleBuilder glitter = new ParticleBuilder(1);
	glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
	ParticleSpawner.spawn(glitter, world, new InterpCircle(targetEntity.getPositionVector().add(0, targetEntity.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
		if (RandUtil.nextBoolean()) {
			glitter.setColor(spellRing.getPrimaryColor());
			glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
		} else {
			glitter.setColor(spellRing.getSecondaryColor());
			glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(-0.1, -0.01), 0));
		}
		glitter.setLifetime(RandUtil.nextInt(20, 30));
		glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
		glitter.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
		glitter.setLifetime(RandUtil.nextInt(10, 20));
		glitter.setScaleFunction(new InterpScale(1, 0));
	});
}
 
源代码28 项目: enderutilities   文件: ItemBuildersWand.java
private ResourceLocation getTemplateResource(ItemStack stack, EntityPlayer player)
{
    int id = this.getSelectionIndex(stack);
    UUID uuid = NBTUtils.getUUIDFromItemStack(stack, WRAPPER_TAG_NAME, true);
    String name = NBTUtils.getOrCreateString(stack, WRAPPER_TAG_NAME, "player", player.getName());
    return new ResourceLocation(Reference.MOD_ID, name + "_" + uuid.toString() + "_" + id);
}
 
源代码29 项目: GregTech   文件: SimpleOrientedCubeRenderer.java
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(TextureMap textureMap) {
    this.sprites = new TextureAtlasSprite[6];
    for (CubeSide cubeSide : CubeSide.values()) {
        String fullPath = String.format("blocks/%s/%s", basePath, cubeSide.name().toLowerCase());
        this.sprites[cubeSide.ordinal()] = textureMap.registerSprite(new ResourceLocation(GTValues.MODID, fullPath));
    }
}
 
源代码30 项目: PneumaticCraft   文件: ResearchItem.java
public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ResourceLocation icon)
{
	this.key = key;
	this.category = category;
	this.tags = tags;    	
    this.icon_resource = icon;
    this.icon_item = null;
    this.displayColumn = col;
    this.displayRow = row;
    this.complexity = complex;
    if (complexity < 1) this.complexity = 1;
    if (complexity > 3) this.complexity = 3;
}
 
 类所在包
 同包方法