Skip to content

Commit

Permalink
Migrate new 1.7 villager trades, fix ic2 uid
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirek-K committed Jun 8, 2016
1 parent 68fb274 commit f97a737
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lang
20 changes: 18 additions & 2 deletions src/main/java/forestry/apiculture/PluginApiculture.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,18 @@ public void doInit() {
villagerRegistry.register(villagerApiarist);

ItemStack wildcardPrincess = new ItemStack(items.beePrincessGE, 1);
ItemStack wildcardDrone = new ItemStack(items.beeDroneGE, 1);
ItemStack apiary = new ItemStack(blocks.apiary);
ItemStack provenFrames = items.frameProven.getItemStack();
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE);
ItemStack propolis = new ItemStack(PluginApiculture.items.propolis,1);
ItemStack forestDrone = BeeDefinition.FOREST.getMemberStack(EnumBeeType.DRONE);
ItemStack meadowsDrone = BeeDefinition.MEADOWS.getMemberStack(EnumBeeType.DRONE);
ItemStack modestDrone = BeeDefinition.MODEST.getMemberStack(EnumBeeType.DRONE);
ItemStack tropicalDrone = BeeDefinition.TROPICAL.getMemberStack(EnumBeeType.DRONE);
ItemStack wintryDrone = BeeDefinition.WINTRY.getMemberStack(EnumBeeType.DRONE);
ItemStack marshyDrone = BeeDefinition.MARSHY.getMemberStack(EnumBeeType.DRONE);

VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist");
apiaristCareer.addTrade(1,
Expand All @@ -291,10 +300,17 @@ public void doInit() {
);
apiaristCareer.addTrade(3,
new VillagerTradeLists.GiveEmeraldForItems(wildcardPrincess, null),
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6))
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6)),
new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), forestDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), meadowsDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), modestDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), tropicalDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), wintryDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), marshyDrone, null)
);
apiaristCareer.addTrade(4,
new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null)
new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(wildcardPrincess, null,new ItemStack(Items.ENDER_EYE),new EntityVillager.PriceInfo(12, 16),endDrone, null)
);
}

Expand Down
55 changes: 55 additions & 0 deletions src/main/java/forestry/core/utils/VillagerTradeLists.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,59 @@ public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random rando
recipeList.add(new MerchantRecipe(randomLog, new ItemStack(Items.EMERALD, emeraldsAmount), itemToSell));
}
}
public static class GiveItemForTwoItems implements EntityVillager.ITradeList {
@Nonnull
public ItemStack buyingItemStack;
@Nullable
public EntityVillager.PriceInfo buyingPriceInfo;
@Nonnull
public ItemStack buyingItemStackTwo;
@Nullable
public EntityVillager.PriceInfo buyingItemTwoInfo;
@Nonnull
public ItemStack sellingItemstack;
@Nullable
public EntityVillager.PriceInfo sellingPriceInfo;

public GiveItemForTwoItems(
@Nonnull ItemStack buyingItemStack,
@Nullable EntityVillager.PriceInfo buyingPriceInfo,
@Nonnull ItemStack buyingItemStackTwo,
@Nullable EntityVillager.PriceInfo buyingItemTwoInfo,
@Nonnull ItemStack sellingItemstack,
@Nullable EntityVillager.PriceInfo sellingPriceInfo) {
this.buyingItemStack = buyingItemStack;
this.buyingPriceInfo = buyingPriceInfo;
this.buyingItemStackTwo = buyingItemStackTwo;
this.buyingItemTwoInfo = buyingItemTwoInfo;
this.sellingItemstack = sellingItemstack;
this.sellingPriceInfo = sellingPriceInfo;
}

@Override
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
int buyAmount = 1;
if (this.buyingPriceInfo != null) {
buyAmount = this.buyingPriceInfo.getPrice(random);
}

int buyTwoAmount = 1;
if (this.buyingItemTwoInfo != null) {
buyTwoAmount = this.buyingItemTwoInfo.getPrice(random);
}

int sellAmount = 1;
if (this.sellingPriceInfo != null) {
sellAmount = this.sellingPriceInfo.getPrice(random);
}

ItemStack buyItemStack = this.buyingItemStack.copy();
buyItemStack.stackSize = buyAmount;
ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy();
buyItemStackTwo.stackSize = buyTwoAmount;
ItemStack sellItemStack = this.sellingItemstack.copy();
sellItemStack.stackSize = sellAmount;
recipeList.add(new MerchantRecipe(buyItemStack, buyItemStackTwo, sellItemStack));
}
}
}
1 change: 1 addition & 0 deletions src/main/java/forestry/plugins/ForestryPluginUids.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ public class ForestryPluginUids {
public static final String BUILDCRAFT_TRANSPORT = "forestry.buildcraft.transport";
public static final String CHISEL = "forestry.chisel";
public static final String NATURA = "forestry.natura";
public static final String INDUSTRIALCRAFT2 = "forestry.industrialcraft2";
}
2 changes: 1 addition & 1 deletion src/main/java/forestry/plugins/compat/PluginIC2.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.Recipes;

@ForestryPlugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description")
@ForestryPlugin(pluginID = ForestryPluginUids.INDUSTRIALCRAFT2, name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description")
public class PluginIC2 extends BlankForestryPlugin {
public static final String modId = "IC2";
public static PluginIC2 instance;
Expand Down

0 comments on commit f97a737

Please sign in to comment.