net.minecraft.util.Identifier Java Examples

The following examples show how to use net.minecraft.util.Identifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditItemListScreen.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void renderItem(MatrixStack matrixStack, int index, int x,
	int y, int var4, int var5, int var6, float partialTicks)
{
	String name = list.get(index);
	Item item = Registry.ITEM.get(new Identifier(name));
	ItemStack stack = new ItemStack(item);
	TextRenderer fr = mc.textRenderer;
	
	String displayName =
		renderIconAndGetName(matrixStack, stack, x + 1, y + 1, true);
	fr.draw(matrixStack, displayName, x + 28, y, 0xf0f0f0);
	fr.draw(matrixStack, name, x + 28, y + 9, 0xa0a0a0);
	fr.draw(matrixStack, "ID: " + Registry.ITEM.getId(item).toString(),
		x + 28, y + 18, 0xa0a0a0);
}
 
Example #2
Source File: MixinClientPlayNetworkHandler.java    From multiconnect with MIT License 6 votes vote down vote up
@Inject(method = "onGameJoin", at = @At("RETURN"))
private void onOnGameJoin(GameJoinS2CPacket packet, CallbackInfo ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        onSynchronizeTags(new SynchronizeTagsS2CPacket(new RegistryTagManager()));

        Protocol_1_12_2 protocol = (Protocol_1_12_2) ConnectionInfo.protocol;
        List<Recipe<?>> recipes = new ArrayList<>();
        List<RecipeInfo<?>> recipeInfos = protocol.getCraftingRecipes();
        for (int i = 0; i < recipeInfos.size(); i++) {
            recipes.add(recipeInfos.get(i).create(new Identifier(String.valueOf(i))));
        }
        onSynchronizeRecipes(new SynchronizeRecipesS2CPacket(recipes));

        CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
        Commands_1_12_2.registerAll(dispatcher, null);
        onCommandTree(new CommandTreeS2CPacket(dispatcher.getRoot()));
        TabCompletionManager.requestCommandList();
    }
}
 
Example #3
Source File: MixinPotionItems.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public String getCreatorModId(ItemStack itemStack) {
	final Item item = itemStack.getItem();
	Identifier defaultId = Registry.ITEM.getDefaultId();
	Identifier id = Registry.ITEM.getId(item);

	if (defaultId.equals(id) && item != Registry.ITEM.get(defaultId)) {
		return null;
	} else {
		final String namespace = id.getNamespace();

		if ("minecraft".equals(namespace)) {
			final Potion potion = PotionUtil.getPotion(itemStack);
			defaultId = Registry.POTION.getDefaultId();
			id = Registry.POTION.getId(potion);

			if (defaultId.equals(id) && potion != Registry.POTION.get(defaultId)) {
				return namespace;
			}

			return id.getNamespace();
		}

		return namespace;
	}
}
 
Example #4
Source File: PonyTextures.java    From MineLittlePony with MIT License 6 votes vote down vote up
private Identifier getTexture(final VillagerType type, final VillagerProfession profession) {

        if (profession == VillagerProfession.NONE) {
            return fallback;
        }

        String key = String.format("pony/%s/%s", type, profession);

        if (cache.containsKey(key)) {
            return cache.get(key); // People often complain that villagers cause lag,
                                   // so let's do better than Mojang and rather NOT go
                                   // through all the lambda generations if we can avoid it.
        }

        Identifier result = verifyTexture(formatter.supplyTexture(key)).orElseGet(() -> {
            if (type == VillagerType.PLAINS) {
                // if texture loading fails, use the fallback.
                return fallback;
            }

            return getTexture(VillagerType.PLAINS, profession);
        });

        cache.put(key, result);
        return result;
    }
 
Example #5
Source File: GalacticraftRecipes.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private static <T extends Recipe<?>> RecipeType<T> registerType(String id) {
    return Registry.register(Registry.RECIPE_TYPE, new Identifier(Constants.MOD_ID, id), new RecipeType<T>() {
        public String toString() {
            return id;
        }
    });
}
 
