net.minecraft.util.IStringSerializable Java Examples

The following examples show how to use net.minecraft.util.IStringSerializable. 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: MachineRecipeLoader.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static <T extends Enum<T> & IStringSerializable> void registerChiselingRecipes(StoneBlock<T> stoneBlock) {
    for (T variant : stoneBlock.getVariantValues()) {
        boolean isBricksVariant = variant.getName().endsWith("_bricks");
        if (!isBricksVariant) {
            ModHandler.addSmeltingRecipe(stoneBlock.getItemVariant(variant, ChiselingVariant.CRACKED), stoneBlock.getItemVariant(variant, ChiselingVariant.NORMAL));
            RecipeMaps.FORGE_HAMMER_RECIPES.recipeBuilder().duration(12).EUt(4)
                .inputs(stoneBlock.getItemVariant(variant, ChiselingVariant.NORMAL))
                .outputs(stoneBlock.getItemVariant(variant, ChiselingVariant.CRACKED))
                .buildAndRegister();
        } else {
            ModHandler.addSmeltingRecipe(stoneBlock.getItemVariant(variant, ChiselingVariant.NORMAL), stoneBlock.getItemVariant(variant, ChiselingVariant.CRACKED));
        }
        RecipeMaps.MIXER_RECIPES.recipeBuilder().duration(12).EUt(4)
            .inputs(stoneBlock.getItemVariant(variant, !isBricksVariant ? ChiselingVariant.CRACKED : ChiselingVariant.NORMAL))
            .fluidInputs(Materials.Water.getFluid(144))
            .outputs(stoneBlock.getItemVariant(variant, ChiselingVariant.MOSSY))
            .buildAndRegister();
        ModHandler.addShapelessRecipe(stoneBlock.getRegistryName().getResourcePath() + "_chiseling_" + variant,
            stoneBlock.getItemVariant(variant, ChiselingVariant.CHISELED),
            stoneBlock.getItemVariant(variant, ChiselingVariant.NORMAL));
    }
}
 
Example #2
Source File: PropertyClass.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
protected PropertyClass(String name, Class valueClass, Collection allowedValues) 
{
	super(name, valueClass);
	this.allowedValues = ImmutableSet.copyOf(allowedValues);
	Iterator iterator = allowedValues.iterator();

	while (iterator.hasNext())
	{
		IStringSerializable oenum = (IStringSerializable)iterator.next();
		String s1 = oenum.getName();

		if (this.nameToValue.containsKey(s1))
		{
			throw new IllegalArgumentException("Multiple values have the same name \'" + s1 + "\'");
		}

		this.nameToValue.put(s1, oenum);
	}
}
 
Example #3
Source File: CycleButtonWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public <T extends Enum<T> & IStringSerializable> CycleButtonWidget(int xPosition, int yPosition, int width, int height, Class<T> enumClass, Supplier<T> supplier, Consumer<T> updater) {
    super(new Position(xPosition, yPosition), new Size(width, height));
    T[] enumConstantPool = enumClass.getEnumConstants();
    this.optionNames = GTUtility.mapToString(enumConstantPool, it -> ((IStringSerializable) it).getName());
    this.currentOptionSupplier = () -> supplier.get().ordinal();
    this.setOptionExecutor = (newIndex) -> updater.accept(enumConstantPool[newIndex]);
}
 
Example #4
Source File: MachineRecipeLoader.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static <T extends Enum<T> & IStringSerializable> void registerBrickRecipe(StoneBlock<T> stoneBlock, T normalVariant, T brickVariant) {
    ModHandler.addShapedRecipe(stoneBlock.getRegistryName().getResourceDomain() + "_" + normalVariant + "_bricks",
        stoneBlock.getItemVariant(brickVariant, ChiselingVariant.NORMAL, 4),
        "XX", "XX", 'X',
        stoneBlock.getItemVariant(normalVariant, ChiselingVariant.NORMAL));
}
 
Example #5
Source File: PropertyClass.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String getName(Comparable value) {
	return ((IStringSerializable)value).getName();
}