Skip to content

Commit

Permalink
Adjust JEI Enchanter refresh logic.
Browse files Browse the repository at this point in the history
Smelter now processes single dusts.

Signed-off-by: King Lemming <[email protected]>
  • Loading branch information
KingLemming committed Jan 2, 2018
1 parent fbc1b24 commit 23f8892
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {
compile "mezz.jei:jei_${config.jei_mc_version}:${config.jei_version}"
}

version = "${project.config.mod_version}." + (System.getenv("BUILD_NUMBER") ?: "36")
version = "${project.config.mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1")

println config.mc_version + "-" + config.forge_version
// Setup the Forge/Minecraft plugin data. Specify the preferred Forge/Minecraft version here.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cofh/thermalexpansion/block/BlockTEBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public abstract class BlockTEBase extends BlockCoreTile {

protected BlockTEBase(Material material) {

super(material);
super(material, "thermalexpansion");
setSoundType(SoundType.STONE);
setCreativeTab(ThermalExpansion.tabCommon);
}
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/cofh/thermalexpansion/block/storage/TileCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,15 @@ public static void config() {
boolean lock = false;
int cacheStackSize;
int maxCacheStackSize;
int maxCapacity;
int maxCapacity = Integer.MAX_VALUE;

public ItemStack storedStack = ItemStack.EMPTY;

public TileCache() {

inventory = new ItemStack[2];
Arrays.fill(inventory, ItemStack.EMPTY);

maxCapacity = getCapacity(0, 0);
maxCacheStackSize = maxCapacity - 64 * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(0, 0)) - 64 * 2;
}