Example #6
Source File: CarpetExpression.java    From fabric-carpet with MIT License 5 votes vote down vote up
private <T> Stat<T> getStat(StatType<T> type, Identifier id)
{
    T key = type.getRegistry().get(id);
    if (key == null || !((StatTypeInterface)type).hasStatCreated(key))
        return null;
    return type.getOrCreateStat(key);
}
 
Example #7
Source File: ParticleArgumentType_1_12_2.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public ParticleType<?> parse(StringReader reader) throws CommandSyntaxException {
    int start = reader.getCursor();
    Identifier id = Identifier.fromCommandInput(reader);
    if (!Registry.PARTICLE_TYPE.containsId(id)) {
        reader.setCursor(start);
        throw ParticleArgumentType.UNKNOWN_PARTICLE_EXCEPTION.createWithContext(reader, id);
    }
    return Registry.PARTICLE_TYPE.get(id);
}
 
Example #8
Source File: WBar.java    From LibGui with MIT License 5 votes vote down vote up
public WBar(Identifier bg, Identifier bar, int field, int maxfield, Direction dir) {
	this.bg = bg;
	this.bar = bar;
	this.field = field;
	this.max = maxfield;
	this.maxValue = 0;
	this.direction = dir;
}
 
Example #9
Source File: AbstractClientPlayerEntityMixin.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Inject(method = "getCapeTexture", at = @At("RETURN"), cancellable = true)
private void getCapeTexture(CallbackInfoReturnable<Identifier> info) {
    if (GalacticraftClient.jsonCapes.areCapesLoaded()) {
        if (GalacticraftClient.jsonCapes.getCapePlayers().containsKey(this.getPlayerListEntry().getProfile().getId())) {
            info.setReturnValue(GalacticraftClient.jsonCapes.getCapePlayers()
                    .get(this.getPlayerListEntry().getProfile().getId()).getCape().getTexture());
        }
    }
}
 
Example #10
Source File: DefaultArmourTextureResolver.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public ArmourVariant getArmourVariant(ArmourLayer layer, Identifier resolvedTexture) {
    if (resolvedTexture.getPath().endsWith("_pony.png")) {
        return ArmourVariant.NORMAL;
    }
    return ArmourVariant.LEGACY;
}
 
Example #11
Source File: MachineHandledScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private void sendSecurityUpdate(ConfigurableElectricMachineBlockEntity entity) {
    if (this.playerInventory.player.getUuid().equals(entity.getSecurity().getOwner()) || !entity.getSecurity().hasOwner()) {
        MinecraftClient.getInstance().getNetworkHandler().sendPacket(new CustomPayloadC2SPacket(new Identifier(Constants.MOD_ID, "security_update"),
                new PacketByteBuf(Unpooled.buffer())
                        .writeBlockPos(pos)
                        .writeEnumConstant(entity.getSecurity().getPublicity())
        ));
    } else {
        Galacticraft.logger.error("Tried to send security update when not the owner!");
    }
}
 
Example #12
Source File: ItemArgumentType_1_12_2.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public Item parse(StringReader reader) throws CommandSyntaxException {
    int start = reader.getCursor();
    Identifier id = Identifier.fromCommandInput(reader);
    if (!Registry.ITEM.containsId(id)) {
        reader.setCursor(start);
        throw ItemStringReader.ID_INVALID_EXCEPTION.createWithContext(reader, id);
    }
    Item item = Registry.ITEM.get(id);
    if (!isValidItem(item)) {
        reader.setCursor(start);
        throw ItemStringReader.ID_INVALID_EXCEPTION.createWithContext(reader, id);
    }
    return item;
}
 
Example #13
Source File: PonyTextures.java    From MineLittlePony with MIT License 5 votes vote down vote up
protected Optional<Identifier> verifyTexture(Identifier texture) {
    if (!resourceManager.containsResource(texture)) {
        MineLittlePony.logger.warn("Villager texture `" + texture + "` was not found.");
        return Optional.empty();
    }

    return Optional.of(texture);
}
 
