mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 22:44:36 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c33d8f674a | ||
|
|
8515d9ef88 | ||
|
|
477b955247 | ||
|
|
ce2610923c | ||
|
|
e069188aab | ||
|
|
308febfed0 | ||
|
|
9f4968524a | ||
|
|
177b37f63d | ||
|
|
8e5f3c49b1 | ||
|
|
ef310b30ce |
No files matched your search
@@ -192,10 +192,9 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
builder = BookmarkItem.builder(groupId, itemStack, recipe, BookmarkItemType.RESULT).multiplier(1);
|
||||
} else if (recipeId != null) {
|
||||
builder = BookmarkItem.builder(groupId, itemStack).recipeId(recipeId)
|
||||
.factor(StackInfo.getAmountLong(itemStack)).multiplier(1);
|
||||
.factor(StackInfo.getAmount(itemStack)).multiplier(1);
|
||||
} else {
|
||||
builder = BookmarkItem.builder(groupId, itemStack).factor(1)
|
||||
.multiplier(StackInfo.getAmountLong(itemStack));
|
||||
builder = BookmarkItem.builder(groupId, itemStack).factor(1).multiplier(StackInfo.getAmount(itemStack));
|
||||
}
|
||||
|
||||
if (existsRecipe) {
|
||||
@@ -262,7 +261,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
builder = BookmarkItem.builder(groupId, stack, recipe, BookmarkItemType.RESULT);
|
||||
} else {
|
||||
builder = BookmarkItem.builder(groupId, stack).recipeId(recipeId)
|
||||
.factor(StackInfo.getAmountLong(stack));
|
||||
.factor(StackInfo.getAmount(stack));
|
||||
}
|
||||
|
||||
this.grid.addItem(builder.multiplier(1).type(BookmarkItemType.ITEM).build(), true);
|
||||
@@ -554,7 +553,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemsGrid.ItemsGridSlot;
|
||||
import codechicken.nei.ItemsGrid.MouseContext;
|
||||
import codechicken.nei.NEIClientUtils.Alignment;
|
||||
import codechicken.nei.recipe.AutoCraftingManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
@@ -39,7 +40,7 @@ public class ItemCraftablesPanel
|
||||
|
||||
public CraftablesGridSlot(int slotIndex, int itemIndex, ItemStack itemStack, RecipeId recipeId) {
|
||||
super(slotIndex, itemIndex, itemStack);
|
||||
this.realAmount = StackInfo.getAmountLong(itemStack);
|
||||
this.realAmount = StackInfo.getAmount(itemStack);
|
||||
this.isFluidDisplay = StackInfo.isFluidDisplayItem(itemStack);
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
@@ -215,7 +216,7 @@ public class ItemCraftablesPanel
|
||||
|
||||
@Override
|
||||
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,7 +268,7 @@ public class ItemCraftablesPanel
|
||||
if (firstGui != null && !ItemCraftablesPanel.guiBlacklist.contains(firstGui.getClass().getName())) {
|
||||
final boolean showOnlyFavorites = NEIClientConfig
|
||||
.getBooleanSetting("inventory.craftables.favoritesOnly");
|
||||
final ItemStackAmount inv = ItemStackAmount.of(firstGui);
|
||||
final ItemStackAmount inv = AutoCraftingManager.getInventoryItems(firstGui);
|
||||
|
||||
if (this.lastGuiContainer != firstGui
|
||||
|| showOnlyFavorites && this.lastFavoritesCount != FavoriteRecipes.size()
|
||||
@@ -316,7 +317,7 @@ public class ItemCraftablesPanel
|
||||
final Map<ItemStack, RecipeId> availableRecipes = new HashMap<>();
|
||||
|
||||
if (!availableHandlers.isEmpty()) {
|
||||
final Map<Item, List<ItemStack>> invByItem = snapshot.inventory.groupByItem();
|
||||
final Map<Item, List<ItemStack>> invByItem = indexInventoryByItem(snapshot.inventory.values());
|
||||
|
||||
if (snapshot.showOnlyFavorites) {
|
||||
for (IRecipeHandler handler : availableHandlers) {
|
||||
@@ -348,6 +349,16 @@ public class ItemCraftablesPanel
|
||||
return availableHandlers;
|
||||
}
|
||||
|
||||
private static Map<Item, List<ItemStack>> indexInventoryByItem(List<ItemStack> invStacks) {
|
||||
final Map<Item, List<ItemStack>> index = new HashMap<>();
|
||||
|
||||
for (ItemStack stack : invStacks) {
|
||||
index.computeIfAbsent(stack.getItem(), i -> new ArrayList<>()).add(stack);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
private void collectHandlerCandidates(IRecipeHandler handler, Map<Item, List<ItemStack>> invByItem,
|
||||
List<RecipeCandidate> candidates) {
|
||||
IntStream.range(0, handler.numRecipes()).parallel().forEach(recipeIndex -> {
|
||||
@@ -389,11 +400,11 @@ public class ItemCraftablesPanel
|
||||
}
|
||||
|
||||
final ItemStack stack = Recipe.getMainResult(results, pStack -> pStack.items[0]).item;
|
||||
long stackSize = 0;
|
||||
int stackSize = 0;
|
||||
|
||||
for (PositionedStack result : results) {
|
||||
if (containsSameType(result, stack)) {
|
||||
stackSize += StackInfo.getAmountLong(result.item);
|
||||
stackSize += StackInfo.getAmount(result.item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,8 +448,36 @@ public class ItemCraftablesPanel
|
||||
return availableRecipes;
|
||||
}
|
||||
|
||||
private static boolean existsIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> invByItem) {
|
||||
return !ingredients.isEmpty() && NEIClientUtils.countMissingIngredients(ingredients, invByItem, 1) == 0;
|
||||
private boolean existsIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> invByItem) {
|
||||
final Map<ItemStack, Integer> usedItems = new HashMap<>();
|
||||
|
||||
for (PositionedStack pStack : ingredients) {
|
||||
ItemStack used = null;
|
||||
|
||||
for (ItemStack permutation : pStack.items) {
|
||||
final List<ItemStack> candidates = invByItem.get(permutation.getItem());
|
||||
|
||||
if (candidates == null) continue;
|
||||
|
||||
for (ItemStack is : candidates) {
|
||||
if (usedItems.getOrDefault(is, is.stackSize) >= pStack.item.stackSize
|
||||
&& NEIServerUtils.areStacksSameTypeCrafting(permutation, is)) {
|
||||
used = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (used != null) break;
|
||||
}
|
||||
|
||||
if (used != null) {
|
||||
usedItems.put(used, usedItems.getOrDefault(used, used.stackSize) - pStack.item.stackSize);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !usedItems.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,12 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -34,7 +29,7 @@ public class ItemStackAmount {
|
||||
}
|
||||
|
||||
public void add(ItemStack item) {
|
||||
add(item, StackInfo.getAmountLong(item));
|
||||
add(item, (long) StackInfo.getAmount(item));
|
||||
}
|
||||
|
||||
public void add(ItemStack stack, Long value) {
|
||||
@@ -101,16 +96,6 @@ public class ItemStackAmount {
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<Item, List<ItemStack>> groupByItem() {
|
||||
final Map<Item, List<ItemStack>> groups = new HashMap<>();
|
||||
|
||||
for (ItemStack stack : values()) {
|
||||
groups.computeIfAbsent(stack.getItem(), i -> new ArrayList<>()).add(stack);
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.itemMap.size();
|
||||
}
|
||||
@@ -155,16 +140,4 @@ public class ItemStackAmount {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ItemStackAmount of(GuiContainer gui) {
|
||||
final ItemStackAmount result = new ItemStackAmount();
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(gui.mc.thePlayer)) {
|
||||
result.add(slot.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -312,8 +312,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
|
||||
if (StackInfo.isFluidDisplayItem(stack.item)) {
|
||||
final FluidStack requiredFluid = StackInfo.getFluid(stack.item);
|
||||
found = requiredFluid != null
|
||||
&& consumeFluid(invStacks, remainingFluid, requiredFluid, StackInfo.getAmountLong(stack.item));
|
||||
found = requiredFluid != null && consumeFluid(invStacks, remainingFluid, requiredFluid);
|
||||
} else {
|
||||
found = false;
|
||||
|
||||
@@ -333,8 +332,8 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
private static boolean consumeFluid(List<ItemStack> invStacks, Map<ItemStack, Long> remainingFluid,
|
||||
FluidStack requiredFluid, long requiredAmount) {
|
||||
long need = requiredAmount;
|
||||
FluidStack requiredFluid) {
|
||||
long need = requiredFluid.amount;
|
||||
final List<ItemStack> matched = new ArrayList<>();
|
||||
|
||||
for (ItemStack is : invStacks) {
|
||||
@@ -365,7 +364,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
long remainingNeed = requiredAmount;
|
||||
long remainingNeed = requiredFluid.amount;
|
||||
for (ItemStack is : matched) {
|
||||
final long available = remainingFluid.get(is);
|
||||
final long consumed = Math.min(available, remainingNeed);
|
||||
@@ -539,40 +538,6 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int countMissingIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> index,
|
||||
int limit) {
|
||||
Map<ItemStack, Integer> usedItems = new HashMap<>();
|
||||
int missing = 0;
|
||||
|
||||
for (PositionedStack pStack : ingredients) {
|
||||
ItemStack used = null;
|
||||
|
||||
for (ItemStack permutation : pStack.items) {
|
||||
final List<ItemStack> candidates = index.get(permutation.getItem());
|
||||
|
||||
if (candidates == null) continue;
|
||||
|
||||
for (ItemStack is : candidates) {
|
||||
if (usedItems.getOrDefault(is, is.stackSize) >= pStack.item.stackSize
|
||||
&& NEIServerUtils.areStacksSameTypeCrafting(permutation, is)) {
|
||||
used = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (used != null) break;
|
||||
}
|
||||
|
||||
if (used != null) {
|
||||
usedItems.put(used, usedItems.getOrDefault(used, used.stackSize) - pStack.item.stackSize);
|
||||
} else if (++missing >= limit) {
|
||||
return missing;
|
||||
}
|
||||
}
|
||||
|
||||
return missing;
|
||||
}
|
||||
|
||||
public static boolean altKey() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
|
||||
}
|
||||
|
||||
@@ -303,9 +303,8 @@ public class PositionedStack implements Cloneable {
|
||||
|
||||
if (fluidStack != null && this.capacity > 0) {
|
||||
tooltip.add(
|
||||
EnumChatFormatting.GRAY + NEIClientUtils.translate(
|
||||
"recipe.fluid.tank.amount",
|
||||
NEIClientUtils.formatFluid(StackInfo.getAmountLong(this.item))));
|
||||
EnumChatFormatting.GRAY + NEIClientUtils
|
||||
.translate("recipe.fluid.tank.amount", NEIClientUtils.formatFluid(fluidStack.amount)));
|
||||
}
|
||||
|
||||
if (customTooltip != null) {
|
||||
|
||||
@@ -30,6 +30,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
private static final MobOverlayScan MOB_OVERLAY_SCAN = new MobOverlayScan();
|
||||
private static final MobOverlayFace MARKED_FACE = new MobOverlayFace();
|
||||
private static final MobOverlayDisplayList MOB_OVERLAY_LIST = new MobOverlayDisplayList();
|
||||
private static final byte[] COLUMN_CELLS = new byte[2 * MobOverlayScan.MAX_VERTICAL_RADIUS + 1];
|
||||
|
||||
public static void reset() {
|
||||
mobOverlay = 0;
|
||||
@@ -83,10 +84,6 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
/**
|
||||
* The model view matrix is relative to ({@code intOffsetX}, {@code intOffsetY}, {@code intOffsetZ}), the camera
|
||||
* position cast to {@code int}.
|
||||
*/
|
||||
private static void renderMobSpawnOverlay(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
|
||||
if (mobOverlay == 0) {
|
||||
MOB_OVERLAY_SCAN.clear();
|
||||
@@ -110,29 +107,49 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
endMobOverlayDraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a marked face to {@link #MOB_OVERLAY_LIST} for each block of {@link #MOB_OVERLAY_SCAN} where mobs can spawn.
|
||||
*/
|
||||
private static void compileMobOverlayList(MobOverlayStyle style, long worldTicks) {
|
||||
MOB_OVERLAY_LIST.beginCompile(MOB_OVERLAY_SCAN, style, worldTicks);
|
||||
for (int chunkX = MOB_OVERLAY_SCAN.getMinChunkX(); chunkX <= MOB_OVERLAY_SCAN.getMaxChunkX(); chunkX++) {
|
||||
for (int chunkZ = MOB_OVERLAY_SCAN.getMinChunkZ(); chunkZ <= MOB_OVERLAY_SCAN.getMaxChunkZ(); chunkZ++) {
|
||||
if (!MOB_OVERLAY_LIST.beginChunk(MOB_OVERLAY_SCAN, chunkX, chunkZ)) continue;
|
||||
|
||||
MOB_OVERLAY_LIST.endChunk(compileChunkFaces(style, chunkX, chunkZ));
|
||||
}
|
||||
}
|
||||
MOB_OVERLAY_LIST.endCompile(MOB_OVERLAY_SCAN);
|
||||
}
|
||||
|
||||
private static boolean compileChunkFaces(MobOverlayStyle style, int chunkX, int chunkZ) {
|
||||
final int CHUNK_WIDTH = 1 << MobOverlayScan.CHUNK_SHIFT;
|
||||
final float alpha = style.computeAlpha();
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawing(style.glMode);
|
||||
final int cornerX = chunkX << MobOverlayScan.CHUNK_SHIFT;
|
||||
final int cornerZ = chunkZ << MobOverlayScan.CHUNK_SHIFT;
|
||||
final int minX = MOB_OVERLAY_SCAN.getMinX();
|
||||
final int minZ = MOB_OVERLAY_SCAN.getMinZ();
|
||||
final int span = MOB_OVERLAY_SCAN.getSpan();
|
||||
for (int i = 0; i < span; i++) {
|
||||
for (int j = 0; j < span; j++) {
|
||||
for (int k = 0; k < MOB_OVERLAY_SCAN.getHeight(); k++) {
|
||||
if (MOB_OVERLAY_SCAN.readSpawnMode(i, k, j) == 0) continue;
|
||||
final int height = MOB_OVERLAY_SCAN.getHeight();
|
||||
boolean hasFaces = false;
|
||||
tess.startDrawing(style.glMode);
|
||||
for (int i = Math.max(cornerX - minX, 0); i < Math.min(cornerX + CHUNK_WIDTH - minX, span); i++) {
|
||||
for (int j = Math.max(cornerZ - minZ, 0); j < Math.min(cornerZ + CHUNK_WIDTH - minZ, span); j++) {
|
||||
MOB_OVERLAY_SCAN.readColumn(i, j, COLUMN_CELLS);
|
||||
for (int k = 0; k < height; k++) {
|
||||
if (MobOverlayScan.extractSpawnMode(COLUMN_CELLS[k]) == 0) continue;
|
||||
|
||||
MARKED_FACE.moveTo(i, k + MOB_OVERLAY_SCAN.readOverlayYOffset(i, k, j), j);
|
||||
MARKED_FACE.moveTo(
|
||||
minX + i - cornerX,
|
||||
k + MobOverlayScan.computeOverlayYOffset(COLUMN_CELLS[k]),
|
||||
minZ + j - cornerZ);
|
||||
loadNeighbourModes(i, k, j);
|
||||
MARKED_FACE.applyColor(style.colouring, alpha);
|
||||
style.addVertices(MARKED_FACE);
|
||||
hasFaces = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
tess.draw();
|
||||
MOB_OVERLAY_LIST.endCompile();
|
||||
return hasFaces;
|
||||
}
|
||||
|
||||
private static void beginMobOverlayDraw(MobOverlayStyle style) {
|
||||
@@ -147,7 +164,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glLineWidth(1.5F);
|
||||
// the outline of `MobOverlayStyle.CONNECTED` lies in the plane of the tint. With depth writes on, the depth
|
||||
// the outline of `MobOverlayStyle.CONNECTED` lies in the plane of the tint. When depth writes are on, the depth
|
||||
// test discards most of the outline
|
||||
GL11.glDepthMask(false);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import codechicken.nei.BookmarkContainerInfo;
|
||||
import codechicken.nei.FavoriteRecipes;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemQuantityField;
|
||||
import codechicken.nei.ItemStackAmount;
|
||||
import codechicken.nei.KeyManager;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
@@ -718,7 +717,7 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
private static void autocraftingIgnoreInventory(RecipeChainMath math) {
|
||||
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
|
||||
final List<ItemStack> playerInventory = ItemStackAmount.of(guiContainer).values();
|
||||
final List<ItemStack> playerInventory = AutoCraftingManager.getInventoryItems(guiContainer).values();
|
||||
final RecipeId rootRecipeId = math.createMasterRoot();
|
||||
|
||||
for (int i = 0; i < math.recipeIngredients.size(); i++) {
|
||||
@@ -729,7 +728,7 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
for (ItemStack stack : playerInventory) {
|
||||
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
||||
amount += StackInfo.getAmountLong(stack);
|
||||
amount += StackInfo.getAmount(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,8 +194,7 @@ public class BookmarkGridGenerator {
|
||||
|| group.crafting.calculatedItems.get(shadowIndex).calculatedType == CalculatedType.INGREDIENT;
|
||||
|
||||
final BookmarkItem shadowBookmarkItem = BookmarkItem.builder(bookmarkItem.groupId, bookmarkItem.itemStack)
|
||||
.multiplier(1).factor(StackInfo.getAmountLong(bookmarkItem.itemStack))
|
||||
.recipeId(bookmarkItem.recipeId)
|
||||
.multiplier(1).factor(StackInfo.getAmount(bookmarkItem.itemStack)).recipeId(bookmarkItem.recipeId)
|
||||
.type(isIngredient ? BookmarkItemType.INGREDIENT : BookmarkItemType.RESULT)
|
||||
.permutations(Collections.emptyMap()).build();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BookmarkItem {
|
||||
|
||||
this.groupId = groupId;
|
||||
this.stack = stack;
|
||||
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.max(nbTag.getLong("Count"), 1) : 1;
|
||||
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.max(nbTag.getInteger("Count"), 1) : 1;
|
||||
}
|
||||
|
||||
public Builder factor(long factor) {
|
||||
@@ -105,7 +105,7 @@ public class BookmarkItem {
|
||||
if (this.multiplier >= 0) {
|
||||
multiplier = this.multiplier;
|
||||
} else if (this.factor > 0) {
|
||||
multiplier = StackInfo.getAmountLong(this.stack) / this.factor;
|
||||
multiplier = StackInfo.getAmount(this.stack) / this.factor;
|
||||
}
|
||||
|
||||
return new BookmarkItem(
|
||||
@@ -234,7 +234,7 @@ public class BookmarkItem {
|
||||
for (RecipeIngredient res : items) {
|
||||
for (ItemStack perm : res.getPermutations()) {
|
||||
if (NEIClientUtils.areStacksSameTypeWithNBT(emptyStack, StackInfo.withAmount(perm, 0))) {
|
||||
amount += 1L * StackInfo.getAmountLong(perm) * res.getChance();
|
||||
amount += 1L * StackInfo.getAmount(perm) * res.getChance();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -271,15 +271,15 @@ public class BookmarkItem {
|
||||
}
|
||||
|
||||
if (jsonObject.has("multiplier")) {
|
||||
builder.multiplier(jsonObject.get("multiplier").getAsLong());
|
||||
builder.multiplier(jsonObject.get("multiplier").getAsInt());
|
||||
}
|
||||
|
||||
if (jsonObject.has("factor")) {
|
||||
builder.factor(jsonObject.get("factor").getAsLong());
|
||||
builder.factor(jsonObject.get("factor").getAsInt());
|
||||
}
|
||||
|
||||
if (jsonObject.has("chance")) {
|
||||
builder.chance(jsonObject.get("chance").getAsLong());
|
||||
builder.chance(jsonObject.get("chance").getAsInt());
|
||||
}
|
||||
|
||||
if (jsonObject.get("recipeId") instanceof JsonObject recipeJson) {
|
||||
@@ -320,9 +320,8 @@ public class BookmarkItem {
|
||||
final ItemStack newPerm = findPermutation(stack);
|
||||
|
||||
if (oldPerm != null && newPerm != null) {
|
||||
final long oldAmount = StackInfo.getAmountLong(oldPerm);
|
||||
final long amount = oldAmount > 0
|
||||
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
|
||||
final long oldAmount = StackInfo.getAmount(oldPerm);
|
||||
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
|
||||
: 0;
|
||||
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
||||
: 1;
|
||||
@@ -370,9 +369,8 @@ public class BookmarkItem {
|
||||
final ItemStack newPerm = findPermutation(perm);
|
||||
|
||||
if (oldPerm != null && newPerm != null) {
|
||||
final long oldAmount = StackInfo.getAmountLong(oldPerm);
|
||||
final long amount = oldAmount > 0
|
||||
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
|
||||
final long oldAmount = StackInfo.getAmount(oldPerm);
|
||||
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
|
||||
: 0;
|
||||
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
||||
: 1;
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemStackAmount;
|
||||
import codechicken.nei.KeyManager;
|
||||
import codechicken.nei.LRUCache;
|
||||
import codechicken.nei.NEICPH;
|
||||
@@ -61,6 +60,7 @@ import codechicken.nei.guihook.IGuiClientSide;
|
||||
import codechicken.nei.guihook.IGuiHandleMouseWheel;
|
||||
import codechicken.nei.guihook.IGuiHotkeyListener;
|
||||
import codechicken.nei.recipe.AcceptsFollowingTooltipLineHandler;
|
||||
import codechicken.nei.recipe.AutoCraftingManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiOverlayButton;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
@@ -284,8 +284,10 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
|
||||
final GuiContainer firstGui = getFirstScreen();
|
||||
|
||||
if (firstGui != null) {
|
||||
for (ItemStack stack : ItemStackAmount.of(firstGui).values()) {
|
||||
this.math.initialItems.add(BookmarkItem.of(-1, stack));
|
||||
for (ItemStack stack : AutoCraftingManager.getInventoryItems(firstGui).values()) {
|
||||
if (stack != null) {
|
||||
this.math.initialItems.add(BookmarkItem.of(-1, stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ class StatsPanel extends ScrollContainer {
|
||||
|
||||
public ItemStack getStackMouseOver(int mouseX, int mouseY) {
|
||||
final Widget widget = getWidgetUnderMouse(mouseX, mouseY);
|
||||
return widget instanceof ItemStatsSlot slot ? slot.getStack() : null;
|
||||
return widget instanceof ItemStatsSlot slot && slot.recipeId == null ? slot.getStack() : null;
|
||||
}
|
||||
|
||||
public void setHighlight(SearchResult searchResult) {
|
||||
|
||||
@@ -51,7 +51,6 @@ import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIModContainer;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
import codechicken.nei.util.ItemUntranslator;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
import codechicken.nei.util.RenderTooltipEventHelper;
|
||||
@@ -230,9 +229,7 @@ public class GuiContainerManager {
|
||||
public static String itemCountDetails(ItemStack stack) {
|
||||
final FluidStack fluid = StackInfo.getFluid(stack);
|
||||
if (fluid != null) {
|
||||
// The fluid of a display item is limited to an int, its stored amount is not
|
||||
final long amount = StackInfo.isFluidDisplayItem(stack) ? StackInfo.getAmountLong(stack) : fluid.amount;
|
||||
return fluidAmountDetails(amount * Math.max(1, stack.stackSize));
|
||||
return fluidAmountDetails(fluid.amount * Math.max(1, stack.stackSize));
|
||||
} else {
|
||||
return countDetails(
|
||||
stack.stackSize,
|
||||
@@ -246,35 +243,17 @@ public class GuiContainerManager {
|
||||
@SuppressWarnings("unused")
|
||||
@Nullable
|
||||
public static String fluidAmountDetails(FluidStack fluid) {
|
||||
return fluidAmountDetails(GTFluidStackStringifyHandler.getFluidAmount(fluid));
|
||||
return fluidAmountDetails(fluid.amount);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String fluidAmountDetails(int amount) {
|
||||
return fluidAmountDetails((long) amount);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String fluidAmountDetails(long amount) {
|
||||
if (amount <= 144) return null;
|
||||
|
||||
final long remainder = amount % 144;
|
||||
final String units = NEIClientUtils.formatNumber(amount / 144);
|
||||
|
||||
if (remainder > 0) {
|
||||
return String.format(
|
||||
translate("inventory.tooltip.count.fluid", "%s = %s * %s + %s"),
|
||||
NEIClientUtils.formatFluid(amount),
|
||||
units,
|
||||
NEIClientUtils.formatFluid(144),
|
||||
NEIClientUtils.formatFluid(remainder));
|
||||
}
|
||||
|
||||
return String.format(
|
||||
return countDetails(
|
||||
amount,
|
||||
144,
|
||||
translate("inventory.tooltip.count.fluid", "%s = %s * %s + %s"),
|
||||
translate("inventory.tooltip.count.fluid", "%s = %s * %s"),
|
||||
NEIClientUtils.formatFluid(amount),
|
||||
units,
|
||||
NEIClientUtils.formatFluid(144));
|
||||
NEIClientUtils::formatFluid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +640,7 @@ public class GuiContainerManager {
|
||||
tooltip = handler.handleTooltip(window, mousex, mousey, tooltip);
|
||||
}
|
||||
|
||||
ItemStack stack = tooltip.isEmpty() ? getStackMouseOver(window) : null;
|
||||
ItemStack stack = getStackMouseOver(window);
|
||||
boolean showTooltip = shouldShowTooltip(window);
|
||||
if (tooltip.isEmpty() && showTooltip) { // mouseover tip, not holding an item
|
||||
font = getFontRenderer(stack);
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -47,8 +46,7 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
public static ItemStack createStack(FluidStack fluidStack) {
|
||||
return fluidStack == null ? null
|
||||
: createStack(fluidStack.getFluid(), GTFluidStackStringifyHandler.getFluidAmount(fluidStack));
|
||||
return fluidStack == null ? null : createStack(fluidStack.getFluid(), fluidStack.amount);
|
||||
}
|
||||
|
||||
public static ItemStack createStack(Fluid fluid, long amount) {
|
||||
|
||||
@@ -1,65 +1,117 @@
|
||||
package codechicken.nei.moboverlay;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/** The mob spawn overlay quads, compiled into a GL display list. */
|
||||
/**
|
||||
* {@code MobOverlayDisplayList} compiles the overlay quads of each chunk column of a {@link MobOverlayScan} box into
|
||||
* one GL display list. A compile rebuilds only the lists whose {@link MobOverlayScan#readChunkVersion} changed.
|
||||
*/
|
||||
public final class MobOverlayDisplayList {
|
||||
|
||||
private int listId = -1;
|
||||
private static final int NO_LIST = -1;
|
||||
|
||||
private int firstListId = NO_LIST;
|
||||
private int parentListId = NO_LIST;
|
||||
private int anchorX;
|
||||
private int anchorY;
|
||||
private int anchorZ;
|
||||
private int chunkSpan;
|
||||
private boolean[] isCompiled = new boolean[0];
|
||||
private boolean[] hasFaces = new boolean[0];
|
||||
private int[] compiledChunkVersion = new int[0];
|
||||
private int modesVersion;
|
||||
private MobOverlayStyle style;
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
private long compiledTicks;
|
||||
private int compilingChunk;
|
||||
|
||||
/**
|
||||
* Compiles after a {@link MobOverlayScan#getModesVersion} change are debounced to one per {@code MIN_COMPILE_TICKS}
|
||||
* ticks, because the version changes several times per second while the player moves fast, and a compile runs for a
|
||||
* millisecond or more.
|
||||
*/
|
||||
public boolean isCompileDue(int currentModesVersion, MobOverlayStyle currentStyle, long worldTicks) {
|
||||
final int MIN_COMPILE_TICKS = 5;
|
||||
if (listId < 0 || style != currentStyle) return true;
|
||||
if (firstListId == NO_LIST || style != currentStyle) return true;
|
||||
|
||||
// after a dimension change or a server switch, `worldTicks` can be lower than `compiledTicks`
|
||||
final boolean isWaitOver = worldTicks - compiledTicks >= MIN_COMPILE_TICKS || worldTicks < compiledTicks;
|
||||
return modesVersion != currentModesVersion && isWaitOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quad positions are relative to block ({@link MobOverlayScan#getMinX}, {@link MobOverlayScan#getMinY},
|
||||
* {@link MobOverlayScan#getMinZ}) of {@code scan}.
|
||||
*/
|
||||
public void beginCompile(MobOverlayScan scan, MobOverlayStyle newStyle, long worldTicks) {
|
||||
if (listId < 0) listId = GLAllocation.generateDisplayLists(1);
|
||||
if (chunkSpan != scan.getChunkSpan()) resize(scan.getChunkSpan());
|
||||
if (style != newStyle) Arrays.fill(isCompiled, false);
|
||||
modesVersion = scan.getModesVersion();
|
||||
style = newStyle;
|
||||
minX = scan.getMinX();
|
||||
minY = scan.getMinY();
|
||||
minZ = scan.getMinZ();
|
||||
compiledTicks = worldTicks;
|
||||
GL11.glNewList(listId, GL11.GL_COMPILE);
|
||||
anchorX = scan.getMinX();
|
||||
anchorY = scan.getMinY();
|
||||
anchorZ = scan.getMinZ();
|
||||
}
|
||||
|
||||
public void endCompile() {
|
||||
public boolean beginChunk(MobOverlayScan scan, int chunkX, int chunkZ) {
|
||||
final int chunk = scan.findChunk(chunkX, chunkZ);
|
||||
final int chunkVersion = scan.readChunkVersion(chunkX, chunkZ);
|
||||
if (isCompiled[chunk] && compiledChunkVersion[chunk] == chunkVersion) return false;
|
||||
|
||||
isCompiled[chunk] = true;
|
||||
compiledChunkVersion[chunk] = chunkVersion;
|
||||
compilingChunk = chunk;
|
||||
GL11.glNewList(firstListId + chunk, GL11.GL_COMPILE);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void endChunk(boolean hasChunkFaces) {
|
||||
GL11.glEndList();
|
||||
hasFaces[compilingChunk] = hasChunkFaces;
|
||||
}
|
||||
|
||||
public void endCompile(MobOverlayScan scan) {
|
||||
GL11.glNewList(parentListId, GL11.GL_COMPILE);
|
||||
for (int chunkX = scan.getMinChunkX(); chunkX <= scan.getMaxChunkX(); chunkX++) {
|
||||
for (int chunkZ = scan.getMinChunkZ(); chunkZ <= scan.getMaxChunkZ(); chunkZ++) {
|
||||
final int chunk = scan.findChunk(chunkX, chunkZ);
|
||||
if (!hasFaces[chunk]) continue;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(
|
||||
(chunkX << MobOverlayScan.CHUNK_SHIFT) - anchorX,
|
||||
0,
|
||||
(chunkZ << MobOverlayScan.CHUNK_SHIFT) - anchorZ);
|
||||
GL11.glCallList(firstListId + chunk);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
/** The model view matrix is relative to block ({@code cameraX}, {@code cameraY}, {@code cameraZ}). */
|
||||
public void draw(int cameraX, int cameraY, int cameraZ) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(minX - cameraX, minY - cameraY, minZ - cameraZ);
|
||||
GL11.glCallList(listId);
|
||||
GL11.glTranslated(anchorX - cameraX, anchorY - cameraY, anchorZ - cameraZ);
|
||||
GL11.glCallList(parentListId);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (listId < 0) return;
|
||||
private void resize(int newChunkSpan) {
|
||||
final int chunkCount = newChunkSpan * newChunkSpan;
|
||||
delete();
|
||||
|
||||
GLAllocation.deleteDisplayLists(listId);
|
||||
listId = -1;
|
||||
chunkSpan = newChunkSpan;
|
||||
firstListId = GLAllocation.generateDisplayLists(chunkCount + 1);
|
||||
parentListId = firstListId + chunkCount;
|
||||
|
||||
isCompiled = new boolean[chunkCount];
|
||||
hasFaces = new boolean[chunkCount];
|
||||
compiledChunkVersion = new int[chunkCount];
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (firstListId == NO_LIST) return;
|
||||
|
||||
GLAllocation.deleteDisplayLists(firstListId);
|
||||
firstListId = NO_LIST;
|
||||
parentListId = NO_LIST;
|
||||
chunkSpan = 0;
|
||||
Arrays.fill(isCompiled, false);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package codechicken.nei.moboverlay;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
/** Vertex builder for one block's top face in the mob spawn overlay. */
|
||||
/** {@code MobOverlayFace} adds the vertices of the mark on one block's top face to {@link Tessellator#instance}. */
|
||||
public final class MobOverlayFace {
|
||||
|
||||
public static final byte OUTSIDE_SCAN = -2;
|
||||
@@ -36,7 +36,7 @@ public final class MobOverlayFace {
|
||||
|
||||
public boolean isJoined(int offsetX, int offsetZ) {
|
||||
final byte neighbourMode = neighbourModes[indexNeighbour(offsetX, offsetZ)];
|
||||
// no outline along the edge of the scan
|
||||
// `MobOverlayStyle.CONNECTED` doesn't outline the edge of the scan
|
||||
return neighbourMode == neighbourModes[indexNeighbour(0, 0)] || neighbourMode == OUTSIDE_SCAN;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ public final class MobOverlayFace {
|
||||
addTexturedVertex(1, 0);
|
||||
}
|
||||
|
||||
/** @param offsetX 0 at the west edge, 1 at the east edge */
|
||||
public void addVertex(double offsetX, double offsetZ) {
|
||||
Tessellator.instance.addVertex(x + offsetX, y, z + offsetZ);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package codechicken.nei.moboverlay;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
@@ -16,11 +18,8 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import codechicken.lib.math.MathHelper;
|
||||
|
||||
/**
|
||||
* Spawn modes, and the tops of flat blocks such as carpets, in a box around the player. The spawn modes are from
|
||||
* {@link Column#getSpawnMode}: 0 for no spawns, 1 for night only and 2 for any time. The box moves with the player once
|
||||
* the player is a few blocks from the box's centre, and {@link #update} scans only the blocks that enter the box.
|
||||
* {@link #update} rescans the column of a block or light change on the next tick. On each tick, {@link #update} also
|
||||
* rescans a slice of the columns, for changes with no block update, such as a boat that moves into the box.
|
||||
* Spawn modes of the blocks in a box around the player. {@link #update} scans the blocks that enter the box, the
|
||||
* columns of block and light changes, and a slice of the box on each tick.
|
||||
*/
|
||||
public final class MobOverlayScan {
|
||||
|
||||
@@ -31,6 +30,7 @@ public final class MobOverlayScan {
|
||||
public static final int MIN_VERTICAL_RADIUS = 4;
|
||||
public static final int MAX_VERTICAL_RADIUS = 64;
|
||||
public static final int DEFAULT_VERTICAL_RADIUS = 16;
|
||||
public static final int CHUNK_SHIFT = 4;
|
||||
private static final int RECENTRE_DISTANCE = 4;
|
||||
private static final int VERTICAL_RECENTRE_DISTANCE = 2;
|
||||
private static final int RESCAN_TICKS = 40;
|
||||
@@ -47,18 +47,21 @@ public final class MobOverlayScan {
|
||||
// a ring buffer over the box, indexed by `findCell()`. A cell has the spawn mode in the bits of `SPAWN_MODE_MASK`,
|
||||
// and `Column.readCoverTop()` shifted left by `COVER_TOP_SHIFT`
|
||||
private byte[] modes = new byte[0];
|
||||
// indexed by `findColumn(x, z)`
|
||||
private boolean[] dirty = new boolean[0];
|
||||
private boolean hasDirtyColumns;
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
// the slice rescan of `update()` continues from this column, numbered `(x - minX) * span + (z - minZ)`
|
||||
private int nextRescanColumn;
|
||||
private int modesVersion;
|
||||
private int chunkSpan;
|
||||
// The version of a chunk column changes when a cell in or beside the chunk column changes, and when an edge of the
|
||||
// box moves into, out of, within or across the chunk column. A full scan and a vertical move change the version of
|
||||
// every chunk column
|
||||
private int[] chunkVersions = new int[0];
|
||||
private int chunkVersionCount;
|
||||
private boolean hasModes;
|
||||
private long scannedTick;
|
||||
// world of `modes`, with `changeListener` added
|
||||
private World scannedWorld;
|
||||
|
||||
public void clear() {
|
||||
@@ -71,17 +74,17 @@ public final class MobOverlayScan {
|
||||
height = 0;
|
||||
modes = new byte[0];
|
||||
dirty = new boolean[0];
|
||||
chunkSpan = 0;
|
||||
chunkVersions = new int[0];
|
||||
hasModes = false;
|
||||
scannedWorld = null;
|
||||
// `Chunk.worldObj` references the world
|
||||
// a world isn't garbage-collected while `column.chunk` references a chunk of the world
|
||||
column.chunk = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan every column in this call after {@link #clear}, a change of either radius, a world change, or a move of
|
||||
* {@link #getSpan} blocks or more across or {@link #getHeight} blocks or more up or down. {@code newRadius} is
|
||||
* clamped between {@link #MIN_RADIUS} and {@link #MAX_RADIUS}, and {@code newVerticalRadius} between
|
||||
* {@link #MIN_VERTICAL_RADIUS} and {@link #MAX_VERTICAL_RADIUS}.
|
||||
* {@link #getSpan} blocks or more across or {@link #getHeight} blocks or more up or down.
|
||||
*/
|
||||
public void update(Entity entity, int newRadius, int newVerticalRadius) {
|
||||
final World world = entity.worldObj;
|
||||
@@ -112,11 +115,14 @@ public final class MobOverlayScan {
|
||||
if (isChanged) modesVersion++;
|
||||
}
|
||||
|
||||
/** The version changes when a spawn mode or the top of a flat block changes, or the box moves. */
|
||||
public int getModesVersion() {
|
||||
return modesVersion;
|
||||
}
|
||||
|
||||
public int getChunkSpan() {
|
||||
return chunkSpan;
|
||||
}
|
||||
|
||||
public int getSpan() {
|
||||
return span;
|
||||
}
|
||||
@@ -137,19 +143,44 @@ public final class MobOverlayScan {
|
||||
return minZ;
|
||||
}
|
||||
|
||||
/** {@code i} and {@code j} are from 0 to {@link #getSpan}, and {@code k} is from 0 to {@link #getHeight}. */
|
||||
public byte readSpawnMode(int i, int k, int j) {
|
||||
return (byte) (modes[findCell(minX + i, minY + k, minZ + j)] & SPAWN_MODE_MASK);
|
||||
public int getMinChunkX() {
|
||||
return minX >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Height of the overlay above the bottom of the block, so that a flat block such as a carpet does not cover the
|
||||
* overlay. The indices are those of {@link #readSpawnMode}.
|
||||
*/
|
||||
public double readOverlayYOffset(int i, int k, int j) {
|
||||
public int getMaxChunkX() {
|
||||
return (minX + span - 1) >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
public int getMinChunkZ() {
|
||||
return minZ >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
public int getMaxChunkZ() {
|
||||
return (minZ + span - 1) >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
public int readChunkVersion(int chunkX, int chunkZ) {
|
||||
return chunkVersions[findChunk(chunkX, chunkZ)];
|
||||
}
|
||||
|
||||
public byte readSpawnMode(int i, int k, int j) {
|
||||
return extractSpawnMode(modes[findCell(minX + i, minY + k, minZ + j)]);
|
||||
}
|
||||
|
||||
public void readColumn(int i, int j, byte[] columnCells) {
|
||||
final int columnStart = findColumn(minX + i, minZ + j) * height;
|
||||
final int bottomCell = Math.floorMod(minY, height);
|
||||
System.arraycopy(modes, columnStart + bottomCell, columnCells, 0, height - bottomCell);
|
||||
System.arraycopy(modes, columnStart, columnCells, height - bottomCell, bottomCell);
|
||||
}
|
||||
|
||||
public static byte extractSpawnMode(byte cell) {
|
||||
return (byte) (cell & SPAWN_MODE_MASK);
|
||||
}
|
||||
|
||||
public static double computeOverlayYOffset(byte cell) {
|
||||
final double OVERLAY_GAP = 0.02;
|
||||
final int coverTopSteps = modes[findCell(minX + i, minY + k, minZ + j)] >> COVER_TOP_SHIFT;
|
||||
return (double) coverTopSteps / COVER_TOP_STEPS + OVERLAY_GAP;
|
||||
return (double) (cell >> COVER_TOP_SHIFT) / COVER_TOP_STEPS + OVERLAY_GAP;
|
||||
}
|
||||
|
||||
private void resize(int newRadius, int newVerticalRadius) {
|
||||
@@ -159,6 +190,8 @@ public final class MobOverlayScan {
|
||||
height = 2 * newVerticalRadius + 1;
|
||||
modes = new byte[span * span * height];
|
||||
dirty = new boolean[span * span];
|
||||
chunkSpan = ((span - 1) >> CHUNK_SHIFT) + 2;
|
||||
chunkVersions = new int[chunkSpan * chunkSpan];
|
||||
hasModes = false;
|
||||
nextRescanColumn = 0;
|
||||
}
|
||||
@@ -172,6 +205,7 @@ public final class MobOverlayScan {
|
||||
scanColumn(x, z);
|
||||
}
|
||||
}
|
||||
markAllChunks();
|
||||
hasModes = true;
|
||||
modesVersion++;
|
||||
scannedTick = scannedWorld.getTotalWorldTime();
|
||||
@@ -189,6 +223,7 @@ public final class MobOverlayScan {
|
||||
final int offsetX = centreX - radius - minX;
|
||||
if (Math.abs(offsetX) > RECENTRE_DISTANCE) {
|
||||
final int enteringX = offsetX > 0 ? minX + span : minX + offsetX;
|
||||
markMovedEdgeChunks(minX, offsetX, Axis.X);
|
||||
minX += offsetX;
|
||||
for (int x = enteringX; x < enteringX + Math.abs(offsetX); x++) {
|
||||
for (int z = minZ; z < minZ + span; z++) {
|
||||
@@ -201,6 +236,7 @@ public final class MobOverlayScan {
|
||||
final int offsetZ = centreZ - radius - minZ;
|
||||
if (Math.abs(offsetZ) > RECENTRE_DISTANCE) {
|
||||
final int enteringZ = offsetZ > 0 ? minZ + span : minZ + offsetZ;
|
||||
markMovedEdgeChunks(minZ, offsetZ, Axis.Z);
|
||||
minZ += offsetZ;
|
||||
for (int x = minX; x < minX + span; x++) {
|
||||
for (int z = enteringZ; z < enteringZ + Math.abs(offsetZ); z++) {
|
||||
@@ -220,6 +256,7 @@ public final class MobOverlayScan {
|
||||
column.scan(enteringY, enteringY + Math.abs(offsetY));
|
||||
}
|
||||
}
|
||||
markAllChunks();
|
||||
isMoved = true;
|
||||
}
|
||||
return isMoved;
|
||||
@@ -230,7 +267,7 @@ public final class MobOverlayScan {
|
||||
boolean isChanged = false;
|
||||
for (int x = minX; x < minX + span; x++) {
|
||||
for (int z = minZ; z < minZ + span; z++) {
|
||||
if (dirty[findColumn(x, z)]) isChanged |= scanColumn(x, z);
|
||||
if (dirty[findColumn(x, z)]) isChanged |= rescanColumn(x, z);
|
||||
}
|
||||
}
|
||||
return isChanged;
|
||||
@@ -243,7 +280,7 @@ public final class MobOverlayScan {
|
||||
for (; nextRescanColumn < sliceEnd; nextRescanColumn++) {
|
||||
final int x = minX + nextRescanColumn / span;
|
||||
final int z = minZ + nextRescanColumn % span;
|
||||
isChanged |= scanColumn(x, z);
|
||||
isChanged |= rescanColumn(x, z);
|
||||
}
|
||||
if (nextRescanColumn >= columnCount) nextRescanColumn = 0;
|
||||
return isChanged;
|
||||
@@ -256,6 +293,60 @@ public final class MobOverlayScan {
|
||||
return column.scan(minY, minY + height);
|
||||
}
|
||||
|
||||
private boolean rescanColumn(int x, int z) {
|
||||
final boolean isChanged = scanColumn(x, z);
|
||||
// the connected outline of a cell depends on the spawn modes of the cells beside the cell
|
||||
if (isChanged) {
|
||||
for (int offsetX = -1; offsetX <= 1; offsetX++) {
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
markChunk((x + offsetX) >> CHUNK_SHIFT, (z + offsetZ) >> CHUNK_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
private void markMovedEdgeChunks(int oldMin, int offset, Axis moveAxis) {
|
||||
final int lowFrom = Math.min(oldMin, oldMin + offset);
|
||||
final int lowTo = Math.max(oldMin, oldMin + offset);
|
||||
markStripChunks(lowFrom, lowTo, moveAxis);
|
||||
markStripChunks(lowFrom + span - 1, lowTo + span - 1, moveAxis);
|
||||
}
|
||||
|
||||
private void markStripChunks(int from, int to, Axis moveAxis) {
|
||||
final int acrossMin = switch (moveAxis) {
|
||||
case X -> minZ;
|
||||
case Z -> minX;
|
||||
};
|
||||
final int minAcrossChunk = acrossMin >> CHUNK_SHIFT;
|
||||
final int maxAcrossChunk = (acrossMin + span - 1) >> CHUNK_SHIFT;
|
||||
for (int alongChunk = from >> CHUNK_SHIFT; alongChunk <= to >> CHUNK_SHIFT; alongChunk++) {
|
||||
for (int acrossChunk = minAcrossChunk; acrossChunk <= maxAcrossChunk; acrossChunk++) {
|
||||
final int chunkX = switch (moveAxis) {
|
||||
case X -> alongChunk;
|
||||
case Z -> acrossChunk;
|
||||
};
|
||||
final int chunkZ = switch (moveAxis) {
|
||||
case X -> acrossChunk;
|
||||
case Z -> alongChunk;
|
||||
};
|
||||
markChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void markAllChunks() {
|
||||
Arrays.fill(chunkVersions, ++chunkVersionCount);
|
||||
}
|
||||
|
||||
private void markChunk(int chunkX, int chunkZ) {
|
||||
chunkVersions[findChunk(chunkX, chunkZ)] = ++chunkVersionCount;
|
||||
}
|
||||
|
||||
public int findChunk(int chunkX, int chunkZ) {
|
||||
return Math.floorMod(chunkX, chunkSpan) * chunkSpan + Math.floorMod(chunkZ, chunkSpan);
|
||||
}
|
||||
|
||||
private int findColumn(int x, int z) {
|
||||
return Math.floorMod(x, span) * span + Math.floorMod(z, span);
|
||||
}
|
||||
@@ -264,10 +355,6 @@ public final class MobOverlayScan {
|
||||
return findColumn(x, z) * height + Math.floorMod(y, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #moveTo} reads a column's chunk, biome and highest non-air block in the box, and {@link #scan} reads the
|
||||
* column's blocks.
|
||||
*/
|
||||
private final class Column {
|
||||
|
||||
private final Entity dummyEntity = new EntityPig(null);
|
||||
@@ -285,10 +372,8 @@ public final class MobOverlayScan {
|
||||
canBiomeSpawn = !biome.getSpawnableList(EnumCreatureType.monster).isEmpty()
|
||||
&& biome.getSpawningChance() > 0;
|
||||
chunk = scannedWorld.getChunkFromBlockCoords(x, z);
|
||||
// `getHeightValue()` is the height above the highest block with a light opacity above 0. A block with a
|
||||
// light opacity of 0 can be higher: Tinkers' Construct slime grass, a hopper or a snow layer. A mob can
|
||||
// spawn on top of slime grass, a hopper or a full snow block. Search the blocks for the highest non-air
|
||||
// block
|
||||
// `getHeightValue()` skips blocks with a light opacity of 0. A mob can spawn on some of these blocks, such
|
||||
// as Tinkers' Construct slime grass, a hopper or a full snow block. Search for the highest non-air block
|
||||
final int SECTION_HEIGHT = 16;
|
||||
int y = Math.min(minY + height - 1, chunk.getTopFilledSegment() + SECTION_HEIGHT - 1);
|
||||
while (y >= minY && chunk.getBlock(x & 15, y, z & 15).isAir(chunk.worldObj, x, y, z)) y--;
|
||||
@@ -308,12 +393,15 @@ public final class MobOverlayScan {
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
/** The spawn mode of the block at height {@code y} in this column. */
|
||||
private byte getSpawnMode(int y) {
|
||||
if (y >= chunk.worldObj.getHeight()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vanilla `SpawnerAnimals.canCreatureTypeSpawnAtLocation()` rejects a normal cube in the cell (such as the
|
||||
// inside of a stone block). Test the block before the light read
|
||||
if (chunk.getBlock(x & 15, y, z & 15).isNormalCube()) return 0;
|
||||
|
||||
if (chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8 || !SpawnerAnimals
|
||||
.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z)) {
|
||||
return 0;
|
||||
@@ -337,10 +425,6 @@ public final class MobOverlayScan {
|
||||
return (byte) (chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15) >= 8 ? 1 : 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The top of the block at height {@code y}, in fractions of a block with {@link MobOverlayScan#COVER_TOP_STEPS}
|
||||
* as the denominator, or 0 for a tall block.
|
||||
*/
|
||||
private int readCoverTop(int y) {
|
||||
final double MAX_COVER_TOP = 0.25;
|
||||
final Block block = chunk.getBlock(x & 15, y, z & 15);
|
||||
@@ -352,7 +436,6 @@ public final class MobOverlayScan {
|
||||
}
|
||||
}
|
||||
|
||||
/** Marks the columns of the block and light changes in {@link #scannedWorld}. */
|
||||
private final class ChangeListener implements IWorldAccess {
|
||||
|
||||
@Override
|
||||
@@ -417,4 +500,9 @@ public final class MobOverlayScan {
|
||||
hasDirtyColumns = true;
|
||||
}
|
||||
}
|
||||
|
||||
private enum Axis {
|
||||
X,
|
||||
Z
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,7 @@ public enum MobOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* A light tint, with a stronger outline around each area of one spawn mode, like a connected texture.
|
||||
*/
|
||||
/** A light tint and a stronger connected-texture outline around each area of one spawn mode. */
|
||||
CONNECTED(GL11.GL_QUADS) {
|
||||
|
||||
@Override
|
||||
@@ -39,7 +37,8 @@ public enum MobOverlayStyle {
|
||||
face.applyColor(Colouring.OVERLAY, MARK_ALPHA);
|
||||
for (int offsetX = -1; offsetX <= 1; offsetX++) {
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
// a corner cell is drawn when either edge next to the corner is outlined, and on an inside corner
|
||||
// a corner cell is drawn when either edge next to the corner is outlined or when the corner is an
|
||||
// inside corner
|
||||
final boolean isOutline = !(face.isJoined(offsetX, offsetZ) && face.isJoined(offsetX, 0)
|
||||
&& face.isJoined(0, offsetZ));
|
||||
if (isOutline) face.addCell(offsetX, offsetZ, OUTLINE_WIDTH);
|
||||
@@ -48,7 +47,7 @@ public enum MobOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/** A small square in the middle of the block, with no tint. */
|
||||
/** A small square in the middle of an untinted block. */
|
||||
SQUARE(GL11.GL_QUADS) {
|
||||
|
||||
@Override
|
||||
@@ -62,7 +61,7 @@ public enum MobOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/** The pufferfish sticker. */
|
||||
/** A pufferfish sticker on the block. */
|
||||
PUFFERFISH("pufferfish", Colouring.STICKER) {
|
||||
|
||||
@Override
|
||||
@@ -102,7 +101,6 @@ public enum MobOverlayStyle {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
/** @return the {@link #formatName} of every style, separated by commas */
|
||||
public static String formatAllNames() {
|
||||
final StringJoiner names = new StringJoiner(", ");
|
||||
for (MobOverlayStyle style : values()) {
|
||||
@@ -119,7 +117,7 @@ public enum MobOverlayStyle {
|
||||
return switch (this) {
|
||||
case CONNECTED -> TINT_ALPHA;
|
||||
case SQUARE -> MARK_ALPHA;
|
||||
// opaque lines for X, and the alpha of the PNG for PUFFERFISH
|
||||
// the lines of X are opaque, and the alpha of PUFFERFISH comes from the PNG
|
||||
case X, PUFFERFISH -> 1.0F;
|
||||
};
|
||||
}
|
||||
@@ -127,9 +125,9 @@ public enum MobOverlayStyle {
|
||||
public abstract void addVertices(MobOverlayFace face);
|
||||
|
||||
public enum Colouring {
|
||||
/** Yellow where mobs spawn only at night, red where mobs spawn at any time. */
|
||||
/** Yellow marks where mobs spawn only at night and red marks where mobs spawn at any time. */
|
||||
OVERLAY,
|
||||
/** The texture's colours, tinted red where mobs spawn at any time. */
|
||||
/** Texture colours with a red tint where mobs spawn at any time. */
|
||||
STICKER
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# Mob overlay TODO: spawn rules from other mods
|
||||
|
||||
`MobOverlayScan` reads the block, the light and the biome of each cell. Some mods set the result of Forge's
|
||||
`LivingSpawnEvent.CheckSpawn` from the monster's position, and `MobOverlayScan` doesn't call these handlers.
|
||||
|
||||
A monster spawns when the result is `ALLOW`, or when the result is `DEFAULT` and `getCanSpawnHere()` returns
|
||||
true. So `ALLOW` skips the light test.
|
||||
|
||||
## DENY: marked cells where a monster can't spawn
|
||||
|
||||
GregTech and Extra Utilities measure a range from the centre of the block.
|
||||
|
||||
| mod in 2.9.0 | handler | range | on the client? |
|
||||
|---|---|---|---|
|
||||
| GregTech Monster Repellator | `GTSpawnEventHandler.denyMobSpawn()` | sphere. The radius is 4 + 12 × tier without power and 16 + 48 × tier with power | no. `MTEMonsterRepellent.onPostTick()` registers the range on the server only |
|
||||
| Extra Utilities magnum torch | `EventHandlerServer.magnumTorchDenySpawn()` | ellipsoid 128 blocks out and 32 blocks up and down | maybe. `TileEntityAntiMobTorch` adds itself to the static `magnumTorchRegistry` and doesn't check the side. The bytecode is the source of this row, and the row isn't tested in game |
|
||||
| Extra Utilities chandelier | the same handler | sphere, radius 16 | maybe. The chandelier's tile entity is a `TileEntityAntiMobTorch` too |
|
||||
| Gadomancy aura pylon with Lux | `EventHandlerEntityServer.on(CheckSpawn)` | sphere, radius `AuraEffects.LUX.getRange()` | not checked. `AuraEffects.LUX` adds the pylon to `registeredLuxPylons` when the pylon's effect runs on an entity |
|
||||
| Blood Magic Ward of Sacrosanctity (`AW028SpawnWard`) | `AlchemicalWizardryEventHooks.onLivingSpawnEvent()` | box from the ritual's horizontal and vertical radii | not checked. `RitualEffectSpawnWard` fills `respawnMap` |
|
||||
| Botania Emptiness potion | `PotionEmptiness.onSpawn()` | sphere around each player with the effect | the player's potion effects |
|
||||
| ServerUtilities | `ServerUtilitiesWorldEventHandler.onMobSpawned()` | chunks of the safe spawn area, and claimed chunks by the team's settings | no. The claims are server data |
|
||||
| Et Futurum Requiem | `ServerEventHandler.spawnEvent()` | in the Nether, a cell above `ModBlocks.NETHER_WART` at meta 0, for a mob that doesn't fly | yes. The block below is in the client world |
|
||||
|
||||
## ALLOW: monsters spawn in unmarked lit cells
|
||||
|
||||
| mod in 2.9.0 | handler | range |
|
||||
|---|---|---|
|
||||
| Blood Magic Veil of Evil (`AW029VeilOfEvil`) | `AlchemicalWizardryEventHooks.onLivingSpawnEvent()` | box from the ritual's radii. Creepers are excluded |
|
||||
| Botania Bloodthirst potion | `PotionBloodthirst.onSpawn()` | sphere around each player with the effect |
|
||||
|
||||
Thaumcraft 4.2.3.5 doesn't have a `CheckSpawn` handler. The list comes from a scan of the 2.9.0 pack's jars for
|
||||
`LivingSpawnEvent$CheckSpawn`. Handlers that test only the mob type, the dimension or the mob count are left out:
|
||||
AMDIForge, EnderZoo, Automagy, the Extra Utilities Underdark, and the slime handlers of Biomes O' Plenty and Botania.
|
||||
The Extra Utilities siege handler (`EventHandlerSiege.SiegeCheckSpawn()`) isn't checked.
|
||||
|
||||
## To do
|
||||
|
||||
- [ ] Add an NEI API: a mod registers a cell test that returns `DENY`, `ALLOW` or `DEFAULT`. `MobOverlayScan` calls
|
||||
each test for each cell in the box.
|
||||
- [ ] Add an API call to mark an area dirty. `MobOverlayScan` then rescans the area when a range is added or
|
||||
removed.
|
||||
- [ ] Ask GregTech, Gadomancy, Blood Magic and ServerUtilities to send their ranges to the client.
|
||||
- [ ] Test the Extra Utilities registry on a client with a dedicated server.
|
||||
- [ ] Find out how the handlers combine. `GTSpawnEventHandler` returns early on `DENY`, and Blood Magic's handler
|
||||
changes `ALLOW` to `DEFAULT`, so the result depends on the order of the handlers on the event bus.
|
||||
@@ -32,7 +32,7 @@ public class AutoCraftingManager {
|
||||
public void execute() {
|
||||
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
|
||||
final ItemStack[] layout = snapshotLayout(guiContainer);
|
||||
final List<BookmarkItem> initialItems = prepareInitialItems(math, ItemStackAmount.of(guiContainer));
|
||||
final List<BookmarkItem> initialItems = prepareInitialItems(math, getInventoryItems(guiContainer));
|
||||
boolean processed = false;
|
||||
boolean changed = false;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class AutoCraftingManager {
|
||||
changed = false;
|
||||
|
||||
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
|
||||
iterator.updateInventory(ItemStackAmount.of(guiContainer));
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
|
||||
while (iterator.hasNext() && !interrupted(guiContainer)) {
|
||||
final Map<RecipeId, Long> recipes = iterator.next();
|
||||
@@ -69,7 +69,7 @@ public class AutoCraftingManager {
|
||||
if (craft) {
|
||||
changed = true;
|
||||
processed = true;
|
||||
iterator.updateInventory(ItemStackAmount.of(guiContainer));
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,18 @@ public class AutoCraftingManager {
|
||||
return AutoCraftingManager.math != null && !task.interrupted();
|
||||
}
|
||||
|
||||
public static ItemStackAmount getInventoryItems(GuiContainer guiContainer) {
|
||||
final ItemStackAmount inventory = new ItemStackAmount();
|
||||
|
||||
for (Slot slot : guiContainer.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(guiContainer.mc.thePlayer)) {
|
||||
inventory.add(slot.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
private static ItemStack[] snapshotLayout(GuiContainer guiContainer) {
|
||||
final List<Slot> slots = guiContainer.inventorySlots.inventorySlots;
|
||||
final ItemStack[] layout = new ItemStack[slots.size()];
|
||||
|
||||
@@ -487,11 +487,11 @@ public class Recipe {
|
||||
stack = getMainResult(getResults(), RecipeIngredient::getItemStack).getItemStack();
|
||||
}
|
||||
|
||||
long stackSize = 0;
|
||||
int stackSize = 0;
|
||||
|
||||
for (RecipeIngredient result : this.results) {
|
||||
if (result.contains(stack)) {
|
||||
stackSize += StackInfo.getAmountLong(result.getItemStack());
|
||||
stackSize += result.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ public class RecipeItemsTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
}
|
||||
|
||||
if (screen instanceof GuiContainer container) {
|
||||
return ItemStackAmount.of(container);
|
||||
return AutoCraftingManager.getInventoryItems(container);
|
||||
}
|
||||
|
||||
return new ItemStackAmount();
|
||||
|
||||
@@ -121,13 +121,9 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static int getAmount(ItemStack stack) {
|
||||
return (int) Math.min(getAmountLong(stack), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static long getAmountLong(ItemStack stack) {
|
||||
if (stack == null) return 0;
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
|
||||
return nbTag != null ? nbTag.getLong("Count") : 0;
|
||||
return nbTag != null ? nbTag.getInteger("Count") : 0;
|
||||
}
|
||||
|
||||
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.drawable.DrawableResource;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.AutoCraftingManager;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.HandlerInfo;
|
||||
@@ -136,7 +137,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
final GuiContainer currentGui = NEIClientUtils.getGuiContainer();
|
||||
|
||||
if (this.lastShiftKey && currentGui != null && !(currentGui instanceof GuiRecipe<?>)) {
|
||||
inventory.putAll(ItemStackAmount.of(currentGui));
|
||||
inventory.putAll(AutoCraftingManager.getInventoryItems(currentGui));
|
||||
}
|
||||
|
||||
if (!this.outputRecipes.isEmpty()) {
|
||||
@@ -155,7 +156,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
for (ItemStack stack : items) {
|
||||
if (stack != null
|
||||
&& NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
||||
amount += StackInfo.getAmountLong(stack);
|
||||
amount += StackInfo.getAmount(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
protected static Class<?> itemFluidDisplay = null;
|
||||
protected static Method getFluidFromDisplayStack = null;
|
||||
private static Method getGTFluidAmount = null;
|
||||
protected static Class<?> gtMetaGeneratedTool = null;
|
||||
protected static Field playSound = null;
|
||||
|
||||
@@ -43,12 +42,6 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
"gregtech.common.items.GT_FluidDisplayItem");
|
||||
getFluidFromDisplayStack = gtUtility.getMethod("getFluidFromDisplayStack", ItemStack.class);
|
||||
|
||||
try {
|
||||
getGTFluidAmount = gtUtility.getMethod("getFluidAmount", FluidStack.class);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
/* GregTech without long fluid stacks */
|
||||
}
|
||||
|
||||
gtMetaGeneratedTool = ReflectionHelper.getClass(
|
||||
loader,
|
||||
"gregtech.api.items.MetaGeneratedTool",
|
||||
@@ -59,18 +52,6 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/** GregTech fluid stacks can hold more than {@link FluidStack#amount} does */
|
||||
public static long getFluidAmount(FluidStack fluidStack) {
|
||||
|
||||
if (getGTFluidAmount != null) {
|
||||
try {
|
||||
return (long) getGTFluidAmount.invoke(null, fluidStack);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
return fluidStack.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
||||
|
||||
@@ -80,7 +61,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
if (fluidStack != null) {
|
||||
final NBTTagCompound nbTag = new NBTTagCompound();
|
||||
nbTag.setString(FluidDisplayStackStringifyHandler.NBT_FLUID_NAME, fluidStack.getFluid().getName());
|
||||
nbTag.setLong("Count", saveStackSize ? getFluidAmount(fluidStack) : 144);
|
||||
nbTag.setInteger("Count", saveStackSize ? fluidStack.amount : 144);
|
||||
return nbTag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ public class RecipeGroup {
|
||||
|
||||
protected boolean isSameStack(ItemStack stackA, ItemStack stackB) {
|
||||
return stackA == stackB || NEIServerUtils.areStacksSameType(stackA, stackB)
|
||||
&& StackInfo.getAmountLong(stackA) == StackInfo.getAmountLong(stackB);
|
||||
&& StackInfo.getAmount(stackA) == StackInfo.getAmount(stackB);
|
||||
}
|
||||
|
||||
protected List<ItemStack> getFilteredPermutations(int member, Point slotKey) {
|
||||
|
||||
Reference in new issue
Block a user