This repository has been archived by the owner on May 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'AbdielKavash/TreeGrowthSim' into dev
- Loading branch information
Showing
9 changed files
with
1,450 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,146 @@ | ||
package gtPlusPlus.api.recipe; | ||
|
||
import static net.minecraft.util.EnumChatFormatting.GRAY; | ||
|
||
import java.awt.Rectangle; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.EnumChatFormatting; | ||
import net.minecraft.util.StatCollector; | ||
|
||
import com.gtnewhorizons.modularui.api.math.Pos2d; | ||
|
||
import gregtech.api.recipe.BasicUIPropertiesBuilder; | ||
import gregtech.api.recipe.NEIRecipePropertiesBuilder; | ||
import gregtech.api.recipe.RecipeMapFrontend; | ||
import gregtech.api.util.GT_Recipe; | ||
import gregtech.api.util.MethodsReturnNonnullByDefault; | ||
import gregtech.common.gui.modularui.UIHelper; | ||
import gregtech.nei.GT_NEI_DefaultHandler; | ||
import gregtech.nei.RecipeDisplayInfo; | ||
import gregtech.nei.formatter.INEISpecialInfoFormatter; | ||
import gtPlusPlus.core.item.ModItems; | ||
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityTreeFarm; | ||
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityTreeFarm.Mode; | ||
|
||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
public class TGSFrontend extends RecipeMapFrontend { | ||
|
||
private static final int SLOT_SIZE = 18; | ||
private static final int CENTER_X = 90; | ||
private static final int SPECIAL_X = CENTER_X - SLOT_SIZE / 2; | ||
private static final int SPECIAL_Y = 9; | ||
private static final int INPUTS_X = CENTER_X - SLOT_SIZE * 3; | ||
private static final int INPUTS_Y = SPECIAL_Y + SLOT_SIZE + SLOT_SIZE / 2; | ||
private static final int OUTPUTS_X = CENTER_X + SLOT_SIZE; | ||
private static final int OUTPUTS_Y = INPUTS_Y; | ||
|
||
public TGSFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, NEIRecipePropertiesBuilder neiPropertiesBuilder) { | ||
super(uiPropertiesBuilder, neiPropertiesBuilder.neiSpecialInfoFormatter(new TGSSpecialValueFormatter())); | ||
super( | ||
uiPropertiesBuilder.addNEITransferRect( | ||
new Rectangle(INPUTS_X + SLOT_SIZE * 2, INPUTS_Y + SLOT_SIZE / 2, SLOT_SIZE * 2, SLOT_SIZE)) | ||
.progressBarPos(new Pos2d(CENTER_X - 10, INPUTS_Y + SLOT_SIZE / 2)), | ||
neiPropertiesBuilder.neiSpecialInfoFormatter(new TGSSpecialValueFormatter())); | ||
} | ||
|
||
@Override | ||
protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) {} | ||
protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) { | ||
// Do not. | ||
} | ||
|
||
@Override | ||
protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} | ||
public Pos2d getSpecialItemPosition() { | ||
return new Pos2d(SPECIAL_X, SPECIAL_Y); | ||
} | ||
|
||
@Override | ||
protected List<String> handleNEIItemOutputTooltip(List<String> currentTip, | ||
GT_NEI_DefaultHandler.FixedPositionedStack pStack) { | ||
if (ModItems.fluidFertBasic != null && pStack.isChanceBased()) { | ||
currentTip.add( | ||
GRAY + StatCollector.translateToLocalFormatted( | ||
"gtpp.nei.tgs.sapling", | ||
StatCollector.translateToLocal(ModItems.fluidFertBasic.getUnlocalizedName()))); | ||
} else { | ||
super.handleNEIItemOutputTooltip(currentTip, pStack); | ||
} | ||
return currentTip; | ||
public List<Pos2d> getItemInputPositions(int itemInputCount) { | ||
return UIHelper.getGridPositions(Mode.values().length, INPUTS_X, INPUTS_Y, 2); | ||
} | ||
|
||
@Override | ||
protected void drawNEIOverlayForOutput(GT_NEI_DefaultHandler.FixedPositionedStack stack) {} | ||
public List<Pos2d> getItemOutputPositions(int itemOutputCount) { | ||
return UIHelper.getGridPositions(Mode.values().length, OUTPUTS_X, OUTPUTS_Y, 2); | ||
} | ||
|
||
private static final String[] tooltipInputs = { StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.saw"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.cutter"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.shears"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.knife") }; | ||
|
||
private static final String[] tooltipOutputs = { StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.needsSaw"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.needsCutter"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.needsShears"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.needsKnife") }; | ||
private static final String tooltipSapling = StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.sapling"); | ||
private static final String tooltipMultiplier = StatCollector.translateToLocal("gtpp.nei.tgs.tooltip.multiplier"); | ||
|
||
@Override | ||
public List<String> handleNEIItemTooltip(ItemStack stack, List<String> currentTip, | ||
GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { | ||
|
||
/* | ||
* This gets a little complicated, because we want to assign tooltips to inputs/outputs based on which mode | ||
* (saw, shears, etc.) they correspond to. But CachedDefaultRecipe does not retain this information for us. This | ||
* is because some recipes don't output any items for some modes. For example, if a recipe only yields logs and | ||
* leaves, then the outputs of GT_Recipe will be {log, null, leaves}. However, in CachedDefaultRecipe this gets | ||
* condensed to just {log, leaves}, with null values omitted. So to figure out which item came from which mode, | ||
* we need to step through both of these arrays simultaneously and match non-null inputs/outputs in GT_Recipe to | ||
* inputs/outputs in CachedDefaultRecipe. | ||
*/ | ||
|
||
// The last input in neiCachedRecipe is always the special slot, this is the input sapling. | ||
if (stack == neiCachedRecipe.mInputs.get(neiCachedRecipe.mInputs.size() - 1).item) { | ||
currentTip.add(EnumChatFormatting.YELLOW + tooltipSapling); | ||
super.handleNEIItemTooltip(stack, currentTip, neiCachedRecipe); | ||
return currentTip; | ||
} | ||
|
||
GT_Recipe.GT_Recipe_WithAlt recipe = (GT_Recipe.GT_Recipe_WithAlt) neiCachedRecipe.mRecipe; | ||
|
||
// Inputs | ||
int slot = 0; | ||
for (int mode = 0; mode < Mode.values().length; ++mode) { | ||
if (mode < recipe.mOreDictAlt.length && recipe.mOreDictAlt[mode] != null) { | ||
// There is a valid input in this mode. | ||
if (slot < neiCachedRecipe.mInputs.size() && stack == neiCachedRecipe.mInputs.get(slot).item) { | ||
int toolMultiplier = GregtechMetaTileEntityTreeFarm.getToolMultiplier(stack, Mode.values()[mode]); | ||
currentTip.add(EnumChatFormatting.YELLOW + tooltipInputs[mode]); | ||
if (toolMultiplier > 0) { | ||
currentTip.add(EnumChatFormatting.YELLOW + tooltipMultiplier + " " + toolMultiplier + "x"); | ||
} | ||
return currentTip; | ||
} | ||
++slot; | ||
} | ||
} | ||
|
||
// Outputs | ||
slot = 0; | ||
for (int mode = 0; mode < Mode.values().length; ++mode) { | ||
if (mode < recipe.mOutputs.length && recipe.mOutputs[mode] != null) { | ||
// There is a valid output in this mode. | ||
if (slot < neiCachedRecipe.mOutputs.size() && stack == neiCachedRecipe.mOutputs.get(slot).item) { | ||
currentTip.add(EnumChatFormatting.YELLOW + tooltipOutputs[mode]); | ||
return currentTip; | ||
} | ||
++slot; | ||
} | ||
} | ||
|
||
return currentTip; | ||
} | ||
|
||
private static class TGSSpecialValueFormatter implements INEISpecialInfoFormatter { | ||
|
||
@Override | ||
public List<String> format(RecipeDisplayInfo recipeInfo) { | ||
if (ModItems.fluidFertBasic == null) { | ||
return Collections.emptyList(); | ||
} | ||
return Arrays.asList( | ||
StatCollector.translateToLocal("gtpp.nei.tgs.1"), | ||
StatCollector.translateToLocalFormatted( | ||
"gtpp.nei.tgs.2", | ||
StatCollector.translateToLocal(ModItems.fluidFertBasic.getUnlocalizedName())), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.3")); | ||
StatCollector.translateToLocal("gtpp.nei.tgs.info-1"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.info-2"), | ||
StatCollector.translateToLocal("gtpp.nei.tgs.info-3")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.