Example #14
Source File: HallowTweaker.java    From the-hallow with MIT License 5 votes vote down vote up
public void addInfusion(Object target, Object input, Object output) {
	try {
		ItemStack stack = RecipeParser.processItemStack(output);
		Identifier id = tweaker.getRecipeId(stack);
		Ingredient targ = RecipeParser.processIngredient(target);
		Ingredient in = RecipeParser.processIngredient(input);
		tweaker.addRecipe(new InfusionRecipe(id, targ, in, stack));
	} catch (Exception e) {
		tweaker.getLogger().error("Error parsing hallowed infusion recipe - " + e.getMessage());
	}
}
 
Example #15
Source File: PonyManager.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public IPony getPony(Identifier resource) {
    try {
        return poniesCache.get(resource);
    } catch (ExecutionException e) {
        return new Pony(resource, PonyData.NULL);
    }
}
 
Example #16
Source File: GalacticraftEnergy.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
public static void register() {
        Registry.register(UniversalComponents.ENERGY_TYPES, new Identifier(Constants.MOD_ID, Constants.Energy.GALACTICRAFT_JOULES), GALACTICRAFT_JOULES);
        Registry.register(UniversalComponents.ENERGY_TYPES, new Identifier(Constants.MOD_ID, Constants.Energy.GALACTICRAFT_OXYGEN), GALACTICRAFT_OXYGEN);

//        ItemComponentCallback.event(GalacticraftItems.BATTERY).register((stack, container) -> container.put(UniversalComponents.CAPACITOR_COMPONENT, new ItemCapacitorComponent(BatteryItem.getMaxEnergy(), GalacticraftEnergy.GALACTICRAFT_JOULES)));
//        ItemComponentCallback.event(GalacticraftItems.INFINITE_BATTERY).register((stack, container) -> {
//            ItemCapacitorComponent capacitorComponent = new ItemCapacitorComponent(Integer.MAX_VALUE, GalacticraftEnergy.GALACTICRAFT_JOULES);
//            capacitorComponent.copyFrom(GalacticraftEnergy.INFINITE_ENERGY_COMPONENT);
//            container.put(UniversalComponents.CAPACITOR_COMPONENT, capacitorComponent);
//        });
    }
 
Example #17
Source File: Identifiers.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Gets the current {@link Identifier} for the object in the registry if it exists. If the object does not exist in
 * the provided registry, {@code fallback} will be returned instead.
 *
 * @param registry the registry to query. Must be an instance of {@link DefaultedRegistry}.
 * @return an {@link Identifier} if the instance is registered or if the fallback is non null, otherwise null
 */
@Nullable
public static <T> Identifier getOrFallback(DefaultedRegistry<T> registry, T instance, @Nullable Identifier fallback) {
	Identifier current = registry.getId(instance);

	if (current.equals(registry.getDefaultId())) {
		return fallback;
	} else {
		return current;
	}
}
 
Example #18
Source File: MixinDefaultPlayerSkin.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Inject(method = "getTexture()Lnet/minecraft/util/Identifier;",
        at = @At("HEAD"),
        cancellable = true)
private static void legacySkin(CallbackInfoReturnable<Identifier> cir) {
    if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
        cir.setReturnValue(IPonyManager.STEVE);
    }
}
 
Example #19
Source File: CarpetEventServer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void onRecipeSelected(ServerPlayerEntity player, Identifier recipe, boolean fullStack)
{
    handler.call( () ->
    {
        return Arrays.asList(
                ((c, t) -> new EntityValue(player)),
                ((c, t) -> new StringValue(NBTSerializableValue.nameFromRegistryId(recipe))),
                ((c, t) -> new NumericValue(fullStack))
        );
    }, player::getCommandSource);
}
 
Example #20
Source File: DefaultArmourTextureResolver.java    From MineLittlePony with MIT License 5 votes vote down vote up
private Identifier ponifyResource(Identifier human) {
    return PONY_ARMOUR.computeIfAbsent(human, key -> {
        String domain = key.getNamespace();
        if ("minecraft".equals(domain)) {
            domain = "minelittlepony"; // it's a vanilla armor. I provide these.
        }

        return new Identifier(domain, key.getPath().replace(".png", "_pony.png"));
    });
}
 
