combinator funnel item caching

This commit is contained in:
Boblet 2024-06-24 16:29:49 +02:00
parent b0ae1c8cee
commit 485fbd35da
13 changed files with 65 additions and 34 deletions

View File

@ -17,6 +17,7 @@
* Decreased crafting complexity and time for the digiminer assembler recipe
* Replaced recipes for the wind turbine and atomic disassembler
* Added a config option for toggling Mekanism compat
* Added recipe caching to the combinator funnel, meaning it no longer has to iterate over the entire recipe list all the time for compression/automation, this should improve performance by a fair bit
## Fixed
* Fixed crash caused by PRISM updating unloaded worlds

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map.Entry;
import com.hbm.handler.imc.ICompatNHNEI;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.util.InventoryUtil;
@ -243,9 +244,13 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler implemen
if(outputId.equals(getKey())) {
for(Entry<Object, Object> recipe : recipes.entrySet()) {
outer: for(Entry<Object, Object> recipe : recipes.entrySet()) {
ItemStack[][] ins = InventoryUtil.extractObject(recipe.getKey());
ItemStack[][] outs = InventoryUtil.extractObject(recipe.getValue());
for(ItemStack[] array : ins) for(ItemStack stack : array) if(stack.getItem() == ModItems.item_secret) continue outer;
for(ItemStack[] array : outs) for(ItemStack stack : array) if(stack.getItem() == ModItems.item_secret) continue outer;
this.arecipes.add(new RecipeSet(ins, outs, recipe.getKey()));
}
@ -257,10 +262,13 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler implemen
@Override
public void loadCraftingRecipes(ItemStack result) {
for(Entry<Object, Object> recipe : recipes.entrySet()) {
outer: for(Entry<Object, Object> recipe : recipes.entrySet()) {
ItemStack[][] ins = InventoryUtil.extractObject(recipe.getKey());
ItemStack[][] outs = InventoryUtil.extractObject(recipe.getValue());
for(ItemStack[] array : ins) for(ItemStack stack : array) if(stack.getItem() == ModItems.item_secret) continue outer;
for(ItemStack[] array : outs) for(ItemStack stack : array) if(stack.getItem() == ModItems.item_secret) continue outer;
match:
for(ItemStack[] array : outs) {
for(ItemStack stack : array) {
@ -285,10 +293,13 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler implemen
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for(Entry<Object, Object> recipe : recipes.entrySet()) {
outer: for(Entry<Object, Object> recipe : recipes.entrySet()) {
ItemStack[][] ins = InventoryUtil.extractObject(recipe.getKey());
ItemStack[][] outs = InventoryUtil.extractObject(recipe.getValue());
for(ItemStack[] array : ins) for(ItemStack stack : array) if(stack.getItem() == ModItems.item_secret) continue outer;
for(ItemStack[] array : outs) for(ItemStack stack : array) if(stack.getItem() == ModItems.item_secret) continue outer;
match:
for(ItemStack[] array : ins) {
for(ItemStack stack : array) {

View File

@ -131,7 +131,7 @@ public class AssemblerRecipes extends SerializableRecipe {
makeRecipe(new ComparableStack(ModBlocks.machine_schrabidium_battery, 1), new AStack[] {new OreDictStack(DESH.ingot(), 4), new OreDictStack(NP237.dust(), 12), new OreDictStack(SA326.dust(), 12), new OreDictStack(SA326.ingot(), 2), new OreDictStack(SA326.wireFine(), 4), },800);
makeRecipe(new ComparableStack(ModBlocks.machine_dineutronium_battery, 1), new AStack[] {new OreDictStack(DNT.ingot(), 24), new ComparableStack(ModItems.powder_spark_mix, 12), new ComparableStack(ModItems.battery_spark_cell_1000, 1), new OreDictStack(CMB.ingot(), 32), new ComparableStack(ModItems.coil_magnetized_tungsten, 8), },1600);
makeRecipe(new ComparableStack(ModBlocks.machine_shredder, 1), new AStack[] {new OreDictStack(STEEL.plate528(), 8), new ComparableStack(ModItems.motor, 2), new ComparableStack(ModBlocks.steel_beam, 2), new ComparableStack(Blocks.iron_bars, 2) },200);
makeRecipe(new ComparableStack(ModBlocks.machine_well, 1), new AStack[] {new ComparableStack(ModBlocks.steel_scaffold, 20), new ComparableStack(ModItems.tank_steel, 2), new ComparableStack(ModItems.motor, 1), new ComparableStack(ModItems.pipes_steel, 1), new ComparableStack(ModItems.drill_titanium, 1), new OreDictStack(MINGRADE.wireFine(), 6), },250);
makeRecipe(new ComparableStack(ModBlocks.machine_well, 1), new AStack[] {new ComparableStack(ModBlocks.steel_scaffold, 20), new ComparableStack(ModItems.tank_steel, 2), new ComparableStack(ModItems.motor, 1), new ComparableStack(ModItems.pipes_steel, 1), new ComparableStack(ModItems.drill_titanium, 1) }, 200);
makeRecipe(new ComparableStack(ModBlocks.machine_pumpjack, 1), new AStack[] {new ComparableStack(ModBlocks.steel_scaffold, 8), new OreDictStack(STEEL.plateWelded(), 8), new ComparableStack(ModItems.pipes_steel, 4), new ComparableStack(ModItems.tank_steel, 4), new OreDictStack(STEEL.plate(), 32), new ComparableStack(ModItems.drill_titanium, 1), new ComparableStack(ModItems.motor_desh) }, 400);
makeRecipe(new ComparableStack(ModBlocks.machine_flare, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 12), new OreDictStack(IRON.ingot(), 12), new OreDictStack(CU.plate528(), 4), new ComparableStack(ModItems.tank_steel, 1), new OreDictStack(STEEL.pipe(), 8), new OreDictStack(STEEL.shell(), 4), new ComparableStack(ModItems.thermo_element, 3), },200);
makeRecipe(new ComparableStack(ModBlocks.machine_coker, 1), new AStack[] {!exp ? new OreDictStack(STEEL.plateWelded(), 3) : new OreDictStack(STEEL.heavyComp(), 2), new OreDictStack(IRON.ingot(), 16), new OreDictStack(CU.plate528(), 8), new OreDictStack(RUBBER.ingot(), 4), new ComparableStack(ModItems.tank_steel, 2), new ComparableStack(ModBlocks.steel_grate, 4) },200);

View File

@ -75,4 +75,8 @@ public class ItemEnums {
public static enum EnumPages {
PAGE1, PAGE2, PAGE3, PAGE4, PAGE5, PAGE6, PAGE7, PAGE8
}
public static enum EnumSecretType {
CANISTER, CONTROLLER
}
}

View File

@ -347,6 +347,7 @@ public class ModItems {
public static Item thruster_nuclear;
public static Item safety_fuse;
public static Item part_generic;
public static Item item_secret;
public static Item chemical_dye;
public static Item crayon;
@ -675,7 +676,6 @@ public class ModItems {
public static Item dysfunctional_reactor;
public static Item blade_titanium;
public static Item turbine_titanium;
public static Item generator_front;
public static Item blade_tungsten;
public static Item turbine_tungsten;
public static Item pellet_coal;
@ -2614,6 +2614,7 @@ public class ModItems {
thruster_nuclear = new Item().setUnlocalizedName("thruster_nuclear").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":thruster_nuclear");
safety_fuse = new Item().setUnlocalizedName("safety_fuse").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":safety_fuse");
part_generic = new ItemGenericPart().setUnlocalizedName("part_generic").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":part_generic");
item_secret = new ItemEnumMulti(EnumSecretType.class, true, true).setUnlocalizedName("item_secret").setCreativeTab(null).setTextureName(RefStrings.MODID + ":item_secret");
chemical_dye = new ItemChemicalDye().setUnlocalizedName("chemical_dye").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":chemical_dye");
crayon = new ItemCrayon().setUnlocalizedName("crayon").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":crayon");
@ -3029,7 +3030,6 @@ public class ModItems {
dysfunctional_reactor = new Item().setUnlocalizedName("dysfunctional_reactor").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":dysfunctional_reactor");
blade_titanium = new Item().setUnlocalizedName("blade_titanium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":blade_titanium");
turbine_titanium = new Item().setUnlocalizedName("turbine_titanium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":turbine_titanium");
generator_front = new Item().setUnlocalizedName("generator_front").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":generator_front");
blade_tungsten = new Item().setUnlocalizedName("blade_tungsten").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":blade_tungsten");
turbine_tungsten = new Item().setUnlocalizedName("turbine_tungsten").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":turbine_tungsten");
@ -6151,6 +6151,7 @@ public class ModItems {
GameRegistry.registerItem(chemical_dye, chemical_dye.getUnlocalizedName());
GameRegistry.registerItem(crayon, crayon.getUnlocalizedName());
GameRegistry.registerItem(part_generic, part_generic.getUnlocalizedName());
GameRegistry.registerItem(item_secret, item_secret.getUnlocalizedName());
GameRegistry.registerItem(parts_legendary, parts_legendary.getUnlocalizedName());
GameRegistry.registerItem(gear_large, gear_large.getUnlocalizedName());
GameRegistry.registerItem(sawblade, sawblade.getUnlocalizedName());
@ -6180,7 +6181,6 @@ public class ModItems {
GameRegistry.registerItem(turbine_titanium, turbine_titanium.getUnlocalizedName());
GameRegistry.registerItem(turbine_tungsten, turbine_tungsten.getUnlocalizedName());
GameRegistry.registerItem(flywheel_beryllium, flywheel_beryllium.getUnlocalizedName());
GameRegistry.registerItem(generator_front, generator_front.getUnlocalizedName());
GameRegistry.registerItem(toothpicks, toothpicks.getUnlocalizedName());
GameRegistry.registerItem(ducttape, ducttape.getUnlocalizedName());
GameRegistry.registerItem(catalyst_clay, catalyst_clay.getUnlocalizedName());

View File

@ -1338,6 +1338,7 @@ public class MainRegistry {
ignoreMappings.add("hbm:tile.ore_daffergon");
ignoreMappings.add("hbm:tile.ore_verticium");
ignoreMappings.add("hbm:item.warhead_mirvlet");
ignoreMappings.add("hbm:item.generator_front");
/// REMAP ///
remapItems.put("hbm:item.gadget_explosive8", ModItems.early_explosive_lenses);

View File

@ -6,12 +6,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.UUID;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.logging.log4j.Level;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.hbm.blocks.IStepTickReceiver;
import com.hbm.blocks.ModBlocks;
@ -41,10 +42,6 @@ import com.hbm.handler.HTTPHandler;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.handler.radiation.ChunkRadiationHandlerPRISM;
import com.hbm.handler.radiation.ChunkRadiationHandlerPRISM.RadPerWorld;
import com.hbm.handler.radiation.ChunkRadiationHandlerPRISM.SubChunk;
import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.items.IEquipReceiver;
import com.hbm.items.ModItems;
import com.hbm.items.armor.ArmorFSB;
@ -92,6 +89,8 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityCreeper;
@ -123,7 +122,6 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.FoodStats;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
@ -854,6 +852,8 @@ public class ModEventHandler {
((ArmorFSB)((EntityPlayer)e).inventory.armorInventory[2].getItem()).handleFall((EntityPlayer)e);
}
private static final UUID fopSpeed = UUID.fromString("e5a8c95d-c7a0-4ecf-8126-76fb8c949389");
@SubscribeEvent
public void onWingFlop(TickEvent.PlayerTickEvent event) {
@ -973,6 +973,17 @@ public class ModEventHandler {
}
}
}
if(player.getUniqueID().toString().equals(ShadyUtil.LePeeperSauvage) || player.getDisplayName().equals("LePeeperSauvage")) {
Multimap multimap = HashMultimap.create();
multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(fopSpeed, "FOP SPEED", 0.5, 1));
player.getAttributeMap().removeAttributeModifiers(multimap);
if(player.isSprinting()) {
player.getAttributeMap().applyAttributeModifiers(multimap);
}
}
}
}
@ -1066,31 +1077,13 @@ public class ModEventHandler {
/// SYNC END ///
}
//TODO: rewrite this so it doesn't look like shit
if(player.worldObj.isRemote && event.phase == event.phase.START && !player.isInvisible() && !player.isSneaking()) {
if(player.getUniqueID().toString().equals(ShadyUtil.HbMinecraft)) {
int i = player.ticksExisted * 3;
Vec3 vec = Vec3.createVectorHelper(3, 0, 0);
vec.rotateAroundY((float) (i * Math.PI / 180D));
for(int k = 0; k < 5; k++) {
vec.rotateAroundY((float) (1F * Math.PI / 180D));
//player.worldObj.spawnParticle("townaura", player.posX + vec.xCoord, player.posY + 1 + player.worldObj.rand.nextDouble() * 0.05, player.posZ + vec.zCoord, 0.0, 0.0, 0.0);
}
}
if(player.getUniqueID().toString().equals(ShadyUtil.Pu_238)) {
Vec3 vec = Vec3.createVectorHelper(3 * rand.nextDouble(), 0, 0);
vec.rotateAroundZ((float) (rand.nextDouble() * Math.PI));
vec.rotateAroundY((float) (rand.nextDouble() * Math.PI * 2));
player.worldObj.spawnParticle("townaura", player.posX + vec.xCoord, player.posY + 1 + vec.yCoord, player.posZ + vec.zCoord, 0.0, 0.0, 0.0);
}
}

View File

@ -36,7 +36,8 @@ public class NEIConfig implements IConfigureNEI {
//Some things are even beyond my control...or are they?
API.hideItem(ItemBattery.getEmptyBattery(ModItems.memory));
API.hideItem(ItemBattery.getFullBattery(ModItems.memory));
API.hideItem(new ItemStack(ModItems.item_secret));
API.hideItem(new ItemStack(ModBlocks.machine_electric_furnace_on));
API.hideItem(new ItemStack(ModBlocks.machine_difurnace_on));
API.hideItem(new ItemStack(ModBlocks.machine_nuke_furnace_on));

View File

@ -1,6 +1,9 @@
package com.hbm.tileentity.machine;
import java.util.HashMap;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.container.ContainerFunnel;
import com.hbm.inventory.gui.GUIFunnel;
import com.hbm.tileentity.IGUIProvider;
@ -96,24 +99,37 @@ public class TileEntityMachineFunnel extends TileEntityMachineBase implements IG
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
if(slot > 8) return false;
if(slots[slot] != null) return true; //if the slot is already occupied, return true because then the same type merging skips the validity check
return this.getFrom9(stack) != null || this.getFrom4(stack) != null;
}
protected InventoryCraftingAuto craftingInventory = new InventoryCraftingAuto(3, 3);
//hashmap lookups are way faster than iterating over the entire ass crafting list all the fucking time
public static final HashMap<ComparableStack, ItemStack> from4Cache = new HashMap();
public static final HashMap<ComparableStack, ItemStack> from9Cache = new HashMap();
public ItemStack getFrom4(ItemStack ingredient) {
ComparableStack singular = new ComparableStack(ingredient).makeSingular();
if(from4Cache.containsKey(singular)) return from4Cache.get(singular);
this.craftingInventory.clear();
this.craftingInventory.setInventorySlotContents(0, ingredient.copy());
this.craftingInventory.setInventorySlotContents(1, ingredient.copy());
this.craftingInventory.setInventorySlotContents(3, ingredient.copy());
this.craftingInventory.setInventorySlotContents(4, ingredient.copy());
return getMatch(this.craftingInventory);
ItemStack match = getMatch(this.craftingInventory);
from4Cache.put(singular, match != null ? match.copy() : null);
return match;
}
public ItemStack getFrom9(ItemStack ingredient) {
ComparableStack singular = new ComparableStack(ingredient).makeSingular();
if(from9Cache.containsKey(singular)) return from9Cache.get(singular);
this.craftingInventory.clear();
for(int i = 0; i < 9; i++) this.craftingInventory.setInventorySlotContents(i, ingredient.copy());
return getMatch(this.craftingInventory);
ItemStack match = getMatch(this.craftingInventory);
from9Cache.put(singular, match != null ? match.copy() : null);
return match;
}
public ItemStack getMatch(InventoryCrafting grid) {

View File

@ -2273,6 +2273,8 @@ item.insert_polonium.name=Poloniumeinlage
item.insert_steel.name=Schwere Stahleinlage
item.insert_xsapi.name=XSAPI-Einlage
item.insert_yharonite.name=Yharoniteinlage
item.item_secret.canister.name=Komposit SB-26
item.item_secret.controller.name=Proprietäre Steuereinheit
item.iv_blood.name=Blutbeutel
item.iv_empty.name=Infusionsbeutel
item.iv_xp.name=Erfahrungsbeutel

View File

@ -3073,6 +3073,8 @@ item.insert_polonium.name=Polonium Insert
item.insert_steel.name=Heavy Steel Insert
item.insert_xsapi.name=XSAPI Insert
item.insert_yharonite.name=Yharonite Insert
item.item_secret.canister.name=Composition SB-26
item.item_secret.controller.name=Proprietary Control Unit
item.iv_blood.name=Blood Bag
item.iv_empty.name=IV Bag
item.iv_xp.name=Experience Bag

View File

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B