mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
fuck me sideways in a maid dress this actually works
This commit is contained in:
parent
2cdaf9749f
commit
bdcaa4199e
@ -103,12 +103,15 @@ public class SlotMonitor {
|
|||||||
|
|
||||||
if(hasTypeChanged) {
|
if(hasTypeChanged) {
|
||||||
|
|
||||||
|
System.out.println("Type changed!");
|
||||||
|
|
||||||
// remove from all existing monitors
|
// remove from all existing monitors
|
||||||
Iterator<CacheSlot> iterator = viewedBy.iterator();
|
Iterator<CacheSlot> iterator = viewedBy.iterator();
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
CacheSlot slot = iterator.next();
|
CacheSlot slot = iterator.next();
|
||||||
slot.removeMonitor(this);
|
slot.removeMonitor(this);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
System.out.println("Removing");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set updated traits
|
// set updated traits
|
||||||
@ -126,9 +129,14 @@ public class SlotMonitor {
|
|||||||
|
|
||||||
// find new monitors
|
// find new monitors
|
||||||
if(pneumoNet != null) {
|
if(pneumoNet != null) {
|
||||||
|
|
||||||
|
System.out.println("Adding to new network...");
|
||||||
|
|
||||||
for(StackCache cache : pneumoNet.accessors) {
|
for(StackCache cache : pneumoNet.accessors) {
|
||||||
|
System.out.println("Adding to cache...");
|
||||||
if(!cache.hasExpired && parent.isAvailableToCache(cache)) {
|
if(!cache.hasExpired && parent.isAvailableToCache(cache)) {
|
||||||
cache.addToCache(this);
|
cache.addToCache(this);
|
||||||
|
System.out.println("Added!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,13 +95,16 @@ public class StackCache {
|
|||||||
|
|
||||||
public void addMonitor(SlotMonitor monitor) {
|
public void addMonitor(SlotMonitor monitor) {
|
||||||
if(this.monitors.add(monitor)) {
|
if(this.monitors.add(monitor)) {
|
||||||
|
monitor.viewedBy.add(this);
|
||||||
this.changeAmounts(monitor.stacksize);
|
this.changeAmounts(monitor.stacksize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMonitor(SlotMonitor monitor) {
|
public void removeMonitor(SlotMonitor monitor) {
|
||||||
|
System.out.println("Trying to remove...");
|
||||||
if(this.monitors.remove(monitor)) {
|
if(this.monitors.remove(monitor)) {
|
||||||
this.changeAmounts(-monitor.stacksize);
|
this.changeAmounts(-monitor.stacksize);
|
||||||
|
System.out.println("Removed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.hbm.inventory.SlotNonRetarded;
|
import com.hbm.inventory.SlotNonRetarded;
|
||||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageAccess;
|
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageAccess;
|
||||||
|
import com.hbm.util.ItemStackUtil;
|
||||||
|
|
||||||
import api.hbm.ntl.StackCache;
|
import api.hbm.ntl.StackCache;
|
||||||
import api.hbm.ntl.StackCache.CacheSlot;
|
import api.hbm.ntl.StackCache.CacheSlot;
|
||||||
@ -70,13 +71,17 @@ public class ContainerPneumoStorageAccess extends Container {
|
|||||||
if(this.cache == null) return;
|
if(this.cache == null) return;
|
||||||
List<CacheSlot> cacheSlots = new ArrayList(cache.cacheSlots.size());
|
List<CacheSlot> cacheSlots = new ArrayList(cache.cacheSlots.size());
|
||||||
cacheSlots.addAll(cache.cacheSlots.values());
|
cacheSlots.addAll(cache.cacheSlots.values());
|
||||||
|
cacheSlots.removeIf(x -> { return x.stacksize <= 0; });
|
||||||
Collections.sort(cacheSlots, SORT_BY_STACK_SIZE);
|
Collections.sort(cacheSlots, SORT_BY_STACK_SIZE);
|
||||||
int size = cacheSlots.size();
|
int size = cacheSlots.size();
|
||||||
|
|
||||||
for(int i = 0; i < slots.length; i++) {
|
for(int i = 0; i < slots.length; i++) {
|
||||||
if(i < size) {
|
if(i < size) {
|
||||||
CacheSlot cache = cacheSlots.get(i);
|
CacheSlot cache = cacheSlots.get(i);
|
||||||
slots[i] = cache.displayStack;
|
if(cache.displayStack != null) {
|
||||||
|
slots[i] = cache.displayStack.copy();
|
||||||
|
ItemStackUtil.addTooltipToStack(slots[i], "x" + cache.stacksize, "in " + cache.monitors.size() + " stacks");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,9 +39,10 @@ public class TileEntityPneumoStorageAccess extends TileEntityLoadedBase implemen
|
|||||||
|
|
||||||
if(this.cache == null) {
|
if(this.cache == null) {
|
||||||
this.cache = new StackCache(xCoord, yCoord, zCoord);
|
this.cache = new StackCache(xCoord, yCoord, zCoord);
|
||||||
if(this.node != null && this.node.hasValidNet()) {
|
}
|
||||||
this.node.net.addStackCache(cache);
|
|
||||||
}
|
if(this.node != null && this.node.hasValidNet()) {
|
||||||
|
this.node.net.addStackCache(cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,15 +13,17 @@ import com.hbm.uninos.networkproviders.PneumaticNetworkProvider;
|
|||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
|
||||||
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
||||||
|
import api.hbm.ntl.IPneumaticConnector;
|
||||||
import api.hbm.ntl.ISlotMonitorProvider;
|
import api.hbm.ntl.ISlotMonitorProvider;
|
||||||
import api.hbm.ntl.SlotMonitor;
|
import api.hbm.ntl.SlotMonitor;
|
||||||
import api.hbm.ntl.StackCache;
|
import api.hbm.ntl.StackCache;
|
||||||
|
import api.hbm.ntl.StackCache.CacheSlot;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implements IFluidStandardReceiverMK2, ISlotMonitorProvider, IGUIProvider {
|
public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implements IPneumaticConnector, IFluidStandardReceiverMK2, ISlotMonitorProvider, IGUIProvider {
|
||||||
|
|
||||||
public FluidTank compair;
|
public FluidTank compair;
|
||||||
public SlotMonitor[] monitors;
|
public SlotMonitor[] monitors;
|
||||||
@ -81,7 +83,17 @@ public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implem
|
|||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
|
for(SlotMonitor monitor : this.monitors) {
|
||||||
|
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
if(this.node != null) {
|
if(this.node != null) {
|
||||||
|
|
||||||
|
if(node.hasValidNet()) {
|
||||||
|
this.node.net.storages.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +102,12 @@ public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implem
|
|||||||
@Override
|
@Override
|
||||||
public void onChunkUnload() {
|
public void onChunkUnload() {
|
||||||
super.onChunkUnload();
|
super.onChunkUnload();
|
||||||
if(node != null && !node.expired && node.hasValidNet()) {
|
|
||||||
|
for(SlotMonitor monitor : this.monitors) {
|
||||||
|
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(node != null && node.hasValidNet()) {
|
||||||
this.node.net.storages.remove(this);
|
this.node.net.storages.remove(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user