Formatted code
This commit is contained in:
@@ -18,97 +18,82 @@
|
||||
|
||||
package appeng.hooks;
|
||||
|
||||
|
||||
// TODO Villager Trading!??!?!
|
||||
|
||||
public class AETrading
|
||||
{
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void manipulateTradesForVillager( EntityVillager villager, MerchantRecipeList recipeList, Random random )
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
* @Override
|
||||
* public void manipulateTradesForVillager( EntityVillager villager, MerchantRecipeList recipeList, Random random )
|
||||
* {
|
||||
* final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
* this.addMerchant( recipeList, materials.silicon(), 1, random, 2 );
|
||||
* this.addMerchant( recipeList, materials.certusQuartzCrystal(), 2, random, 4 );
|
||||
* this.addMerchant( recipeList, materials.certusQuartzDust(), 1, random, 3 );
|
||||
* this.addTrade( recipeList, materials.certusQuartzDust(), materials.certusQuartzCrystal(), random, 2 );
|
||||
* }
|
||||
* private void addMerchant( MerchantRecipeList list, IItemDefinition item, int emera, Random rand, int greed )
|
||||
* {
|
||||
* for( ItemStack itemStack : item.maybeStack( 1 ).asSet() )
|
||||
* {
|
||||
* // Sell
|
||||
* ItemStack from = itemStack.copy();
|
||||
* ItemStack to = new ItemStack( Items.emerald );
|
||||
* int multiplier = ( Math.abs( rand.nextInt() ) % 6 );
|
||||
* final int emeraldCost = emera + ( Math.abs( rand.nextInt() ) % greed ) - multiplier;
|
||||
* int mood = rand.nextInt() % 2;
|
||||
* from.stackSize = multiplier + mood;
|
||||
* to.stackSize = multiplier * emeraldCost - mood;
|
||||
* if( to.stackSize < 0 )
|
||||
* {
|
||||
* from.stackSize -= to.stackSize;
|
||||
* to.stackSize -= to.stackSize;
|
||||
* }
|
||||
* this.addToList( list, from, to );
|
||||
* // Buy
|
||||
* ItemStack reverseTo = from.copy();
|
||||
* ItemStack reverseFrom = to.copy();
|
||||
* reverseFrom.stackSize *= rand.nextFloat() * 3.0f + 1.0f;
|
||||
* this.addToList( list, reverseFrom, reverseTo );
|
||||
* }
|
||||
* }
|
||||
* private void addTrade( MerchantRecipeList list, IItemDefinition inputDefinition, IItemDefinition
|
||||
* outputDefinition, Random rand, int conversionVariance )
|
||||
* {
|
||||
* final Optional<ItemStack> maybeInputStack = inputDefinition.maybeStack( 1 );
|
||||
* final Optional<ItemStack> maybeOutputStack = outputDefinition.maybeStack( 1 );
|
||||
* if( maybeInputStack.isPresent() && maybeOutputStack.isPresent() )
|
||||
* {
|
||||
* // Sell
|
||||
* ItemStack inputStack = maybeInputStack.get().copy();
|
||||
* ItemStack outputStack = maybeOutputStack.get().copy();
|
||||
* inputStack.stackSize = 1 + ( Math.abs( rand.nextInt() ) % ( 1 + conversionVariance ) );
|
||||
* outputStack.stackSize = 1;
|
||||
* this.addToList( list, inputStack, outputStack );
|
||||
* }
|
||||
* }
|
||||
* private void addToList( MerchantRecipeList l, ItemStack a, ItemStack b )
|
||||
* {
|
||||
* if( a.stackSize < 1 )
|
||||
* {
|
||||
* a.stackSize = 1;
|
||||
* }
|
||||
* if( b.stackSize < 1 )
|
||||
* {
|
||||
* b.stackSize = 1;
|
||||
* }
|
||||
* if( a.stackSize > a.getMaxStackSize() )
|
||||
* {
|
||||
* a.stackSize = a.getMaxStackSize();
|
||||
* }
|
||||
* if( b.stackSize > b.getMaxStackSize() )
|
||||
* {
|
||||
* b.stackSize = b.getMaxStackSize();
|
||||
* }
|
||||
* l.add( new MerchantRecipe( a, b ) );
|
||||
* }
|
||||
*/
|
||||
|
||||
this.addMerchant( recipeList, materials.silicon(), 1, random, 2 );
|
||||
this.addMerchant( recipeList, materials.certusQuartzCrystal(), 2, random, 4 );
|
||||
this.addMerchant( recipeList, materials.certusQuartzDust(), 1, random, 3 );
|
||||
|
||||
this.addTrade( recipeList, materials.certusQuartzDust(), materials.certusQuartzCrystal(), random, 2 );
|
||||
}
|
||||
|
||||
private void addMerchant( MerchantRecipeList list, IItemDefinition item, int emera, Random rand, int greed )
|
||||
{
|
||||
for( ItemStack itemStack : item.maybeStack( 1 ).asSet() )
|
||||
{
|
||||
// Sell
|
||||
ItemStack from = itemStack.copy();
|
||||
ItemStack to = new ItemStack( Items.emerald );
|
||||
|
||||
int multiplier = ( Math.abs( rand.nextInt() ) % 6 );
|
||||
final int emeraldCost = emera + ( Math.abs( rand.nextInt() ) % greed ) - multiplier;
|
||||
int mood = rand.nextInt() % 2;
|
||||
|
||||
from.stackSize = multiplier + mood;
|
||||
to.stackSize = multiplier * emeraldCost - mood;
|
||||
|
||||
if( to.stackSize < 0 )
|
||||
{
|
||||
from.stackSize -= to.stackSize;
|
||||
to.stackSize -= to.stackSize;
|
||||
}
|
||||
|
||||
this.addToList( list, from, to );
|
||||
|
||||
// Buy
|
||||
ItemStack reverseTo = from.copy();
|
||||
ItemStack reverseFrom = to.copy();
|
||||
|
||||
reverseFrom.stackSize *= rand.nextFloat() * 3.0f + 1.0f;
|
||||
|
||||
this.addToList( list, reverseFrom, reverseTo );
|
||||
}
|
||||
}
|
||||
|
||||
private void addTrade( MerchantRecipeList list, IItemDefinition inputDefinition, IItemDefinition outputDefinition, Random rand, int conversionVariance )
|
||||
{
|
||||
final Optional<ItemStack> maybeInputStack = inputDefinition.maybeStack( 1 );
|
||||
final Optional<ItemStack> maybeOutputStack = outputDefinition.maybeStack( 1 );
|
||||
|
||||
if( maybeInputStack.isPresent() && maybeOutputStack.isPresent() )
|
||||
{
|
||||
// Sell
|
||||
ItemStack inputStack = maybeInputStack.get().copy();
|
||||
ItemStack outputStack = maybeOutputStack.get().copy();
|
||||
|
||||
inputStack.stackSize = 1 + ( Math.abs( rand.nextInt() ) % ( 1 + conversionVariance ) );
|
||||
outputStack.stackSize = 1;
|
||||
|
||||
this.addToList( list, inputStack, outputStack );
|
||||
}
|
||||
}
|
||||
|
||||
private void addToList( MerchantRecipeList l, ItemStack a, ItemStack b )
|
||||
{
|
||||
if( a.stackSize < 1 )
|
||||
{
|
||||
a.stackSize = 1;
|
||||
}
|
||||
if( b.stackSize < 1 )
|
||||
{
|
||||
b.stackSize = 1;
|
||||
}
|
||||
|
||||
if( a.stackSize > a.getMaxStackSize() )
|
||||
{
|
||||
a.stackSize = a.getMaxStackSize();
|
||||
}
|
||||
if( b.stackSize > b.getMaxStackSize() )
|
||||
{
|
||||
b.stackSize = b.getMaxStackSize();
|
||||
}
|
||||
|
||||
l.add( new MerchantRecipe( a, b ) );
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user