Example #21
Source File: ShapelessCompressingRecipe.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
static ItemStack getStack(JsonObject json) {
    String itemId = JsonHelper.getString(json, "item");
    Item ingredientItem = Registry.ITEM.getOrEmpty(new Identifier(itemId)).orElseThrow(() -> new JsonSyntaxException("Unknown item '" + itemId + "'"));
    if (json.has("data")) {
        throw new JsonParseException("Disallowed data tag found");
    } else {
        int count = JsonHelper.getInt(json, "count", 1);
        return new ItemStack(ingredientItem, count);
    }
}
 
Example #22
Source File: NetworkVersionManager.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Construct the Map representation of the channel list, for use during login handshaking.
 *
 * @see FMLHandshakeMessages.S2CModList
 * @see FMLHandshakeMessages.C2SModListReply
 */
public Map<Identifier, String> buildChannelVersions() {
	Map<Identifier, String> channelVersions = new HashMap<>();

	for (Map.Entry<Identifier, NetworkChannelVersion> entry: versions.entrySet()) {
		channelVersions.put(entry.getKey(), entry.getValue().getNetworkProtocolVersion());
	}

	return channelVersions;
}
 
Example #23
Source File: DownloadScreen.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
    super.render(mouseX, mouseY, partialTicks);
    String right = "Preparing Addon " + addon + " of " + dls.length;
    String right2 = "";
    if (dl.hasStarted()) {
        right = "Downloading Addon " + addon + " of " + dls.length;
        int percent = (int) ((dl.getCurrentSize() * 100) / dl.getTotalSize());
        right2 = percent + "% " + humanReadableByteCount(dl.getCurrentSize()) + "/" + humanReadableByteCount(dl.getTotalSize());
    }
    if (dl.isComplete()) {
        right = "Completed Addon Download " + addon + " of " + dls.length;
        nextAddon();
    }
    fill(0, 0, width, height, RED.getRGB());
    fill(0, height - 20, width, height, DARK.darker().getRGB());
    fill(width - font.getStringWidth(right) - 4, height - 34, width, height, DARK.darker().getRGB());
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.enableAlphaTest();
    minecraft.getTextureManager().bindTexture(new Identifier("sandbox", "textures/gui/sandbox.png"));
    GlStateManager.color4f(1, 1, 1, 1);
    int int_6 = (this.minecraft.getWindow().getScaledWidth() - 256) / 2;
    int int_8 = (this.minecraft.getWindow().getScaledHeight() - 256) / 2;
    this.blit(int_6, int_8, 0, 0, 256, 256);
    GlStateManager.popMatrix();
    drawCenteredString(font, "Connecting to Sandbox", (int) (width / 2f), (int) ((height / 2f) + (width / 3) / 2) - 20, WHITE.getRGB());
    drawRightText(right, width, height - 30, WHITE.getRGB());
    drawCenteredString(font, right2, width - (font.getStringWidth(right) / 2), height - 14, WHITE.getRGB());
    font.drawWithShadow("Joining Private Session", 3, height - 14, WHITE.getRGB());
}
 
Example #24
Source File: ConfigurableElectricMachineBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Nonnull
public SpriteIdentifier getDefaultSpriteId(@Nonnull T entity, @Nonnull Direction direction) {
    switch (direction) {
        case NORTH:
        case SOUTH:
        case EAST:
        case WEST:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_side"));
        case UP:
        case DOWN:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
    }
    return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
}
 
Example #25
Source File: BackgroundPonyList.java    From MineLittlePony with MIT License 5 votes vote down vote up
public Identifier getId(UUID uuid) {
    if (backgroundPonyList.isEmpty() || isUser(uuid)) {
        return IPonyManager.getDefaultSkin(uuid);
    }

    int bgi = MathUtil.mod(uuid.hashCode(), backgroundPonyList.size());

    return backgroundPonyList.get(bgi);
}
 
