aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-07-06 20:25:58 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-07-06 20:25:58 +1000
commit6f3593f3d510458eaec3e97fa770b4d2a3cb241d (patch)
tree969178370160c3cb5c4a16848d287e229e47be7d /src/Java
parent3e36708d9ad60fbc23ece6ccdb431e3ad5b3cfb2 (diff)
downloadGT5-Unofficial-6f3593f3d510458eaec3e97fa770b4d2a3cb241d.tar.gz
GT5-Unofficial-6f3593f3d510458eaec3e97fa770b4d2a3cb241d.tar.bz2
GT5-Unofficial-6f3593f3d510458eaec3e97fa770b4d2a3cb241d.zip
+ Gave Aboriginal villagers some broad trade options.
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/Core_VillagerAdditions.java3
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java107
2 files changed, 109 insertions, 1 deletions
diff --git a/src/Java/gtPlusPlus/plugin/villagers/Core_VillagerAdditions.java b/src/Java/gtPlusPlus/plugin/villagers/Core_VillagerAdditions.java
index e4048162e4..8a637a3b76 100644
--- a/src/Java/gtPlusPlus/plugin/villagers/Core_VillagerAdditions.java
+++ b/src/Java/gtPlusPlus/plugin/villagers/Core_VillagerAdditions.java
@@ -20,6 +20,7 @@ import gtPlusPlus.core.util.Utils;
import gtPlusPlus.plugin.manager.Core_Manager;
import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner;
import gtPlusPlus.plugin.villagers.entity.EntityBaseVillager;
+import gtPlusPlus.plugin.villagers.trade.TradeHandlerAboriginal;
import gtPlusPlus.plugin.villagers.trade.TradeHandlerBanker;
import gtPlusPlus.plugin.villagers.trade.TradeHandlerTechnician;
import gtPlusPlus.plugin.villagers.trade.TradeHandlerTrader;
@@ -50,7 +51,7 @@ public class Core_VillagerAdditions implements IPlugin {
VillagerUtils.registerNewVillager(0, "Banker", "Banker", "Banker", "banker", new TradeHandlerBanker());
VillagerUtils.registerNewVillager(1, "Technician", "Technician", "Technician", "technician", new TradeHandlerTechnician());
VillagerUtils.registerNewVillager(2, "Trader", "Trader", "Trader", "trader", new TradeHandlerTrader());
- VillagerUtils.registerNewVillager(3, "Aboriginal", "Aboriginal", "Aboriginal", "aboriginal", new TradeHandlerTrader());
+ VillagerUtils.registerNewVillager(3, "Aboriginal", "Aboriginal", "Aboriginal", "aboriginal", new TradeHandlerAboriginal());
if (mVillagerMap.size() > 0) {
for (VillagerObject g : mVillagerMap.values()) {
diff --git a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java
new file mode 100644
index 0000000000..ef67543f47
--- /dev/null
+++ b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java
@@ -0,0 +1,107 @@
+package gtPlusPlus.plugin.villagers.trade;
+
+import static java.util.Collections.shuffle;
+
+import java.util.Collections;
+import java.util.Random;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.material.ELEMENT;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.village.MerchantRecipe;
+import net.minecraft.village.MerchantRecipeList;
+
+public class TradeHandlerAboriginal extends TradeHandlerBase {
+
+ private final static AutoMap<ItemStack> mOutputs = new AutoMap<ItemStack>();
+ private static boolean initialised = false;
+
+ public static void init() {
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.anvil, 1));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.bookshelf, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.cactus, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.dirt, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.cobblestone, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.mossy_cobblestone, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.pumpkin, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.hardened_clay, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.log, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.obsidian, 8));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.wheat, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.gravel, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Blocks.sand, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.apple, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.emerald, 1));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.diamond, 1));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.baked_potato, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.beef, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.bone, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.bread, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.carrot, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.potato, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.poisonous_potato, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.chicken, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.porkchop, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.cooked_beef, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.cooked_chicken, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.cooked_porkchop, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.fish, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.cooked_fished, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.feather, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.egg, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.gold_nugget, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.leather, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.melon_seeds, 0));
+ mOutputs.put(ItemUtils.getSimpleStack(Items.reeds, 0));
+ initialised = true;
+ }
+
+
+ public TradeHandlerAboriginal() {
+ Logger.INFO("Created Trade Manager for 'Trader' villager profession type.");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
+ if (!initialised) {
+ init();
+ }
+ if (initialised) {
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.wooden_door, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.log, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.log2, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.planks, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.sapling, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.sandstone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.nether_brick, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.bookshelf, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.crafting_table, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.gravel, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.hardened_clay, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.cactus, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.quartz_block, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.stone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.mossy_cobblestone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput()));
+ shuffle(recipeList);
+ shuffle(recipeList);
+ shuffle(recipeList);
+ shuffle(recipeList);
+ shuffle(recipeList);
+ shuffle(recipeList);
+ }
+ }
+
+ private ItemStack getOutput() {
+ ItemStack output = mOutputs.get(MathUtils.randInt(0, mOutputs.size()-1));
+ int outputSize = (output.stackSize == 0 ? (MathUtils.randInt(MathUtils.randInt(0, 8), MathUtils.randInt(4, 32))) : output.stackSize);
+ return ItemUtils.getSimpleStack(output, outputSize);
+ }
+
+}