Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with Combination Crafting #36

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ private int getEnergyBarScaled(int pixels) {
}

private int getProgressBarScaled(int pixels) {
int i = this.tile.getProgress();
long i = this.tile.getProgress();
CombinationRecipe recipe = this.tile.getRecipe();
long j = recipe == null ? 0 : recipe.getCost();
return (int) (j != 0 && i != 0 ? (long) i * pixels / j : 0);
return (int) (j != 0 && i != 0 ? i * pixels / j : 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ public class CombinationCraftingWrapper implements IRecipeWrapper {
public CombinationCraftingWrapper(IJeiHelpers helpers, CombinationRecipe recipe) {
this.helpers = helpers;
this.recipe = recipe;
int period = recipe.getPedestalIngredients()
.stream()
.map(Ingredient::getMatchingStacks)
.map(a -> a.length)
.reduce(1, (a, b) -> a * b);

int period = Math.max(1, recipe.getInputIngredient().getMatchingStacks().length);
for (Ingredient ingredient : recipe.getPedestalIngredients()) {
int length = ingredient.getMatchingStacks().length;
if (length > 0) {
period *= length;
}
}
timer = helpers.getGuiHelper()
.createTickTimer(period * 20, period, false);
}
Expand All @@ -47,6 +50,13 @@ public List<String> getTooltipStrings(int mouseX, int mouseY) {
ArrayList<String> tooltip = new ArrayList<>();
tooltip.add(Utils.localize("tooltip.ec.items_required"));
Object2IntLinkedOpenHashMap<String> tooltipCount = new Object2IntLinkedOpenHashMap<>();

ItemStack[] coreStacks = recipe.getInputIngredient().getMatchingStacks();
if(coreStacks.length != 0) {
String line = coreStacks[timer.getValue() % coreStacks.length].getDisplayName();
tooltipCount.put(line, tooltipCount.getInt(line) + 1);
}

for (Ingredient ing : recipe.getPedestalIngredients()) {
ItemStack[] stacks = ing.getMatchingStacks();
if(stacks.length == 0) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TileCraftingCore extends TileEntity implements ITickable, IGTEnergy
private final ItemStackHandler inventory = new StackHandler();
private final EnergyStorageCustom energy = new EnergyStorageCustom(ModConfig.confCraftingCoreRFCapacity);

private int progress;
private long progress;
private int oldEnergy;
private int pedestalCount;

Expand Down Expand Up @@ -166,6 +166,8 @@ public CombinationRecipe getRecipe(List<BlockPos> locations) {

if (!recipes.isEmpty()) {
for (CombinationRecipe recipe : recipes) {
if (recipe.getPedestalIngredients().isEmpty())
return recipe;
List<TilePedestal> pedestals = this.getPedestalsWithStuff(recipe, locations);
if (!pedestals.isEmpty())
return recipe;
Expand All @@ -175,7 +177,7 @@ public CombinationRecipe getRecipe(List<BlockPos> locations) {
return null;
}

public int getProgress() {
public long getProgress() {
return this.progress;
}

Expand All @@ -196,15 +198,15 @@ public int getPedestalCount() {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
this.inventory.deserializeNBT(tag);
this.progress = tag.getInteger("Progress");
this.progress = tag.getLong("Progress");
WaitingIdly marked this conversation as resolved.
Show resolved Hide resolved
this.energy.setEnergy(tag.getInteger("Energy"));
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
tag = super.writeToNBT(tag);
tag.merge(this.inventory.serializeNBT());
tag.setInteger("Progress", this.progress);
tag.setLong("Progress", this.progress);
tag.setInteger("Energy", this.energy.getEnergyStored());

return tag;
Expand Down