Example #26
Source File: InGameHudMixin.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Inject(method = "render", at = @At(value = "TAIL"))
private void draw(MatrixStack stack, float float_1, CallbackInfo ci) {
    if (CelestialBodyType.getByDimType(client.player.world.getRegistryKey()).isPresent() && !CelestialBodyType.getByDimType(client.player.world.getRegistryKey()).get().getAtmosphere().getComposition().containsKey(AtmosphericGas.OXYGEN)) {
        DiffuseLighting.enableGuiDepthLighting();
        client.getTextureManager().bindTexture(new Identifier(Constants.MOD_ID, Constants.ScreenTextures.getRaw(Constants.ScreenTextures.OVERLAY)));

        this.drawTexture(stack, this.scaledWidth - 17, 5, OXYGEN_X, OXYGEN_Y, OXYGEN_WIDTH, OXYGEN_HEIGHT);
        this.drawTexture(stack, this.scaledWidth - 34, 5, OXYGEN_X, OXYGEN_Y, OXYGEN_WIDTH, OXYGEN_HEIGHT);

        if (!client.player.isCreative()) {
            SimpleInventoryComponent gearInventory = ((GCPlayerAccessor) this.client.player).getGearInventory();
            if (gearInventory.getStack(6).getItem() instanceof OxygenTankItem) {
                this.drawTexture(stack, this.scaledWidth - 17 + OXYGEN_WIDTH, 5 + OXYGEN_HEIGHT, OXYGEN_OVERLAY_X, OXYGEN_OVERLAY_Y, -OXYGEN_WIDTH, (int) -((double) OXYGEN_HEIGHT - ((double) OXYGEN_HEIGHT * (((double) gearInventory.getStack(6).getMaxDamage() - (double) gearInventory.getStack(6).getDamage()) / (double) gearInventory.getStack(6).getMaxDamage()))));
            } else if (client.player.isCreative()) {
                this.drawTexture(stack, this.scaledWidth - 17 + OXYGEN_WIDTH, 5 + OXYGEN_HEIGHT, OXYGEN_OVERLAY_X, OXYGEN_OVERLAY_Y, -OXYGEN_WIDTH, -OXYGEN_HEIGHT);
            }
            if (gearInventory.getStack(7).getItem() instanceof OxygenTankItem) {
                this.drawTexture(stack, this.scaledWidth - 34 + OXYGEN_WIDTH, 5 + OXYGEN_HEIGHT, OXYGEN_OVERLAY_X, OXYGEN_OVERLAY_Y, -OXYGEN_WIDTH, (int) -((double) OXYGEN_HEIGHT - ((double) OXYGEN_HEIGHT * (((double) gearInventory.getStack(7).getMaxDamage() - (double) gearInventory.getStack(7).getDamage()) / (double) gearInventory.getStack(7).getMaxDamage()))));
            } else if (client.player.isCreative()) {
                this.drawTexture(stack, this.scaledWidth - 34 + OXYGEN_WIDTH, 5 + OXYGEN_HEIGHT, OXYGEN_OVERLAY_X, OXYGEN_OVERLAY_Y, -OXYGEN_WIDTH, -OXYGEN_HEIGHT);
            }
        } else {
            this.drawTexture(stack, this.scaledWidth - 17, 5, 12, 40, OXYGEN_WIDTH, OXYGEN_HEIGHT);
            this.drawTexture(stack, this.scaledWidth - 34, 5, 12, 40, OXYGEN_WIDTH, OXYGEN_HEIGHT);
        }
    }
}
 
Example #27
Source File: MixinActivity.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<Activity> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #28
Source File: PlayerModelKey.java    From MineLittlePony with MIT License 4 votes vote down vote up
PlayerModelKey(String name, Function<Boolean, M> modelFactory, RendererFactory rendererFactory) {
    this.rendererFactory = rendererFactory;

    steveKey = Mson.getInstance().registerModel(new Identifier("minelittlepony", "races/steve/" + name), () -> modelFactory.apply(false));
    alexKey = Mson.getInstance().registerModel(new Identifier("minelittlepony", "races/alex/" + name), () -> modelFactory.apply(true));
}
 
Example #29
Source File: TagContainerAccessor.java    From multiconnect with MIT License 4 votes vote down vote up
@Accessor("entries")
void multiconnect_setEntries(BiMap<Identifier, Tag<T>> entries);
 
Example #30
Source File: RecipeInfo.java    From multiconnect with MIT License 4 votes vote down vote up
public Recipe<?> create(Identifier id) {
    return creator.apply(id);
}