mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 11:05:07 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8d00a5445 | ||
|
|
75d53b12ca | ||
|
|
f93d5977ed | ||
|
|
c4f9c54200 |
No files matched your search
@@ -92,6 +92,11 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
this.labelColor = color;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
this.size.width = Math.max(this.columns * SLOT_SIZE, fontRenderer.getStringWidth(this.label) + 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
if (this.length == 0) return;
|
||||
|
||||
@@ -882,9 +882,14 @@ public class NEIClientConfig {
|
||||
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
|
||||
world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer() && getLockedMode() == -1) {
|
||||
final int globalMode = global.config.getTag("inventory.cheatmode").getIntValue();
|
||||
final int worldMode = Math
|
||||
.min(globalMode, NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
|
||||
if (worldMode != globalMode) {
|
||||
world.config.getTag("inventory.cheatmode").setIntValue(worldMode);
|
||||
}
|
||||
}
|
||||
|
||||
bootNEI();
|
||||
|
||||
@@ -37,6 +37,10 @@ public class PositionedStack implements Cloneable {
|
||||
protected int chance = CHANCE_FULL;
|
||||
protected boolean permutated = false;
|
||||
|
||||
protected String acceptsLabel;
|
||||
protected List<String> tooltip;
|
||||
protected List<Badge> badges;
|
||||
|
||||
public PositionedStack(Object object, int x, int y, boolean genPerms) {
|
||||
items = NEIServerUtils.extractRecipeItems(object);
|
||||
relx = x;
|
||||
@@ -90,12 +94,28 @@ public class PositionedStack implements Cloneable {
|
||||
for (ItemStack item : items) if (item.stackSize > i) item.stackSize = i;
|
||||
}
|
||||
|
||||
public void setAcceptsLabel(String acceptsLabel) {
|
||||
this.acceptsLabel = acceptsLabel;
|
||||
}
|
||||
|
||||
public String getAcceptsLabel() {
|
||||
return this.acceptsLabel;
|
||||
}
|
||||
|
||||
public void setBadges(List<Badge> badges) {
|
||||
this.badges = badges;
|
||||
}
|
||||
|
||||
public List<Badge> getBadges() {
|
||||
return null;
|
||||
return this.badges;
|
||||
}
|
||||
|
||||
public void setTooltip(List<String> tooltip) {
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public List<String> getTooltip() {
|
||||
return null;
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
public int getChance() {
|
||||
@@ -111,6 +131,8 @@ public class PositionedStack implements Cloneable {
|
||||
PositionedStack pStack = (PositionedStack) super.clone();
|
||||
pStack.items = Arrays.stream(this.items).map(ItemStack::copy).toArray(ItemStack[]::new);
|
||||
pStack.item = this.item == null ? null : this.item.copy();
|
||||
pStack.tooltip = this.tooltip == null ? null : new ArrayList<>(this.tooltip);
|
||||
pStack.badges = this.badges == null ? null : new ArrayList<>(this.badges);
|
||||
return pStack;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -14,8 +14,9 @@ public class NEIInfo {
|
||||
|
||||
public static void load(World world) {
|
||||
OptionCycled modeOption = (OptionCycled) NEIClientConfig.getOptionList().getOption("inventory.cheatmode");
|
||||
final boolean worldConfig = NEIClientConfig.isWorldSpecific("inventory.cheatmode");
|
||||
// kept alive so the WeakReference in Option.slotRef isn't GC'd before copyGlobals/cycle use it
|
||||
GuiOptionList env = modeOption.parent.synthesizeEnvironment(false);
|
||||
GuiOptionList env = modeOption.parent.synthesizeEnvironment(worldConfig);
|
||||
if (!modeOption.optionValid(modeOption.value())) {
|
||||
modeOption.copyGlobals();
|
||||
modeOption.cycle();
|
||||
|
||||
@@ -15,7 +15,7 @@ public class AcceptsFollowingTooltipLineHandler extends ItemsTooltipLineHandler
|
||||
|
||||
public Object tooltipGUID;
|
||||
|
||||
public AcceptsFollowingTooltipLineHandler(Object tooltipGUID, List<ItemStack> items, ItemStack activeStack,
|
||||
protected AcceptsFollowingTooltipLineHandler(Object tooltipGUID, List<ItemStack> items, ItemStack activeStack,
|
||||
int maxRows) {
|
||||
super(NEIClientUtils.translate("recipe.accepts"), items, false, maxRows);
|
||||
this.tooltipGUID = tooltipGUID;
|
||||
|
||||
@@ -32,43 +32,46 @@ public class AutoCraftingManager {
|
||||
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
|
||||
do {
|
||||
changed = false;
|
||||
try {
|
||||
do {
|
||||
changed = false;
|
||||
|
||||
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
|
||||
while (iterator.hasNext() && !interrupted(guiContainer)) {
|
||||
final Map<RecipeId, Long> recipes = iterator.next();
|
||||
boolean craft = false;
|
||||
while (iterator.hasNext() && !interrupted(guiContainer)) {
|
||||
final Map<RecipeId, Long> recipes = iterator.next();
|
||||
boolean craft = false;
|
||||
|
||||
for (Map.Entry<RecipeId, Long> entry : recipes.entrySet()) {
|
||||
final RecipeHandlerRef handler = RecipeHandlerRef.of(entry.getKey());
|
||||
for (Map.Entry<RecipeId, Long> entry : recipes.entrySet()) {
|
||||
final RecipeHandlerRef handler = RecipeHandlerRef.of(entry.getKey());
|
||||
|
||||
if (handler != null && handler.canCraft(guiContainer)) {
|
||||
long multiplier = entry.getValue();
|
||||
if (handler != null && handler.canCraft(guiContainer)) {
|
||||
long multiplier = entry.getValue();
|
||||
|
||||
while (multiplier > 0 && !interrupted(guiContainer)
|
||||
&& handler.craft(guiContainer, (int) Math.min(64, multiplier))) {
|
||||
multiplier -= 64;
|
||||
while (multiplier > 0 && !interrupted(guiContainer)
|
||||
&& handler.craft(guiContainer, (int) Math.min(64, multiplier))) {
|
||||
multiplier -= 64;
|
||||
}
|
||||
|
||||
craft = craft || multiplier != entry.getValue();
|
||||
}
|
||||
|
||||
craft = multiplier != entry.getValue();
|
||||
if (interrupted(guiContainer)) break;
|
||||
}
|
||||
|
||||
if (interrupted(guiContainer)) break;
|
||||
if (craft) {
|
||||
changed = true;
|
||||
processed = true;
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
}
|
||||
}
|
||||
|
||||
if (craft) {
|
||||
changed = true;
|
||||
processed = true;
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
}
|
||||
}
|
||||
} while (changed && !interrupted(guiContainer));
|
||||
|
||||
} while (changed && !interrupted(guiContainer));
|
||||
|
||||
StackInfo.pauseItemDamageSound(false);
|
||||
} finally {
|
||||
StackInfo.pauseItemDamageSound(false);
|
||||
}
|
||||
|
||||
if (processed && !changed && !interrupted(guiContainer)) {
|
||||
NEIClientUtils.playClickSound();
|
||||
|
||||
@@ -36,6 +36,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
public int numSlots;
|
||||
public int recipeAmount;
|
||||
public boolean isContainerItem = false;
|
||||
public long damagePerContainerCraft;
|
||||
}
|
||||
|
||||
public static class IngredientDistribution {
|
||||
@@ -123,6 +124,11 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
if (craftingSlot.getHasStack() && craftingSlot.canTakeStack(firstGui.mc.thePlayer)) {
|
||||
FastTransferManager.clickSlot(firstGui, craftingSlot.slotNumber, 0, 1);
|
||||
|
||||
if (craftingSlot.getHasStack()) {
|
||||
break;
|
||||
}
|
||||
|
||||
craft = true;
|
||||
}
|
||||
|
||||
@@ -259,6 +265,11 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
final int maxStackSize = istack.stack.getMaxStackSize();
|
||||
if (maxStackSize == 1 && istack.isContainerItem) {
|
||||
|
||||
if (istack.damagePerContainerCraft > 0) {
|
||||
quantity = (int) Math.min(quantity, istack.damagePerContainerCraft);
|
||||
}
|
||||
|
||||
// If non-stackable, fill up as much as possible of the other ingredients
|
||||
continue;
|
||||
}
|
||||
@@ -372,7 +383,14 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
final NBTTagCompound tagCompound = pstack.getTagCompound();
|
||||
|
||||
if (tagCompound != null && tagCompound.hasKey("GT.ToolStats")) {
|
||||
final NBTTagCompound toolStats = tagCompound.getCompoundTag("GT.ToolStats");
|
||||
final long damagePerContainerCraft = getGTToolDamagePerContainerCraft(pstack);
|
||||
final long maxDamage = toolStats.getLong("MaxDamage");
|
||||
final long damage = toolStats.getLong("Damage");
|
||||
|
||||
istack.isContainerItem = true;
|
||||
istack.damagePerContainerCraft = (maxDamage - damage + damagePerContainerCraft - 1)
|
||||
/ damagePerContainerCraft;
|
||||
} else {
|
||||
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
@@ -390,6 +408,19 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private int getGTToolDamagePerContainerCraft(ItemStack aStack) {
|
||||
|
||||
try {
|
||||
final Object toolStats = aStack.getItem().getClass().getMethod("getToolStats", ItemStack.class)
|
||||
.invoke(aStack.getItem(), aStack);
|
||||
return (int) toolStats.getClass().getMethod("getToolDamagePerContainerCraft").invoke(toolStats);
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected List<DistributedIngred> getPermutationIngredients(List<PositionedStack> ingredients) {
|
||||
ArrayList<DistributedIngred> ingredStacks = new ArrayList<>();
|
||||
for (PositionedStack posstack : ingredients) /* work out what we need */ {
|
||||
|
||||
@@ -436,6 +436,10 @@ public class NEIRecipeWidget extends Widget {
|
||||
|| this.acceptsFollowingTooltipLineHandler.tooltipGUID != hovered) {
|
||||
this.acceptsFollowingTooltipLineHandler = AcceptsFollowingTooltipLineHandler
|
||||
.of(hovered, this.permutations.get(hovered), hovered.item);
|
||||
|
||||
if (this.acceptsFollowingTooltipLineHandler != null && hovered.getAcceptsLabel() != null) {
|
||||
this.acceptsFollowingTooltipLineHandler.setLabel(hovered.getAcceptsLabel());
|
||||
}
|
||||
}
|
||||
} else if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
this.acceptsFollowingTooltipLineHandler = null;
|
||||
|
||||
@@ -335,40 +335,43 @@ public class RecipeChainMath {
|
||||
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
|
||||
resetCalculation();
|
||||
try {
|
||||
resetCalculation();
|
||||
|
||||
if (this.outputRecipes.containsKey(ROOT_RECIPE_ID)) {
|
||||
for (BookmarkItem ingrItem : this.recipeIngredients) {
|
||||
if (ROOT_RECIPE_ID.equals(ingrItem.recipeId)
|
||||
&& ingrItem.itemStack.getItem().hasContainerItem(ingrItem.itemStack)) {
|
||||
this.containerItemsBlacklist.add(ingrItem.itemStack);
|
||||
if (this.outputRecipes.containsKey(ROOT_RECIPE_ID)) {
|
||||
for (BookmarkItem ingrItem : this.recipeIngredients) {
|
||||
if (ROOT_RECIPE_ID.equals(ingrItem.recipeId)
|
||||
&& ingrItem.itemStack.getItem().hasContainerItem(ingrItem.itemStack)) {
|
||||
this.containerItemsBlacklist.add(ingrItem.itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkItem prefItem : this.recipeResults) {
|
||||
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)) {
|
||||
final long prefMultiplier = this.outputRecipes.get(prefItem.recipeId);
|
||||
for (BookmarkItem prefItem : this.recipeResults) {
|
||||
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)) {
|
||||
final long prefMultiplier = this.outputRecipes.get(prefItem.recipeId);
|
||||
|
||||
if (prefItem.itemStack.getItem().hasContainerItem(prefItem.itemStack)) {
|
||||
this.containerItemsBlacklist.add(prefItem.itemStack);
|
||||
if (prefItem.itemStack.getItem().hasContainerItem(prefItem.itemStack)) {
|
||||
this.containerItemsBlacklist.add(prefItem.itemStack);
|
||||
}
|
||||
|
||||
this.preferredItems.put(prefItem, prefItem);
|
||||
calculateSuitableRecipe(prefItem, prefMultiplier, new ArrayList<>(), visitor);
|
||||
this.preferredItems.remove(prefItem);
|
||||
}
|
||||
|
||||
this.preferredItems.put(prefItem, prefItem);
|
||||
calculateSuitableRecipe(prefItem, prefMultiplier, new ArrayList<>(), visitor);
|
||||
this.preferredItems.remove(prefItem);
|
||||
}
|
||||
|
||||
for (BookmarkItem prefItem : this.recipeResults) {
|
||||
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)
|
||||
&& this.requiredAmount.containsKey(prefItem)) {
|
||||
final long prefAmount = prefItem.getAmount(this.outputRecipes.get(prefItem.recipeId));
|
||||
this.requiredAmount.put(prefItem, this.requiredAmount.get(prefItem) - prefAmount);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
StackInfo.pauseItemDamageSound(isPausedItemDamageSound);
|
||||
}
|
||||
|
||||
for (BookmarkItem prefItem : this.recipeResults) {
|
||||
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)
|
||||
&& this.requiredAmount.containsKey(prefItem)) {
|
||||
final long prefAmount = prefItem.getAmount(this.outputRecipes.get(prefItem.recipeId));
|
||||
this.requiredAmount.put(prefItem, this.requiredAmount.get(prefItem) - prefAmount);
|
||||
}
|
||||
}
|
||||
|
||||
StackInfo.pauseItemDamageSound(isPausedItemDamageSound);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user