aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/plugin/villagers/trade
diff options
context:
space:
mode:
authoriouter <62897714+iouter@users.noreply.github.com>2022-01-07 12:36:06 +0800
committerGitHub <noreply@github.com>2022-01-07 12:36:06 +0800
commit0834d4b8b45a881f36ed5b295ac0fb38df49fa9a (patch)
tree6fb4a45cf17dd22748148417bc7bb0efb850cea3 /src/main/java/gtPlusPlus/plugin/villagers/trade
parentea1439a4195c8f77c45625ea2593a232bf19984e (diff)
parent9b2e050151ad93170e84321d067d1e9d4ded4ba5 (diff)
downloadGT5-Unofficial-0834d4b8b45a881f36ed5b295ac0fb38df49fa9a.tar.gz
GT5-Unofficial-0834d4b8b45a881f36ed5b295ac0fb38df49fa9a.tar.bz2
GT5-Unofficial-0834d4b8b45a881f36ed5b295ac0fb38df49fa9a.zip
Merge branch 'GTNewHorizons:master' into master
Diffstat (limited to 'src/main/java/gtPlusPlus/plugin/villagers/trade')
-rw-r--r--src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java161
-rw-r--r--src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java27
-rw-r--r--src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBase.java25
-rw-r--r--src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java27
-rw-r--r--src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java45
5 files changed, 285 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java
new file mode 100644
index 0000000000..3baca10792
--- /dev/null
+++ b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java
@@ -0,0 +1,161 @@
+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> mInputs = new AutoMap<ItemStack>();
+ 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));
+ mInputs.put(ItemUtils.getSimpleStack(Items.wooden_door));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.log));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.log2));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.planks));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.sapling));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.sandstone));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.nether_brick));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.bookshelf));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.crafting_table));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.gravel));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.hardened_clay));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.cactus));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.quartz_block));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.stone));
+ mInputs.put(ItemUtils.getSimpleStack(Blocks.mossy_cobblestone));
+ mInputs.put(ItemUtils.getSimpleStack(Items.apple, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.emerald, 1));
+ mInputs.put(ItemUtils.getSimpleStack(Items.diamond, 1));
+ mInputs.put(ItemUtils.getSimpleStack(Items.baked_potato, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.beef, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.bone, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.bread, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.carrot, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.potato, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.poisonous_potato, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.chicken, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.porkchop, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.cooked_beef, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.cooked_chicken, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.cooked_porkchop, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.fish, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.cooked_fished, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.feather, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.egg, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.gold_nugget, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.leather, 0));
+ mInputs.put(ItemUtils.getSimpleStack(Items.melon_seeds, 0));
+ mInputs.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(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ recipeList.add(new MerchantRecipe(getInput(), getInput(), getOutput()));
+ shuffle(recipeList);
+ }
+ }
+
+ private ItemStack getInput() {
+ ItemStack input = mInputs.get(MathUtils.randInt(0, mInputs.size()-1));
+ int outputSize = (input.stackSize == 0 ? (Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))) : input.stackSize);
+ return ItemUtils.getSimpleStack(input, outputSize);
+ }
+
+ final static int MID_BOUND = 24;
+ private ItemStack getOutput() {
+ ItemStack output = mOutputs.get(MathUtils.randInt(0, mOutputs.size()-1));
+ int outputSize = (output.stackSize == 0 ? (Math.min(MathUtils.randInt(MathUtils.randInt(1, MID_BOUND), MathUtils.randInt(MID_BOUND, 32)), MathUtils.randInt(MathUtils.randInt(12, MID_BOUND), MathUtils.randInt(MID_BOUND, 48)))) : output.stackSize);
+ return ItemUtils.getSimpleStack(output, outputSize);
+ }
+
+}
diff --git a/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java
new file mode 100644
index 0000000000..215dc0683b
--- /dev/null
+++ b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java
@@ -0,0 +1,27 @@
+package gtPlusPlus.plugin.villagers.trade;
+
+import java.util.Collections;
+import java.util.Random;
+
+import gtPlusPlus.core.recipe.common.CI;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.village.MerchantRecipe;
+import net.minecraft.village.MerchantRecipeList;
+
+public class TradeHandlerBanker extends TradeHandlerBase {
+
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
+ //if (villager.getProfession() == 7735) {
+ recipeList.add(new MerchantRecipe(CI.electricMotor_LV, CI.electricPiston_LV, CI.robotArm_LV));
+ recipeList.add(new MerchantRecipe(CI.electricMotor_MV, CI.electricPiston_MV, CI.robotArm_MV));
+ recipeList.add(new MerchantRecipe(CI.electricMotor_HV, CI.electricPiston_HV, CI.robotArm_HV));
+ recipeList.add(new MerchantRecipe(CI.electricMotor_EV, CI.electricPiston_EV, CI.robotArm_EV));
+ recipeList.add(new MerchantRecipe(CI.electricMotor_IV, CI.electricPiston_IV, CI.robotArm_IV));
+ //Collections.shuffle(recipeList);
+ //}
+ }
+
+}
diff --git a/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBase.java b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBase.java
new file mode 100644
index 0000000000..b726ebefff
--- /dev/null
+++ b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBase.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 SirSengir.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser Public License v3
+ * which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl-3.0.txt
+ *
+ * Various Contributors including, but not limited to:
+ * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
+ ******************************************************************************/
+package gtPlusPlus.plugin.villagers.trade;
+
+import java.util.Random;
+
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.village.MerchantRecipeList;
+import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
+
+public abstract class TradeHandlerBase implements IVillageTradeHandler {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public abstract void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random);
+
+}
diff --git a/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java
new file mode 100644
index 0000000000..922316b136
--- /dev/null
+++ b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java
@@ -0,0 +1,27 @@
+package gtPlusPlus.plugin.villagers.trade;
+
+import java.util.Collections;
+import java.util.Random;
+
+import gtPlusPlus.core.recipe.common.CI;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.village.MerchantRecipe;
+import net.minecraft.village.MerchantRecipeList;
+
+public class TradeHandlerTechnician extends TradeHandlerBase {
+
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
+ //if (villager.getProfession() == 7737) {
+ recipeList.add(new MerchantRecipe(CI.machineHull_LV, CI.electricMotor_LV, CI.machineHull_LV));
+ recipeList.add(new MerchantRecipe(CI.machineHull_MV, CI.electricMotor_MV, CI.machineHull_MV));
+ recipeList.add(new MerchantRecipe(CI.machineHull_HV, CI.electricMotor_HV, CI.machineHull_HV));
+ recipeList.add(new MerchantRecipe(CI.machineHull_EV, CI.electricMotor_EV, CI.machineHull_EV));
+ recipeList.add(new MerchantRecipe(CI.machineHull_IV, CI.electricMotor_IV, CI.machineHull_IV));
+ //Collections.shuffle(recipeList);
+ //}
+ }
+
+}
diff --git a/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java
new file mode 100644
index 0000000000..0025c054bd
--- /dev/null
+++ b/src/main/java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java
@@ -0,0 +1,45 @@
+package gtPlusPlus.plugin.villagers.trade;
+
+import java.util.Collections;
+import java.util.Random;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.material.ELEMENT;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraft.village.MerchantRecipe;
+import net.minecraft.village.MerchantRecipeList;
+
+public class TradeHandlerTrader extends TradeHandlerBase {
+
+ public TradeHandlerTrader() {
+ Logger.INFO("Created Trade Manager for 'Trader' villager profession type.");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
+ ItemStack Ore1 = null, Ore2 = null;
+ if (Ore1 == null) {
+ Ore1 = ELEMENT.getInstance().SILICON.getOre(1);
+ }
+ if (Ore2 == null) {
+ Ore2 = ELEMENT.getInstance().ALUMINIUM.getOre(1);
+ }
+ if (Ore1 == null) {
+ Ore1 = ELEMENT.getInstance().GOLD.getOre(1);
+ }
+ if (Ore2 == null) {
+ Ore2 = ELEMENT.getInstance().LEAD.getOre(1);
+ }
+ recipeList.add(new MerchantRecipe(ItemUtils.getItemStackOfAmountFromOreDict("logWood", 32), ELEMENT.getInstance().IRON.getOre(1)));
+ recipeList.add(new MerchantRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 32), ELEMENT.getInstance().COPPER.getOre(1)));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.obsidian, 6), ELEMENT.getInstance().TIN.getOre(1)));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.glowstone, 32), Ore1));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.piston, 32), Ore2));
+ Collections.shuffle(recipeList);
+ }
+
+}