Java源码示例:stanhebben.zenscript.annotations.ZenMethod
示例1
@ZenMethod
public static void removeRecipe(IIngredient[] input) {
ArrayList<Object> converted = new ArrayList<>();
for (IIngredient i : input) {
if (i instanceof IItemStack) {
converted.add(CraftTweakerMC.getItemStack(i));
} else if (i instanceof IOreDictEntry) {
converted.add(new OredictItemStack(((IOreDictEntry) i).getName(), 1));
}
}
RecipeLoader.actions.add(new Removal(converted));
}
示例2
@ZenMethod
public static void AddRecipe(IIngredient input,IItemStack output) {
Object itemInput=null;
if (input instanceof IItemStack) {
itemInput=CraftTweakerMC.getItemStack(input);
}
else if(input instanceof IOreDictEntry) {
itemInput=((IOreDictEntry)input).getName();
}
if(itemInput!=null)
RecipeLoader.actions.add(new Addition(itemInput,CraftTweakerMC.getItemStack(output)));
}
示例3
@ZenMethod
public static void RemoveRecipe(IIngredient input) {
Object itemInput=null;
if (input instanceof IItemStack) {
itemInput=CraftTweakerMC.getItemStack(input);
}
else if(input instanceof IOreDictEntry) {
itemInput=((IOreDictEntry)input).getName();
}
if(itemInput!=null)
RecipeLoader.actions.add(new Removal(itemInput));
}
示例4
@ZenMethod
public static void AddRecipe(IIngredient input,IItemStack output) {
Object itemInput=null;
if (input instanceof IItemStack) {
itemInput=CraftTweakerMC.getItemStack(input);
}
else if(input instanceof IOreDictEntry) {
itemInput=((IOreDictEntry)input).getName();
}
if(itemInput!=null)
RecipeLoader.actions.add(new Addition(itemInput,CraftTweakerMC.getItemStack(output)));
}
示例5
@ZenMethod
public static void RemoveRecipe(IIngredient input) {
Object itemInput=null;
if (input instanceof IItemStack) {
itemInput=CraftTweakerMC.getItemStack(input);
}
else if(input instanceof IOreDictEntry) {
itemInput=((IOreDictEntry)input).getName();
}
if(itemInput!=null)
RecipeLoader.actions.add(new Removal(itemInput));
}
示例6
@ZenMethod
public static void AddRecipe(IIngredient input,IItemStack output) {
Object itemInput=null;
if (input instanceof IItemStack) {
itemInput=CraftTweakerMC.getItemStack(input);
}
else if(input instanceof IOreDictEntry) {
itemInput=((IOreDictEntry)input).getName();
}
if(itemInput!=null)
RecipeLoader.actions.add(new Addition(itemInput,CraftTweakerMC.getItemStack(output)));
}
示例7
@ZenMethod
public static void RemoveRecipe(IIngredient[] input) {
if(input.length>0){
Object[] array = new Object[input.length];
for(int i = 0; i < input.length;i++){
if (input[i] instanceof IItemStack)
array[i]=CraftTweakerMC.getItemStack(input[i]);
else if(input[i] instanceof IOreDictEntry)
array[i]=((IOreDictEntry)input[i]).getName();
}
SakuraRecipeRegister.actions.add(new Removal(array));
}
}
示例8
@Override
@ZenMethod
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MaterialStack that = (MaterialStack) o;
if (amount != that.amount) return false;
return material.equals(that.material);
}
示例9
@ZenMethod
public static void AddRecipe(ILiquidStack input_fluid,IIngredient[] input,ILiquidStack output) {
if(input.length>0){
Object[] array = new Object[input.length];
for(int i = 0; i < input.length;i++){
if (input[i] instanceof IItemStack)
array[i]=CraftTweakerMC.getItemStack(input[i]);
else if(input[i] instanceof IOreDictEntry)
array[i]=((IOreDictEntry)input[i]).getName();
}
SakuraRecipeRegister.actions.add(new Addition(array, CraftTweakerMC.getLiquidStack(output),CraftTweakerMC.getLiquidStack(input_fluid)));
}
}
示例10
@ZenMethod
public static void AddRecipe(IIngredient[] input,IItemStack output,ILiquidStack input_fluid) {
if(input.length>0){
Object[] array = new Object[input.length];
for(int i = 0; i < input.length;i++){
if (input[i] instanceof IItemStack)
array[i]=CraftTweakerMC.getItemStack(input[i]);
else if(input[i] instanceof IOreDictEntry)
array[i]=((IOreDictEntry)input[i]).getName();
}
SakuraRecipeRegister.actions.add(new Addition(array, CraftTweakerMC.getItemStack(output),CraftTweakerMC.getLiquidStack(input_fluid)));
}
}
示例11
@ZenMethod
public static void addBulb(Object input, int color, int energyUsage, int growthModifier, String[] plants, int boostModifier)
{
if (input == null) return;
String itemName = input.toString();
if (plants == null) plants = new String[0];
CraftTweakerAPI.apply(new Add(itemName, color, energyUsage, growthModifier, plants, boostModifier));
}
示例12
@ZenMethod
public static void addRecipe(IItemStack output, Object input)
{
IMachineRecipe recipe = CraftTweakerHelper.getMachineRecipe(output, input);
CraftTweakerAPI.apply(new Add(recipe));
}
示例13
@ZenMethod
public static void addRecipe(IItemStack output, Object input)
{
IMachineRecipe recipe = CraftTweakerHelper.getMachineRecipe(output, input);
CraftTweakerAPI.apply(new Add(recipe));
}
示例14
@ZenMethod
public static void addRecipe(IItemStack output, Object input)
{
IMachineRecipe recipe = CraftTweakerHelper.getMachineRecipe(output, input);
CraftTweakerAPI.apply(new Add(recipe));
}
示例15
@ZenMethod
public void buildAndRegister() {
ValidationResult<PrimitiveBlastFurnaceRecipe> result = build();
if (result.getType() == EnumValidationResult.VALID) {
PrimitiveBlastFurnaceRecipe recipe = result.getResult();
RecipeMaps.PRIMITIVE_BLAST_FURNACE_RECIPES.add(recipe);
}
}
示例16
@ZenMethod
public void addRecipe(FuelRecipe fuelRecipe) {
FluidKey fluidKey = new FluidKey(fuelRecipe.getRecipeFluid());
if (recipeFluidMap.containsKey(fluidKey)) {
FuelRecipe oldRecipe = recipeFluidMap.remove(fluidKey);
recipeList.remove(oldRecipe);
}
recipeFluidMap.put(fluidKey, fuelRecipe);
recipeList.add(fuelRecipe);
}
示例17
@ZenMethod
public void buildAndRegister() {
ValidationResult<CokeOvenRecipe> result = build();
if (result.getType() == EnumValidationResult.VALID) {
CokeOvenRecipe recipe = result.getResult();
RecipeMaps.COKE_OVEN_RECIPES.add(recipe);
}
}
示例18
@ZenMethod
public static void addRecipe(IItemStack output, Object input)
{
IMachineRecipe recipe = CraftTweakerHelper.getMachineRecipe(output, input);
CraftTweakerAPI.apply(new Add(recipe));
}
示例19
@ZenMethod
public static void addRecipe(Object input, int cores)
{
OptimiserRecipe recipe = CraftTweakerHelper.getOptimiserRecipe(input, cores);
CraftTweakerAPI.apply(new Add(recipe));
}
示例20
@ZenMethod
public static void addRecipe(IItemStack output, Object input)
{
IMachineRecipe recipe = CraftTweakerHelper.getMachineRecipe(output, input);
CraftTweakerAPI.apply(new Add(recipe));
}
示例21
@ZenMethod("findRecipe")
@Method(modid = GTValues.MODID_CT)
@Nullable
public CTRecipe ctFindRecipe(long maxVoltage, IItemStack[] itemInputs, ILiquidStack[] fluidInputs, @Optional(valueLong = Integer.MAX_VALUE) int outputFluidTankCapacity) {
List<ItemStack> mcItemInputs = itemInputs == null ? Collections.emptyList() :
Arrays.stream(itemInputs)
.map(CraftTweakerMC::getItemStack)
.collect(Collectors.toList());
List<FluidStack> mcFluidInputs = fluidInputs == null ? Collections.emptyList() :
Arrays.stream(fluidInputs)
.map(CraftTweakerMC::getLiquidStack)
.collect(Collectors.toList());
Recipe backingRecipe = findRecipe(maxVoltage, mcItemInputs, mcFluidInputs, outputFluidTankCapacity);
return backingRecipe == null ? null : new CTRecipe(this, backingRecipe);
}
示例22
@ZenMethod
@Method(modid = GTValues.MODID_CT)
public void generate(long randomSeed, IWorld world, IBlockPos centerPos, IBlockState blockState) {
World mcWorld = CraftTweakerMC.getWorld(world);
net.minecraft.block.state.IBlockState mcBlockState = CraftTweakerMC.getBlockState(blockState);
BlockPos blockPos = CraftTweakerMC.getBlockPos(centerPos);
generate(new Random(randomSeed), (x, y, z) -> mcWorld.setBlockState(blockPos, mcBlockState));
}
示例23
@ZenMethod
public CTRecipeBuilder inputs(IIngredient... ingredients) {
this.backingBuilder.inputsIngredients(Arrays.stream(ingredients)
.map(s -> new CountableIngredient(new CraftTweakerIngredientWrapper(s), s.getAmount()))
.collect(Collectors.toList()));
return this;
}
示例24
@ZenMethod
public static IngotMaterial createIngotMaterial(int metaItemSubId, String name, int color, String iconSet, int harvestLevel, @Optional MaterialStack[] materialComponents, @Optional float toolSpeed, @Optional float attackDamage, @Optional int toolDurability, @Optional int blastFurnaceTemperature) {
return new IngotMaterial(metaItemSubId, name, color,
MaterialIconSet.getByName(iconSet), harvestLevel,
validateComponentList(materialComponents), 0, null,
Math.max(0.0f, toolSpeed), Math.max(0.0f, attackDamage), Math.max(0, toolDurability), blastFurnaceTemperature);
}
示例25
@ZenMethod("getBiomeWeightModifier")
@Method(modid = GTValues.MODID_CT)
public int ctGetBiomeWeightModifier(IBiome biome) {
int biomeIndex = ArrayUtils.indexOf(CraftTweakerMC.biomes, biome);
Biome mcBiome = Biome.REGISTRY.getObjectById(biomeIndex);
return mcBiome == null ? 0 : getBiomeWeightModifier().apply(mcBiome);
}
示例26
@ZenMethod
public CTRecipeBuilder property(String key, int value) {
boolean applied = this.backingBuilder.applyProperty(key, value);
if (!applied) {
throw new IllegalArgumentException("Property " +
key + " cannot be applied to recipe type " +
backingBuilder.getClass().getSimpleName());
}
return this;
}
示例27
@ZenMethod("addToolEnchantment")
@Method(modid = GTValues.MODID_CT)
public void ctAddEnchantmentForTools(IEnchantment enchantment) {
Enchantment enchantmentType = (Enchantment) enchantment.getDefinition().getInternal();
toolEnchantments.add(new EnchantmentData(enchantmentType, enchantment.getLevel()));
}
示例28
@ZenMethod
public static void clearAllRecipe() {
RecipeLoader.actions.add(new ClearAllRecipe());
}
示例29
@ZenMethod
public static DustMaterial createDustMaterial(int metaItemSubId, String name, int color, String iconSet, int harvestLevel, @Optional MaterialStack[] materialComponents) {
return new DustMaterial(metaItemSubId, name, color,
MaterialIconSet.getByName(iconSet), harvestLevel,
validateComponentList(materialComponents), 0);
}
示例30
@ZenMethod
public static void remove(PrimitiveBlastFurnaceRecipe recipe) {
RecipeMaps.getPrimitiveBlastFurnaceRecipes().remove(recipe);
}