i'll be shitting blood tonight

This commit is contained in:
Boblet 2026-05-11 16:41:20 +02:00
parent d105a806ef
commit e6ac26abd0
20 changed files with 74 additions and 177 deletions

View File

@ -27,3 +27,4 @@
* Fixed state change in RoR controllers not allowing repeat commands
* Fixed blast furnace NEI handler not cycling through all valid material shapes
* Fixed RoR transmitter sending empty signals when unused mappings apply
* Fixed hopper IO for battery sockets being entirely broken

View File

@ -1,7 +0,0 @@
package api.hbm.ntl;
@Deprecated
public enum EnumStorageType {
CLUTTER, //potentially unsorted storage (like crates) with many slots that have low capacity
MASS //storage with very few lots (usually 1) and very high capacity
}

View File

@ -8,9 +8,12 @@ public interface ISlotMonitorProvider {
/** Returns an array of available slot monitors, which should ideally mirror the available slots of that container */
public SlotMonitor[] getMonitors();
/** Returns the slot contents of that index, so that the monitors cna detect changes */
/** Returns the slot contents of that index, so that the monitors can detect changes */
public ItemStack getSlotAt(int index);
/** Returns the amount of that slot at that index. Some storages may use int64 datatypes so we have to account for those too somehow, since ItemStacks cannot handle that. */
public long getAmountAt(int index);
/** Whether this storage unit is reachable by the access point on the provided location */
public boolean isAvailableToTerminal(int termX, int termY, int termZ);
}

View File

@ -1,30 +0,0 @@
package api.hbm.ntl;
import net.minecraft.item.ItemStack;
@Deprecated
public interface IStorageComponent {
/**
* @return The type of storage this tile entity represents.
*/
public EnumStorageType getType();
/**
* @return A StorageManifest instance containing all managed stacks
*/
public StorageManifest getManifest();
/**
* @return An integer representing the version of the manifest. The higher the numberm, the more recent the manifest
* (i.e. always count up), the version has to change every time the manifest updates.
*/
public int getManifestVersion();
/**
* @param stack The stack to be stored
* @param simulate Whether the changes should actually be written or if the operation is only for checking
* @return The remainder of the stack after being stored, null if nothing remains
*/
public ItemStack storeStack(ItemStack stack, boolean simulate);
}

View File

@ -1,13 +1,21 @@
package api.hbm.ntl;
import java.util.HashSet;
import api.hbm.ntl.StackCache.CacheSlot;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
public class SlotMonitor {
/** The index of the slot in the inventory this monitor....monitors */
public final int index;
/** The inventory */
public final ISlotMonitorProvider parent;
/** If this monitor detects a change, all cache slots need to be notified */
public HashSet<CacheSlot> viewedBy = new HashSet();
public Item item;
public long stacksize;
public int meta;
@ -17,4 +25,8 @@ public class SlotMonitor {
this.index = index;
this.parent = parent;
}
public void checkUpdate() {
}
}

View File

@ -0,0 +1,29 @@
package api.hbm.ntl;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
public class StackCache {
public LinkedHashMap<Integer, CacheSlot> cacheSlots = new LinkedHashMap();
public class CacheSlot {
public Item item;
public long stacksize;
public int meta;
public NBTTagCompound nbt;
public LinkedHashSet<SlotMonitor> monitors = new LinkedHashSet();
}
public static int getStackIdentity(Item item, int meta, NBTTagCompound nbt) {
int identity = Item.getIdFromItem(item) * 27644437;
identity += meta * 27644437;
if(nbt != null) identity += nbt.toString().hashCode();
return identity;
}
}

View File

@ -1,70 +0,0 @@
package api.hbm.ntl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@Deprecated
public class StorageManifest {
public LinkedHashMap<Integer, MetaNode> itemMeta = new LinkedHashMap();
public void writeStack(ItemStack stack) {
int id = Item.getIdFromItem(stack.getItem());
MetaNode meta = itemMeta.get(id);
if(meta == null) {
meta = new MetaNode();
itemMeta.put(id, meta);
}
NBTNode nbt = meta.metaNBT.get(stack.getItemDamage());
if(nbt == null) {
nbt = new NBTNode();
meta.metaNBT.put(stack.getItemDamage(), nbt);
}
NBTTagCompound compound = stack.hasTagCompound() ? (NBTTagCompound) stack.stackTagCompound.copy() : null;
long amount = nbt.nbtAmount.containsKey(compound) ? nbt.nbtAmount.get(compound) : 0;
amount += stack.stackSize;
nbt.nbtAmount.put(compound, amount);
}
public List<StorageStack> getStacks(boolean sorted) {
List<StorageStack> stacks = new ArrayList();
for(Entry<Integer, MetaNode> itemNode : itemMeta.entrySet()) {
for(Entry<Integer, NBTNode> metaNode : itemNode.getValue().metaNBT.entrySet()) {
for(Entry<NBTTagCompound, Long> nbtNode : metaNode.getValue().nbtAmount.entrySet()) {
ItemStack itemStack = new ItemStack(Item.getItemById(itemNode.getKey()), 1, metaNode.getKey());
itemStack.stackTagCompound = nbtNode.getKey();
StorageStack stack = new StorageStack(itemStack, nbtNode.getValue());
stacks.add(stack);
}
}
}
if(sorted) Collections.sort(stacks);
return stacks;
}
public class MetaNode {
public LinkedHashMap<Integer, NBTNode> metaNBT = new LinkedHashMap();
}
public class NBTNode {
public LinkedHashMap<NBTTagCompound, Long> nbtAmount = new LinkedHashMap();
}
}