@Override
Expand Down Expand Up @@ -166,12 +164,10 @@ protected boolean setLevel(int level) {

if (super.setLevel(level)) {
if (!storedStack.isEmpty()) {
maxCapacity = getCapacity(level, enchantHolding);
maxCacheStackSize = maxCapacity - storedStack.getMaxStackSize() * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(level, enchantHolding)) - storedStack.getMaxStackSize() * 2;
balanceStacks();
} else {
maxCapacity = getCapacity(level, enchantHolding);
maxCacheStackSize = maxCapacity - 64 * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(level, enchantHolding)) - 64 * 2;
}
return true;
}
Expand Down Expand Up @@ -346,11 +342,9 @@ public void readFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("Item")) {
storedStack = ItemHelper.readItemStackFromNBT(nbt.getCompoundTag("Item"));
cacheStackSize = nbt.getInteger("CacheCount");
maxCapacity = getCapacity(level, enchantHolding);
maxCacheStackSize = maxCapacity - storedStack.getMaxStackSize() * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(level, enchantHolding)) - storedStack.getMaxStackSize() * 2;
} else {
maxCapacity = getCapacity(level, enchantHolding);
maxCacheStackSize = maxCapacity - 64 * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(level, enchantHolding)) - 64 * 2;
lock = false;
}
}
Expand Down Expand Up @@ -482,8 +476,7 @@ public void setStoredItemType(ItemStack stack, int amount) {
} else {
storedStack = ItemHelper.cloneStack(stack, 1);
cacheStackSize = Math.min(amount, getMaxStoredCount());
maxCapacity = getCapacity(level, enchantHolding);
maxCacheStackSize = maxCapacity - storedStack.getMaxStackSize() * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(level, enchantHolding)) - storedStack.getMaxStackSize() * 2;
balanceStacks();
}
updateTrackers();
Expand Down Expand Up @@ -579,8 +572,7 @@ public void setInventorySlotContents(int slot, ItemStack stack) {
storedStack = ItemHelper.cloneStack(inventory[0], 1);
cacheStackSize = inventory[0].getCount();
inventory[0] = ItemStack.EMPTY;
maxCapacity = getCapacity(level, enchantHolding);
maxCacheStackSize = maxCapacity - storedStack.getMaxStackSize() * 2;
maxCacheStackSize = Math.min(maxCapacity, getCapacity(level, enchantHolding)) - storedStack.getMaxStackSize() * 2;
} else {
cacheStackSize += inventory[0].getCount() + inventory[1].getCount();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cofh/thermalexpansion/item/ItemSatchel.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ public static boolean onItemPickup(EntityItemPickupEvent event, ItemStack stack)
if (isVoid(stack)) {
eventItem.setCount(0);
stack.setAnimationsToGo(5);
EntityPlayer player = event.getEntityPlayer();
player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, (MathHelper.RANDOM.nextFloat() - MathHelper.RANDOM.nextFloat()) * 0.7F + 1.0F);
stack.getTagCompound().setInteger("Random", MathHelper.RANDOM.nextInt());
return true;
} else if (!(eventItem.getItem() instanceof IInventoryContainerItem) || ((IInventoryContainerItem) eventItem.getItem()).getSizeInventory(stack) <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import cofh.thermalexpansion.plugins.jei.machine.transposer.TransposerRecipeCategory;
import mezz.jei.api.*;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
Expand Down Expand Up @@ -127,7 +128,8 @@ public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {

public static void refresh() {

EnchanterRecipeCategory.refresh();
// This is done because JEI whines otherwise.
Minecraft.getMinecraft().addScheduledTask(EnchanterRecipeCategory::refresh);
}

/* HELPERS */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,18 @@ public static void refresh() {

List<EnchanterRecipeWrapper> enchanterRecipeWrappers = recipeRegistry.getRecipeWrappers(categoryStandard);
for (EnchanterRecipeWrapper wrapper : enchanterRecipeWrappers) {
//recipeRegistry.removeRecipe(wrapper, RecipeUidsTE.ENCHANTER);
wrapper.refresh();
recipeRegistry.removeRecipe(wrapper, RecipeUidsTE.ENCHANTER);
}
enchanterRecipeWrappers.clear();

for (EnchanterRecipe recipe : EnchanterManager.getRecipeList()) {
if (recipe.getType() == Type.STANDARD) {
enchanterRecipeWrappers.add(new EnchanterRecipeWrapper(JEIPluginTE.guiHelper, recipe));
}
}
for (EnchanterRecipeWrapper wrapper : enchanterRecipeWrappers) {
recipeRegistry.addRecipe(wrapper, RecipeUidsTE.ENCHANTER);
}
// TODO: This is a temporary half-solution til Mezz gets back to me.
// enchanterRecipeWrappers.clear();
//
// for (EnchanterRecipe recipe : EnchanterManager.getRecipeList()) {
// if (recipe.getType() == Type.STANDARD) {
// enchanterRecipeWrappers.add(new EnchanterRecipeWrapper(JEIPluginTE.guiHelper, recipe));
// }
// }
// for (EnchanterRecipeWrapper wrapper : enchanterRecipeWrappers) {
// recipeRegistry.addRecipe(wrapper, RecipeUidsTE.ENCHANTER);
// }
// EnchanterRecipeCategoryEmpowered.refresh(registry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cofh.core.init.CoreProps;
import cofh.core.inventory.ComparableItemStack;
import cofh.core.util.helpers.ItemHelper;
import cofh.thermalfoundation.block.BlockStorageResource;
import cofh.thermalfoundation.item.ItemMaterial;
import com.google.common.collect.ImmutableSet;
import gnu.trove.iterator.TObjectIntIterator;
Expand Down Expand Up @@ -51,7 +52,9 @@ public static void initialize() {
addFuel(new ItemStack(Items.COAL, 1, 0), 24000);
addFuel(new ItemStack(Blocks.COAL_BLOCK), 24000 * 10);
addFuel(new ItemStack(Items.COAL, 1, 1), 16000);
addFuel(ItemHelper.cloneStack(BlockStorageResource.blockCharcoal, 1), 16000 * 10);
addFuel(ItemHelper.cloneStack(ItemMaterial.fuelCoke, 1), 40000);
addFuel(ItemHelper.cloneStack(BlockStorageResource.blockCoke, 1), 40000 * 10);

loadFuels();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
public class SmelterManager {

private static Map<List<ComparableItemStackSmelter>, SmelterRecipe> recipeMap = new THashMap<>();
private static Map<List<ComparableItemStackSmelter>, SmelterRecipe> recipeMapRecycle = new THashMap<>();
private static Set<ComparableItemStackSmelter> validationSet = new THashSet<>();
private static Set<ComparableItemStackSmelter> lockSet = new THashSet<>();

Expand Down Expand Up @@ -268,8 +269,8 @@ public static void initialize() {
{
int energy = DEFAULT_ENERGY * 3 / 2;

addRecipe(energy, BLOCK_SAND, new ItemStack(Items.COMPASS), new ItemStack(Items.IRON_INGOT, 4), ItemMaterial.crystalSlagRich, 10); // consumes redstone
addRecipe(energy, BLOCK_SAND, new ItemStack(Items.FLINT_AND_STEEL), new ItemStack(Items.IRON_INGOT), ItemMaterial.crystalSlag, 90); // make a use for flint: slag!
addRecipe(energy, BLOCK_SAND, new ItemStack(Items.COMPASS), new ItemStack(Items.IRON_INGOT, 4), ItemMaterial.crystalSlagRich, 10);
addRecipe(energy, BLOCK_SAND, new ItemStack(Items.FLINT_AND_STEEL), new ItemStack(Items.IRON_INGOT), ItemMaterial.crystalSlag, 90);

ItemStack ingot = new ItemStack(Items.IRON_INGOT);
// no minecart, rails. Railcraft causes resource duplication there
Expand Down Expand Up @@ -298,7 +299,7 @@ public static void initialize() {
}
ingot = new ItemStack(Items.GOLD_INGOT);

addRecipe(energy, BLOCK_SAND, new ItemStack(Items.CLOCK), new ItemStack(Items.GOLD_INGOT, 4), ItemMaterial.crystalSlagRich, 10); // consumes redstone
addRecipe(energy, BLOCK_SAND, new ItemStack(Items.CLOCK), new ItemStack(Items.GOLD_INGOT, 4), ItemMaterial.crystalSlagRich, 10);
addRecycleRecipe(energy, new ItemStack(Blocks.LIGHT_WEIGHTED_PRESSURE_PLATE), ingot, 2);

addRecycleRecipe(energy, new ItemStack(Items.GOLDEN_SWORD), ingot, 2);
Expand Down Expand Up @@ -485,7 +486,7 @@ private static void addDefaultOreDictionaryRecipe(String oreName, String dustNam
addOreToIngotRecipe(DEFAULT_ENERGY, oreName, ItemHelper.cloneStack(ingot, ORE_MULTIPLIER), ItemHelper.cloneStack(ingot, ORE_MULTIPLIER_SPECIAL), ItemHelper.cloneStack(ingotRelated, 1), richSlagChance, slagOreChance);
}
if (dustName != null) {
addDustToIngotRecipe(DEFAULT_ENERGY / 5, dustName, ItemHelper.cloneStack(ingot, 2), slagDustChance);
addDustToIngotRecipe(DEFAULT_ENERGY / 8, dustName, ItemHelper.cloneStack(ingot, 1), slagDustChance);
}
}

Expand Down Expand Up @@ -563,12 +564,12 @@ private static void addOreToIngotRecipe(int energy, String oreName, ItemStack in
}
}

private static void addDustToIngotRecipe(int energy, String dustName, ItemStack ingot2, int slagDustChance) {
private static void addDustToIngotRecipe(int energy, String dustName, ItemStack ingot, int slagDustChance) {

List<ItemStack> registeredOres = OreDictionary.getOres(dustName, false);

if (registeredOres.size() > 0) {
addRecipe(energy, ItemHelper.cloneStack(registeredOres.get(0), 2), BLOCK_SAND, ingot2, ItemMaterial.crystalSlag, slagDustChance);
addRecipe(energy, ItemHelper.cloneStack(registeredOres.get(0), 1), BLOCK_SAND, ingot, ItemMaterial.crystalSlag, slagDustChance);
}
}

Expand Down

0 comments on commit 23f8892

Please sign in to comment.