aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-07-05 20:35:43 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-07-05 20:35:43 +1000
commit3302e20803b5259ae2a8d4cc9e297240f8caf167 (patch)
tree8b135d514a32106f148c92a23cbf56bc0f12faec /src
parent4a9e0f9ded8c4f2ed8a0ba3e1d32724887f6c3be (diff)
downloadGT5-Unofficial-3302e20803b5259ae2a8d4cc9e297240f8caf167.tar.gz
GT5-Unofficial-3302e20803b5259ae2a8d4cc9e297240f8caf167.tar.bz2
GT5-Unofficial-3302e20803b5259ae2a8d4cc9e297240f8caf167.zip
+ Added in a Villager Replacer.
$ More work fixing the recipe system. $ Fixed Villagers not using the correct custom trades. % Changed the Industrial sifter requiring exact amounts of in/output busses.
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java99
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java123
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/VillagerEventHandler.java47
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/VillagerObject.java2
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java269
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java6
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java6
-rw-r--r--src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java26
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java2
9 files changed, 422 insertions, 158 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java
new file mode 100644
index 0000000000..a81bd8f340
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java
@@ -0,0 +1,99 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+
+public class ShapedRecipe {
+
+ private final static String CHARS = "abcdefghijklmnop";
+ public final ShapedOreRecipe mRecipe;
+
+ public ShapedRecipe(
+ Object aInput1, Object aInput2, Object aInput3,
+ Object aInput4, Object aInput5, Object aInput6,
+ Object aInput7, Object aInput8, Object aInput9,
+ ItemStack aOutput) {
+
+ this(new Object[] {aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9}, aOutput);
+
+ }
+
+ public ShapedRecipe(Object[] aInputs, ItemStack aOutput) {
+ char shape[] = new char[9];
+ String aGridWhole = "";
+ String aGrid[] = new String[3];
+
+ //Build a Pair for each slot
+ AutoMap<Pair<Character, Object>> aRecipePairs = new AutoMap<Pair<Character, Object>>();
+ int aCharSlot = 0;
+ for (Object stack : aInputs) {
+ if (stack != null) {
+ aRecipePairs.put(new Pair<Character, Object>(CHARS.charAt(aCharSlot++), stack));
+ }
+ else {
+ aRecipePairs.put(new Pair<Character, Object>(' ', (ItemStack) null));
+ }
+ }
+
+ //If we have enough valid slots, iterate them and build a String which represents the entire grid.
+ //If this String is the correct length, we will split it into thirds and build the grid String array.
+ if (aRecipePairs.size() == 9) {
+ for (Pair<Character, Object> h : aRecipePairs) {
+ if (h.getKey() != null) {
+ aGridWhole += String.valueOf(h.getKey());
+ }
+ }
+ if (aGridWhole.length() == 9) {
+ aGrid[0] = ""+aGridWhole.charAt(0)+aGridWhole.charAt(1)+aGridWhole.charAt(2);
+ aGrid[1] = ""+aGridWhole.charAt(3)+aGridWhole.charAt(4)+aGridWhole.charAt(5);
+ aGrid[2] = ""+aGridWhole.charAt(6)+aGridWhole.charAt(7)+aGridWhole.charAt(8);
+ }
+ }
+
+ //Rebuild the Map without spaces
+ aRecipePairs.clear();
+ aCharSlot = 0;
+ int counter = 3;
+ for (Object stack : aInputs) {
+ if (stack != null) {
+ aRecipePairs.put(new Pair<Character, Object>(CHARS.charAt(aCharSlot++), stack));
+ counter++;
+ }
+ }
+
+ //Register the shaped grid straight to the varags
+ Object[] mVarags2 = new Object[counter];
+ mVarags2[0] = aGrid[0];
+ mVarags2[1] = aGrid[1];
+ mVarags2[2] = aGrid[2];
+
+ //Add Each Char, then Item to the varags, sequentially.
+ int counter2 = 3;
+ for (Pair<Character, Object> r : aRecipePairs) {
+ char c = r.getKey();
+ Object o = r.getValue();
+ mVarags2[counter2] = (char) c;
+ mVarags2[counter2+1] = o;
+ counter2 += 2;
+ }
+
+ //Try set the recipe for this object.
+ ShapedOreRecipe testRecipe = null;
+ try {
+ testRecipe = new ShapedOreRecipe(aOutput, mVarags2);
+ }
+ catch (Throwable t) {
+
+ }
+ if (testRecipe == null) {
+ this.mRecipe = null;
+ }
+ else {
+ this.mRecipe = testRecipe;
+ }
+
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java
index 7fcaf0d73a..2ec7598f4c 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java
@@ -17,6 +17,7 @@ import gregtech.api.util.GT_Recipe;
import gtPlusPlus.api.interfaces.RunnableWithInfo;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.minecraft.ShapedRecipe;
import gtPlusPlus.core.handler.COMPAT_HANDLER;
import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler;
import gtPlusPlus.core.handler.Recipes.RegistrationHandler;
@@ -28,19 +29,21 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
public class RecipeUtils {
- public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, final ItemStack resultItem){
+ public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, ItemStack resultItem){
final ArrayList<Object> validSlots = new ArrayList<>();
if (resultItem == null){
- Logger.WARNING("Found a recipe with an invalid output, yet had a valid inputs. Skipping.");
- return false;
+ Logger.WARNING("Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found..");
+ resultItem = ItemUtils.getItemStackOfAmountFromOreDict("givemeabrokenitem", 1);
+ RegistrationHandler.recipesFailed++;
+ //return false;
}
if ((slot_1 == null) && (slot_2 == null) && (slot_3 == null) &&
(slot_4 == null) && (slot_5 == null) && (slot_6 == null) &&
(slot_7 == null) && (slot_8 == null) && (slot_9 == null)){
- Logger.WARNING("Found a recipe with 0 inputs, yet had a valid output.");
- Logger.WARNING("Error found while adding a recipe for: "+resultItem.getDisplayName()+" | Please report this issue on Github.");
+ Logger.INFO("Found a recipe with 0 inputs, yet had a valid output.");
+ Logger.INFO("Error found while adding a recipe for: "+resultItem.getDisplayName()+" | Please report this issue on Github.");
RegistrationHandler.recipesFailed++;
return false;
}
@@ -138,7 +141,7 @@ public class RecipeUtils {
//k.getClass();
//k.printStackTrace();
//k.getLocalizedMessage();
- Logger.INFO("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName());
+ Logger.INFO("@@@: Invalid Recipe detected for: "+resultItem != null ? resultItem.getUnlocalizedName() : "INVALID OUTPUT ITEM");
if (!COMPAT_HANDLER.areInitItemsLoaded){
RegistrationHandler.recipesFailed++;
}
@@ -545,7 +548,7 @@ public class RecipeUtils {
public InternalRecipeObject(Object[] aInputs, ItemStack aOutput, boolean gtRecipe) {
mOutput = aOutput != null ? aOutput.copy() : null;
- String line1 = "", line2 = "", line3 = "";
+ /*String line1 = "", line2 = "", line3 = "";
String h = "abcdefghi";
char blank = ' ';
int counter = 0;
@@ -601,15 +604,36 @@ public class RecipeUtils {
Object[] mVarags = new Object[18];
int mSlotCount = 0;
+
+ ItemStack[] a32 = new ItemStack[9];
+ char[] a16 = new char[9];
- for (int i=0;i<9;i++) {
- if (s[i] != ' ') {
- mVarags[mSlotCount] = String.valueOf(s[i]);
- }
- if (vInputs[i] != null) {
- mVarags[mSlotCount+1] = vInputs[i];
- }
- mSlotCount += 2;
+ for (mSlotCount=0;mSlotCount<9;mSlotCount++) {
+ if (mSlotCount >= vInputs.length-1) {
+ mVarags[mSlotCount] = String.valueOf(blank);
+ a16[mSlotCount] = blank;
+ mVarags[mSlotCount+1] = (ItemStack) null;
+ a32[mSlotCount] = (ItemStack) null;
+ }
+ else {
+ if (s[mSlotCount] != ' ') {
+ mVarags[mSlotCount] = String.valueOf(s[mSlotCount]);
+ a16[mSlotCount] = Character.valueOf(s[mSlotCount]);
+ }
+ else {
+ mVarags[mSlotCount] = String.valueOf(blank);
+ a16[mSlotCount] = blank;
+ }
+ if (vInputs[mSlotCount] != null) {
+ mVarags[mSlotCount+1] = vInputs[mSlotCount].copy();
+ a32[mSlotCount] = vInputs[mSlotCount].copy();
+ }
+ else {
+ mVarags[mSlotCount+1] = (ItemStack) null;
+ a32[mSlotCount] = (ItemStack) null;
+ }
+ }
+
}
int nullCount = 0;
@@ -619,27 +643,76 @@ public class RecipeUtils {
nullCount++;
}
}
- Object[] mVarags2 = new Object[mVarags.length-nullCount];
- for (int i=0;i<(mVarags.length-nullCount);i++) {
- mVarags2[i] = mVarags[i];
+ Object[] mVarags2 = new Object[mVarags.length-nullCount+3];
+ mVarags2[0]=line1;
+ mVarags2[1]=line2;
+ mVarags2[2]=line3;
+ for (int i=3;i<(mVarags.length-nullCount+3);i++) {
+ if (mVarags[i] instanceof String) {
+ mVarags2[i] = (char) ((String) mVarags[i]).charAt(0);
+ }
+ else if (mVarags[i] instanceof ItemStack) {
+ mVarags2[i] = (ItemStack) mVarags[i];
+ }
}
+
+ int jhr = 0;
+ for (Object u : mVarags2) {
+ if (u != null) {
+ if (u instanceof ItemStack) {
+ ItemStack g = (ItemStack) u;
+ Logger.INFO("mVarags2: "+(g).getDisplayName());
+ }
+ else if (u instanceof String) {
+ Logger.INFO("mVarags2: "+(String) u);
+ }
+ else if (u instanceof Character || u instanceof String) {
+ char n;
+ if (u instanceof String) {
+ n = ((String) u).charAt(0);
+ }
+ else if (u instanceof Character){
+ n = (char) u;
+ }
+ else {
+ n = ' ';
+ }
+ Logger.INFO("mVarags2: "+n);
+ }
+ else {
+ Logger.INFO("mVarags2: Invalid Type. Type: "+u.getClass().getName());
+ }
+ }
+ jhr++;
+ }
- ShapedOreRecipe d = new ShapedOreRecipe(
+ ShapedOreRecipe d = null;
+ try {
+ d = new ShapedOreRecipe(
aOutput,
- line1,
- line2,
- line3,
mVarags2);
+ }
+ catch (Throwable t) {
+
+ }*/
- if (mOutput == null || counter < 8 || d == null || (line1 == null || line2 == null || line3 == null) || !ItemUtils.checkForInvalidItems(d.getRecipeOutput())) {
+ /*if (mOutput == null || d == null || (line1 == null || line2 == null || line3 == null) || !ItemUtils.checkForInvalidItems(d.getRecipeOutput())) {
isValid = false;
}
else {
isValid = true;
+ }*/
+
+
+ ShapedRecipe r = new ShapedRecipe(aInputs, aOutput);
+ if (r != null && r.mRecipe != null) {
+ isValid = true;
}
-
- mRecipe = d != null ? d : null;
+ else {
+ isValid = false;
+ }
+ mRecipe = r != null ? r.mRecipe : null;
}
@Override
diff --git a/src/Java/gtPlusPlus/plugin/villagers/VillagerEventHandler.java b/src/Java/gtPlusPlus/plugin/villagers/VillagerEventHandler.java
new file mode 100644
index 0000000000..b515f0979e
--- /dev/null
+++ b/src/Java/gtPlusPlus/plugin/villagers/VillagerEventHandler.java
@@ -0,0 +1,47 @@
+package gtPlusPlus.plugin.villagers;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.plugin.villagers.entity.EntityBaseVillager;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.world.World;
+import net.minecraftforge.event.entity.EntityJoinWorldEvent;
+
+public class VillagerEventHandler {
+
+ private final static VillagerEventHandler mInstance;
+
+ static {
+ mInstance = new VillagerEventHandler();
+ Utils.registerEvent(mInstance);
+ }
+
+ @SubscribeEvent
+ public void onEntityJoinWorld(EntityJoinWorldEvent event){
+
+
+ /*try {
+ if (event.entity != null && event.entity instanceof EntityLivingBase && event.entity instanceof EntityVillager){
+ EntityVillager entity = (EntityVillager) event.entity;
+ World world = entity.worldObj;
+ int profession = entity.getProfession();
+ if (world != null && (profession >= 7735 && profession <= 7737)){
+ EntityBaseVillager mNew = new EntityBaseVillager(world, profession);
+ mNew.copyLocationAndAnglesFrom(entity);
+ if (mNew != null) {
+ world.removeEntity(entity);
+ world.spawnEntityInWorld(mNew);
+ }
+ }
+
+ }
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ return;
+ }*/
+
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/plugin/villagers/VillagerObject.java b/src/Java/gtPlusPlus/plugin/villagers/VillagerObject.java
index 9507371fb1..a5587a1b52 100644
--- a/src/Java/gtPlusPlus/plugin/villagers/VillagerObject.java
+++ b/src/Java/gtPlusPlus/plugin/villagers/VillagerObject.java
@@ -20,7 +20,7 @@ public class VillagerObject {
//Register Custom Trade to Registry.
if (aCustomTrade != null) {
- Core_VillagerAdditions.mVillagerTrades.put(new Pair<Integer, IVillageTradeHandler>(aID, aCustomTrade));
+ Core_VillagerAdditions.mVillagerTrades.put(new Pair<Integer, IVillageTradeHandler>(7735+aID, aCustomTrade));
}
//Register Skin to Registry.
if (aSkin != null) {
diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java
index 2bc3c1f6a2..8fcb0b96dd 100644
--- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java
+++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java
@@ -6,6 +6,7 @@ import java.util.Iterator;
import java.util.Random;
import cpw.mods.fml.common.registry.VillagerRegistry;
+import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import gtPlusPlus.plugin.villagers.NameLists;
@@ -44,13 +45,13 @@ public class EntityBaseVillager extends EntityVillager {
* interacts with buyingList and make it use your own list, or you need to not
* extend EntityVillager and just implement IMerchant instead.
*/
-
+
private final int mRoleID;
public EntityBaseVillager(World aWorld){
- this(aWorld, 0);
- }
-
+ this(aWorld, 0);
+ }
+
public EntityBaseVillager(World aWorld, int aID) {
super(aWorld, aID);
mRoleID = aID;
@@ -209,19 +210,23 @@ public class EntityBaseVillager extends EntityVillager {
v82191 = ReflectionUtils.getField(getClass(), "buyingList");
try {
o = (MerchantRecipeList) v82191.get(this);
+ Logger.INFO("Is BuyingList Valid? "+(v82191 != null));
return v82191 != null ? o : null;
} catch (IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
return null;
}
} catch (NoSuchFieldException e1) {
+ e1.printStackTrace();
return null;
}
}
protected void setBuyingList(MerchantRecipeList f) {
try {
- ReflectionUtils.setField(this, "buyingList", f);
+ Logger.INFO("set BuyingList? "+(ReflectionUtils.setField(this, "buyingList", f)));
} catch (IllegalArgumentException e) {
+ e.printStackTrace();
}
}
@@ -287,119 +292,119 @@ public class EntityBaseVillager extends EntityVillager {
int k;
label50:
- switch (this.getProfession()) {
- case 0:
- addPurchaseRecipe(merchantrecipelist, Items.wheat, this.rand, this.adjustProbability(0.9F));
- addPurchaseRecipe(merchantrecipelist, Item.getItemFromBlock(Blocks.wool), this.rand,
- this.adjustProbability(0.5F));
- addPurchaseRecipe(merchantrecipelist, Items.chicken, this.rand, this.adjustProbability(0.5F));
- addPurchaseRecipe(merchantrecipelist, Items.cooked_fished, this.rand, this.adjustProbability(0.4F));
- addEmeraldTrade(merchantrecipelist, Items.bread, this.rand, this.adjustProbability(0.9F));
- addEmeraldTrade(merchantrecipelist, Items.melon, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.apple, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.cookie, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.shears, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.flint_and_steel, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.cooked_chicken, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.arrow, this.rand, this.adjustProbability(0.5F));
-
- if (this.rand.nextFloat() < this.adjustProbability(0.5F)) {
- merchantrecipelist.add(new MerchantRecipe(new ItemStack(Blocks.gravel, 10),
- new ItemStack(Items.emerald), new ItemStack(Items.flint, 4 + this.rand.nextInt(2), 0)));
- }
-
- break;
- case 1:
- addPurchaseRecipe(merchantrecipelist, Items.paper, this.rand, this.adjustProbability(0.8F));
- addPurchaseRecipe(merchantrecipelist, Items.book, this.rand, this.adjustProbability(0.8F));
- addPurchaseRecipe(merchantrecipelist, Items.written_book, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Item.getItemFromBlock(Blocks.bookshelf), this.rand,
- this.adjustProbability(0.8F));
- addEmeraldTrade(merchantrecipelist, Item.getItemFromBlock(Blocks.glass), this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.compass, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.clock, this.rand, this.adjustProbability(0.2F));
-
- if (this.rand.nextFloat() < this.adjustProbability(0.07F)) {
- Enchantment enchantment = Enchantment.enchantmentsBookList[this.rand
- .nextInt(Enchantment.enchantmentsBookList.length)];
- int i1 = MathHelper.getRandomIntegerInRange(this.rand, enchantment.getMinLevel(),
- enchantment.getMaxLevel());
- ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i1));
- k = 2 + this.rand.nextInt(5 + i1 * 10) + 3 * i1;
- merchantrecipelist
- .add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, k), itemstack));
- }
+ switch (this.getProfession()) {
+ case 0:
+ addPurchaseRecipe(merchantrecipelist, Items.wheat, this.rand, this.adjustProbability(0.9F));
+ addPurchaseRecipe(merchantrecipelist, Item.getItemFromBlock(Blocks.wool), this.rand,
+ this.adjustProbability(0.5F));
+ addPurchaseRecipe(merchantrecipelist, Items.chicken, this.rand, this.adjustProbability(0.5F));
+ addPurchaseRecipe(merchantrecipelist, Items.cooked_fished, this.rand, this.adjustProbability(0.4F));
+ addEmeraldTrade(merchantrecipelist, Items.bread, this.rand, this.adjustProbability(0.9F));
+ addEmeraldTrade(merchantrecipelist, Items.melon, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.apple, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.cookie, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.shears, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.flint_and_steel, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.cooked_chicken, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.arrow, this.rand, this.adjustProbability(0.5F));
+
+ if (this.rand.nextFloat() < this.adjustProbability(0.5F)) {
+ merchantrecipelist.add(new MerchantRecipe(new ItemStack(Blocks.gravel, 10),
+ new ItemStack(Items.emerald), new ItemStack(Items.flint, 4 + this.rand.nextInt(2), 0)));
+ }
- break;
- case 2:
- addEmeraldTrade(merchantrecipelist, Items.ender_eye, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.experience_bottle, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.redstone, this.rand, this.adjustProbability(0.4F));
- addEmeraldTrade(merchantrecipelist, Item.getItemFromBlock(Blocks.glowstone), this.rand,
- this.adjustProbability(0.3F));
- Item[] aitem = new Item[] { Items.iron_sword, Items.diamond_sword, Items.iron_chestplate,
- Items.diamond_chestplate, Items.iron_axe, Items.diamond_axe, Items.iron_pickaxe,
- Items.diamond_pickaxe };
- Item[] aitem1 = aitem;
- int j = aitem.length;
- k = 0;
-
- while (true) {
- if (k >= j) {
- break label50;
+ break;
+ case 1:
+ addPurchaseRecipe(merchantrecipelist, Items.paper, this.rand, this.adjustProbability(0.8F));
+ addPurchaseRecipe(merchantrecipelist, Items.book, this.rand, this.adjustProbability(0.8F));
+ addPurchaseRecipe(merchantrecipelist, Items.written_book, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Item.getItemFromBlock(Blocks.bookshelf), this.rand,
+ this.adjustProbability(0.8F));
+ addEmeraldTrade(merchantrecipelist, Item.getItemFromBlock(Blocks.glass), this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.compass, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.clock, this.rand, this.adjustProbability(0.2F));
+
+ if (this.rand.nextFloat() < this.adjustProbability(0.07F)) {
+ Enchantment enchantment = Enchantment.enchantmentsBookList[this.rand
+ .nextInt(Enchantment.enchantmentsBookList.length)];
+ int i1 = MathHelper.getRandomIntegerInRange(this.rand, enchantment.getMinLevel(),
+ enchantment.getMaxLevel());
+ ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i1));
+ k = 2 + this.rand.nextInt(5 + i1 * 10) + 3 * i1;
+ merchantrecipelist
+ .add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, k), itemstack));
}
- Item item = aitem1[k];
+ break;
+ case 2:
+ addEmeraldTrade(merchantrecipelist, Items.ender_eye, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.experience_bottle, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.redstone, this.rand, this.adjustProbability(0.4F));
+ addEmeraldTrade(merchantrecipelist, Item.getItemFromBlock(Blocks.glowstone), this.rand,
+ this.adjustProbability(0.3F));
+ Item[] aitem = new Item[] { Items.iron_sword, Items.diamond_sword, Items.iron_chestplate,
+ Items.diamond_chestplate, Items.iron_axe, Items.diamond_axe, Items.iron_pickaxe,
+ Items.diamond_pickaxe };
+ Item[] aitem1 = aitem;
+ int j = aitem.length;
+ k = 0;
+
+ while (true) {
+ if (k >= j) {
+ break label50;
+ }
- if (this.rand.nextFloat() < this.adjustProbability(0.05F)) {
- merchantrecipelist.add(new MerchantRecipe(new ItemStack(item, 1, 0),
- new ItemStack(Items.emerald, 2 + this.rand.nextInt(3), 0),
- EnchantmentHelper.addRandomEnchantment(this.rand, new ItemStack(item, 1, 0),
- 5 + this.rand.nextInt(15))));
- }
+ Item item = aitem1[k];
+
+ if (this.rand.nextFloat() < this.adjustProbability(0.05F)) {
+ merchantrecipelist.add(new MerchantRecipe(new ItemStack(item, 1, 0),
+ new ItemStack(Items.emerald, 2 + this.rand.nextInt(3), 0),
+ EnchantmentHelper.addRandomEnchantment(this.rand, new ItemStack(item, 1, 0),
+ 5 + this.rand.nextInt(15))));
+ }
- ++k;
+ ++k;
+ }
+ case 3:
+ addPurchaseRecipe(merchantrecipelist, Items.coal, this.rand, this.adjustProbability(0.7F));
+ addPurchaseRecipe(merchantrecipelist, Items.iron_ingot, this.rand, this.adjustProbability(0.5F));
+ addPurchaseRecipe(merchantrecipelist, Items.gold_ingot, this.rand, this.adjustProbability(0.5F));
+ addPurchaseRecipe(merchantrecipelist, Items.diamond, this.rand, this.adjustProbability(0.5F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_sword, this.rand, this.adjustProbability(0.5F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_sword, this.rand, this.adjustProbability(0.5F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_axe, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_axe, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_pickaxe, this.rand, this.adjustProbability(0.5F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_pickaxe, this.rand, this.adjustProbability(0.5F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_shovel, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_shovel, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_hoe, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_hoe, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_boots, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_boots, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_helmet, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_helmet, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_chestplate, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_chestplate, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.iron_leggings, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.diamond_leggings, this.rand, this.adjustProbability(0.2F));
+ addEmeraldTrade(merchantrecipelist, Items.chainmail_boots, this.rand, this.adjustProbability(0.1F));
+ addEmeraldTrade(merchantrecipelist, Items.chainmail_helmet, this.rand, this.adjustProbability(0.1F));
+ addEmeraldTrade(merchantrecipelist, Items.chainmail_chestplate, this.rand, this.adjustProbability(0.1F));
+ addEmeraldTrade(merchantrecipelist, Items.chainmail_leggings, this.rand, this.adjustProbability(0.1F));
+ break;
+ case 4:
+ addPurchaseRecipe(merchantrecipelist, Items.coal, this.rand, this.adjustProbability(0.7F));
+ addPurchaseRecipe(merchantrecipelist, Items.porkchop, this.rand, this.adjustProbability(0.5F));
+ addPurchaseRecipe(merchantrecipelist, Items.beef, this.rand, this.adjustProbability(0.5F));
+ addEmeraldTrade(merchantrecipelist, Items.saddle, this.rand, this.adjustProbability(0.1F));
+ addEmeraldTrade(merchantrecipelist, Items.leather_chestplate, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.leather_boots, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.leather_helmet, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.leather_leggings, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.cooked_porkchop, this.rand, this.adjustProbability(0.3F));
+ addEmeraldTrade(merchantrecipelist, Items.cooked_beef, this.rand, this.adjustProbability(0.3F));
}
- case 3:
- addPurchaseRecipe(merchantrecipelist, Items.coal, this.rand, this.adjustProbability(0.7F));
- addPurchaseRecipe(merchantrecipelist, Items.iron_ingot, this.rand, this.adjustProbability(0.5F));
- addPurchaseRecipe(merchantrecipelist, Items.gold_ingot, this.rand, this.adjustProbability(0.5F));
- addPurchaseRecipe(merchantrecipelist, Items.diamond, this.rand, this.adjustProbability(0.5F));
- addEmeraldTrade(merchantrecipelist, Items.iron_sword, this.rand, this.adjustProbability(0.5F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_sword, this.rand, this.adjustProbability(0.5F));
- addEmeraldTrade(merchantrecipelist, Items.iron_axe, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_axe, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.iron_pickaxe, this.rand, this.adjustProbability(0.5F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_pickaxe, this.rand, this.adjustProbability(0.5F));
- addEmeraldTrade(merchantrecipelist, Items.iron_shovel, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_shovel, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.iron_hoe, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_hoe, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.iron_boots, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_boots, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.iron_helmet, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_helmet, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.iron_chestplate, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_chestplate, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.iron_leggings, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.diamond_leggings, this.rand, this.adjustProbability(0.2F));
- addEmeraldTrade(merchantrecipelist, Items.chainmail_boots, this.rand, this.adjustProbability(0.1F));
- addEmeraldTrade(merchantrecipelist, Items.chainmail_helmet, this.rand, this.adjustProbability(0.1F));
- addEmeraldTrade(merchantrecipelist, Items.chainmail_chestplate, this.rand, this.adjustProbability(0.1F));
- addEmeraldTrade(merchantrecipelist, Items.chainmail_leggings, this.rand, this.adjustProbability(0.1F));
- break;
- case 4:
- addPurchaseRecipe(merchantrecipelist, Items.coal, this.rand, this.adjustProbability(0.7F));
- addPurchaseRecipe(merchantrecipelist, Items.porkchop, this.rand, this.adjustProbability(0.5F));
- addPurchaseRecipe(merchantrecipelist, Items.beef, this.rand, this.adjustProbability(0.5F));
- addEmeraldTrade(merchantrecipelist, Items.saddle, this.rand, this.adjustProbability(0.1F));
- addEmeraldTrade(merchantrecipelist, Items.leather_chestplate, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.leather_boots, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.leather_helmet, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.leather_leggings, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.cooked_porkchop, this.rand, this.adjustProbability(0.3F));
- addEmeraldTrade(merchantrecipelist, Items.cooked_beef, this.rand, this.adjustProbability(0.3F));
- }
if (merchantrecipelist.isEmpty()) {
addPurchaseRecipe(merchantrecipelist, Items.gold_ingot, this.rand, 1.0F);
@@ -414,6 +419,38 @@ public class EntityBaseVillager extends EntityVillager {
for (int l = 0; l < p_70950_1_ && l < merchantrecipelist.size(); ++l) {
this.getBuyingList().addToListWithCheck((MerchantRecipe) merchantrecipelist.get(l));
}
+
+ try {
+ if (this.getBuyingList() != null) {
+ for (Object g : this.getBuyingList()) {
+ if (g != null) {
+ if (g instanceof MerchantRecipe) {
+ MerchantRecipe m = (MerchantRecipe) g;
+ ItemStack selling = m.getItemToSell();
+ ItemStack[] buying = new ItemStack[] {m.getItemToBuy(), m.getSecondItemToBuy() != null ? m.getSecondItemToBuy() : null};
+ if (selling == null) {
+ Logger.INFO("Villager is Selling an invalid item");
+ }
+ else if (buying[0] == null && buying[1] == null) {
+ Logger.INFO("Villager is buying two invalid items");
+ }
+ else {
+ Logger.INFO("Villager is Selling x"+selling.stackSize+selling.getDisplayName()+" for x"+buying[0].stackSize+" "+buying[0].getDisplayName()+buying[1] != null ? " and for x"+buying[1].stackSize+" "+buying[1].getDisplayName() : "");
+ }
+ }
+ else
+ Logger.INFO("Found: "+g.getClass().getName());
+ }
+ }
+ }
+ else {
+
+ }
+ }
+ catch (Throwable t) {
+
+ }
+
}
/**
@@ -464,7 +501,7 @@ public class EntityBaseVillager extends EntityVillager {
aRecipeList.add(new MerchantRecipe(itemstack, itemstack1));
}
}
-
+
public static void addCustomTrade(MerchantRecipeList aRecipeList, ItemStack aItem1, ItemStack aItem2, ItemStack aItem3, Random aRand, float aChance) {
if (aRand.nextFloat() < aChance) {
aRecipeList.add(new MerchantRecipe(aItem1, aItem2, aItem3));
@@ -475,7 +512,7 @@ public class EntityBaseVillager extends EntityVillager {
Tuple tuple = (Tuple) blacksmithSellingList.get(aItem);
return tuple == null ? 1
: (((Integer) tuple.getFirst()).intValue() >= ((Integer) tuple.getSecond()).intValue()
- ? ((Integer) tuple.getFirst()).intValue()
+ ? ((Integer) tuple.getFirst()).intValue()
: ((Integer) tuple.getFirst()).intValue() + aRand.nextInt(
((Integer) tuple.getSecond()).intValue() - ((Integer) tuple.getFirst()).intValue()));
}
@@ -489,7 +526,7 @@ public class EntityBaseVillager extends EntityVillager {
private static ItemStack getSimpleLootStack(Item aItem, Random aRand) {
return new ItemStack(aItem, getLootAmount_VillagerSellingList(aItem, aRand), 0);
}
-
+
public static void addPurchaseRecipe(MerchantRecipeList aTradeList, Item aItem, int aMeta, Random aRand, float aChance) {
if (aRand.nextFloat() < aChance) {
aTradeList.add(new MerchantRecipe(getComplexLootStack(aItem, aMeta, aRand), Items.emerald));
@@ -504,7 +541,7 @@ public class EntityBaseVillager extends EntityVillager {
Tuple tuple = (Tuple) villagersSellingList.get(aItem);
return tuple == null ? 1
: (((Integer) tuple.getFirst()).intValue() >= ((Integer) tuple.getSecond()).intValue()
- ? ((Integer) tuple.getFirst()).intValue()
+ ? ((Integer) tuple.getFirst()).intValue()
: ((Integer) tuple.getFirst()).intValue() + aRand.nextInt(
((Integer) tuple.getSecond()).intValue() - ((Integer) tuple.getFirst()).intValue()));
}
diff --git a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java
index d85f86ad57..215dc0683b 100644
--- a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java
+++ b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerBanker.java
@@ -14,14 +14,14 @@ public class TradeHandlerBanker extends TradeHandlerBase {
@SuppressWarnings("unchecked")
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
- if (villager.getProfession() == 7735) {
+ //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);
- }
+ //Collections.shuffle(recipeList);
+ //}
}
}
diff --git a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java
index cc77aa69cf..922316b136 100644
--- a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java
+++ b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTechnician.java
@@ -14,14 +14,14 @@ public class TradeHandlerTechnician extends TradeHandlerBase {
@SuppressWarnings("unchecked")
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
- if (villager.getProfession() == 7737) {
+ //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);
- }
+ //Collections.shuffle(recipeList);
+ //}
}
}
diff --git a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java
index 508ecd9e83..9b75b54cfa 100644
--- a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java
+++ b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerTrader.java
@@ -3,6 +3,7 @@ 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;
@@ -12,17 +13,24 @@ 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) {
- if (villager.getProfession() == 7736) {
- recipeList.add(new MerchantRecipe(ItemUtils.getItemStackOfAmountFromOreDict("logWood", 32), ELEMENT.getInstance().IRON.getOre(1)));
- recipeList.add(new MerchantRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRawMeat", 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), ELEMENT.getInstance().SILICON.getOre(1)));
- recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.piston, 32), ELEMENT.getInstance().ALUMINIUM.getOre(1)));
- Collections.shuffle(recipeList);
- }
+
+ Logger.INFO("Trying to manipulate trade for villager.");
+
+ //if (villager.getProfession() == 7736) {
+ recipeList.add(new MerchantRecipe(ItemUtils.getItemStackOfAmountFromOreDict("logWood", 32), ELEMENT.getInstance().IRON.getOre(1)));
+ recipeList.add(new MerchantRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRawMeat", 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), ELEMENT.getInstance().SILICON.getOre(1)));
+ recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.piston, 32), ELEMENT.getInstance().ALUMINIUM.getOre(1)));
+ Collections.shuffle(recipeList);
+ //}
}
-
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java
index fa1a0a3aae..a85c9ad5d7 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java
@@ -218,7 +218,7 @@ extends GregtechMeta_MultiBlockBase {
}
}
}
- if ((this.mInputBusses.size() != 1) || (this.mOutputBusses.size() != 4)
+ if ((this.mInputBusses.size() < 1) || (this.mOutputBusses.size() < 4)
|| (this.mMaintenanceHatches.size() != 1) || (this.mEnergyHatches.size() < 1)) {
Logger.MACHINE_INFO("Returned False 3");
Logger.MACHINE_INFO("Input Buses: "+this.mInputBusses.size()+" | expected: 1");