View File

@ -1,54 +0,0 @@
package api.hbm.ntl;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@Deprecated
public class StorageStack implements Comparable {
private int cachedItemId;
private ItemStack type;
private long amount;
public StorageStack(ItemStack type) {
this(type, type.stackSize);
this.cachedItemId = Item.getIdFromItem(type.getItem());
}
public StorageStack(ItemStack type, long amount) {
this.type = type.copy();
this.amount = amount;
this.type.stackSize = 0;
}
public ItemStack getType() {
return this.type.copy();
}
public long getAmount() {
return this.amount;
}
@Override
public int compareTo(Object o) {
StorageStack other = (StorageStack) o;
if(this.cachedItemId < other.cachedItemId) return -1;
if(this.cachedItemId > other.cachedItemId) return 1;
if(this.type.getItemDamage() < other.type.getItemDamage()) return -1;
if(this.type.getItemDamage() > other.type.getItemDamage()) return 1;
if(this.type.hasTagCompound() && !other.type.hasTagCompound()) return -1;
if(!this.type.hasTagCompound() && other.type.hasTagCompound()) return 1;
if(this.type.hasTagCompound() && other.type.hasTagCompound()) {
// keyset size comparison should hopefully catch most of the larger NBT cases
if(this.type.stackTagCompound.func_150296_c().size() < other.type.stackTagCompound.func_150296_c().size()) return -1;
if(this.type.stackTagCompound.func_150296_c().size() > other.type.stackTagCompound.func_150296_c().size()) return 1;
int comp = this.type.stackTagCompound.toString().compareTo(other.type.stackTagCompound.toString()); // not terribly performant but hopefully not that common
if(comp != 0) return comp;
}
if(this.type.stackSize < other.type.stackSize) return -1;
if(this.type.stackSize > other.type.stackSize) return 1;
return 0;
}
}

View File

@ -129,7 +129,7 @@ public class GeneralConfig {
preferredOutputMod = CommonConfig.createConfigStringList(config,CATEGORY_GENERAL,"1.42_preferredOutputMod",
"The mod which is preferred as output when certain machines autogenerate recipes. Currently used for the shredder", new String[] {RefStrings.MODID});
enableLoadScreenReplacement = config.get(CATEGORY_GENERAL, "1.43_enableLoadScreenReplacement", true, "Tries to replace the vanilla load screen with the 'tip of the day' one, may clash with other mods trying to do the same.").getBoolean(true);
enableMachineGravity = config.get(CATEGORY_GENERAL, "1.44_enableMachineGravity", true, "Requires some large machines to have a proper foundation, or else they tilt and break.").getBoolean(false);
enableMachineGravity = config.get(CATEGORY_GENERAL, "1.44_enableMachineGravity", true, "Requires large large machines to have a proper foundation, or else they tilt and break. Independent from the 528 version of this config, which does the same, but only works with 528 enabled.").getBoolean(false);
enableExpensiveMode = config.get(CATEGORY_GENERAL, "1.99_enableExpensiveMode", false, "It does what the name implies.").getBoolean(false);
final String CATEGORY_528 = CommonConfig.CATEGORY_528;
@ -180,6 +180,7 @@ public class GeneralConfig {
enable528NetherBurn = false;
enable528PressurizedRecipes = false;
enable528ExplosiveEnergistics = false;
enable528MachineGravity = false;
}
}
}

View File

@ -17,6 +17,12 @@ public class ContainerPneumoStorageAccess extends Container {
public ContainerPneumoStorageAccess(InventoryPlayer invPlayer, TileEntityPneumoStorageAccess access) {
this.access = access;
for(int i = 0; i < 6; i++) {
for(int j = 0; j < 8; j++) {
this.addSlotToContainer(new SlotNonRetarded(inventory, j + i * 8, 8 + j * 18, 17 + i * 18));
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new SlotNonRetarded(invPlayer, j + i * 9 + 9, 8 + j * 18, 169 + i * 18));

View File

@ -106,19 +106,18 @@ public class TileEntityLoadedBase extends TileEntity implements ILoadedTile, IBu
}
public static enum TiltType {
UNAVOIDABLE, CONFIG_NORMAL, CONFIG_528
UNAVOIDABLE, CONFIG;
}
public void checkTilt(TiltType cfg, boolean extraHeavy) {
boolean doesTilt = false;
if(cfg == TiltType.UNAVOIDABLE) doesTilt = true;
if(cfg == TiltType.CONFIG_NORMAL && GeneralConfig.enableMachineGravity) doesTilt = true;
if(cfg == TiltType.CONFIG_NORMAL && GeneralConfig.enable528MachineGravity) doesTilt = true;
if(cfg == TiltType.CONFIG_528 && GeneralConfig.enable528MachineGravity) doesTilt = true;
if(cfg == TiltType.CONFIG && GeneralConfig.enableMachineGravity) doesTilt = true;
if(cfg == TiltType.CONFIG && GeneralConfig.enable528MachineGravity) doesTilt = true;
if(!doesTilt) { this.tilted = false; return; }
if(this.getFloorCount() <= 0) { this.tilted = false; return; }
if(this.worldObj.getTotalWorldTime() % 20 != 0) return;
if(this.worldObj.getTotalWorldTime() + BlockPos.getIdentity(xCoord, yCoord, zCoord) % 20 != 0) return;
if(this.tiltBlocksChecked >= this.getFloorCount()) {

View File

@ -188,7 +188,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
public void updateEntity() {
if(!worldObj.isRemote) {
this.checkTilt(TiltType.CONFIG_NORMAL, true);
this.checkTilt(TiltType.CONFIG, true);
if (redstonePowered) {
isOn = true;

View File

@ -98,7 +98,7 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP
public void updateEntity() {
if(!worldObj.isRemote) {
this.checkTilt(TiltType.CONFIG_NORMAL, true);
this.checkTilt(TiltType.CONFIG, true);
for(int i = 0; i < 4; i++) {
if(klystronNodes[i] == null || klystronNodes[i].expired) klystronNodes[i] = createNode(KlystronNetworkProvider.THE_PROVIDER, ForgeDirection.getOrientation(i + 2));

View File

@ -105,7 +105,7 @@ public class TileEntityMachineGasFlare extends TileEntityMachineBase implements
public void updateEntity() {
if(!worldObj.isRemote) {
this.checkTilt(TiltType.CONFIG_528, false);
this.checkTilt(TiltType.CONFIG, false);
this.fluidUsed = 0;
this.output = 0;

View File

@ -133,7 +133,7 @@ public class TileEntityMachineRefinery extends TileEntityMachineBase implements
public void updateEntity() {
if(!worldObj.isRemote) {
this.checkTilt(TiltType.CONFIG_528, false);
this.checkTilt(TiltType.CONFIG, false);
this.isOn = false;

View File

@ -210,12 +210,14 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
@Override
public boolean canExtractItem(int i, ItemStack stack, int j) {
if(stack.getItem() instanceof IBatteryItem) {
if(i == mode_input && ((IBatteryItem)stack.getItem()).getCharge(stack) == 0) return true;
if(i == mode_output && ((IBatteryItem)stack.getItem()).getCharge(stack) == ((IBatteryItem)stack.getItem()).getMaxCharge(stack)) return true;
if(i == mode_output && ((IBatteryItem)stack.getItem()).getCharge(stack) == 0) return true;
if(i == mode_input && ((IBatteryItem)stack.getItem()).getCharge(stack) == ((IBatteryItem)stack.getItem()).getMaxCharge(stack)) return true;
}
return false;
}
@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return stack.getItem() instanceof IBatteryItem; }
@Override public int[] getAccessibleSlotsFromSide(int side) { return new int[] {0}; }
@Override public long getPower() {

View File

@ -11,17 +11,21 @@ import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.ntl.IPneumaticConnector;
import api.hbm.ntl.StackCache;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
// throwing the towel - for now. there's a test i could run, but it's a lot of work and will likely just confirm my suspicions about performance
// this demands another sidequest: fucking multi threading
public class TileEntityPneumoStorageAccess extends TileEntity implements IPneumaticConnector, IGUIProvider {
protected PneumaticNode node;
public StackCache cache;
public TileEntityPneumoStorageAccess() {
this.cache = new StackCache();
}
@Override
public void updateEntity() {

View File

@ -106,6 +106,7 @@ public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implem
@Override public SlotMonitor[] getMonitors() { return monitors; }
@Override public ItemStack getSlotAt(int index) { return this.getStackInSlot(index); }
@Override public long getAmountAt(int index) { ItemStack stack = getSlotAt(index); return stack != null ? stack.stackSize : 0; }
@Override
public boolean isAvailableToTerminal(int termX, int termY, int termZ) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B