mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
Compare commits
3 Commits
775126f0ba
...
9d7b7ca3bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d7b7ca3bc | ||
|
|
2e3a6cb086 | ||
|
|
8113546777 |
@ -182,14 +182,14 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
|||||||
this.zLevel = 0.0F;
|
this.zLevel = 0.0F;
|
||||||
itemRender.zLevel = 0.0F;
|
itemRender.zLevel = 0.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ItemStack TEMPLATE_FOLDER = new ItemStack(ModItems.template_folder);
|
public static final ItemStack TEMPLATE_FOLDER = new ItemStack(ModItems.template_folder);
|
||||||
|
|
||||||
/** Standardsized item rendering from GUIScreenRecipeSelector */
|
/** Standardsized item rendering from GUIScreenRecipeSelector */
|
||||||
public void renderItem(ItemStack stack, int x, int y) {
|
public void renderItem(ItemStack stack, int x, int y) {
|
||||||
renderItem(stack, x, y, 100F);
|
renderItem(stack, x, y, 100F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderItem(ItemStack stack, int x, int y, float layer) {
|
public void renderItem(ItemStack stack, int x, int y, float layer) {
|
||||||
FontRenderer font = stack.getItem().getFontRenderer(stack);
|
FontRenderer font = stack.getItem().getFontRenderer(stack);
|
||||||
if(font == null) font = fontRendererObj;
|
if(font == null) font = fontRendererObj;
|
||||||
@ -323,11 +323,11 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
|||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void click() {
|
public void click() {
|
||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickSendFlag(TileEntity tile, int x, int y, int left, int top, int sizeX, int sizeY, String name) {
|
public void clickSendFlag(TileEntity tile, int x, int y, int left, int top, int sizeX, int sizeY, String name) {
|
||||||
if(checkClick(x, y, left, top, sizeX, sizeY)) {
|
if(checkClick(x, y, left, top, sizeX, sizeY)) {
|
||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||||
@ -336,29 +336,14 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
|||||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tile.xCoord, tile.yCoord, tile.zCoord));
|
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tile.xCoord, tile.yCoord, tile.zCoord));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///NEI drag and drop support
|
///NEI drag and drop support
|
||||||
@Override
|
@Override
|
||||||
@Optional.Method(modid = "NotEnoughItems")
|
@Optional.Method(modid = "NotEnoughItems")
|
||||||
public boolean handleDragNDrop(GuiContainer gui, int x, int y, ItemStack stack, int button) {
|
public boolean handleDragNDrop(GuiContainer gui, int x, int y, ItemStack stack, int button) {
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
if(gui instanceof GuiInfoContainer && stack != null){
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
|
||||||
|
|
||||||
/*if(gui instanceof GuiInfoContainer && stack != null){
|
|
||||||
Slot slot = getSlotAtPosition(x,y);
|
Slot slot = getSlotAtPosition(x,y);
|
||||||
if(slot instanceof SlotPattern){
|
if(slot instanceof SlotPattern){
|
||||||
if(inventorySlots instanceof ContainerBase) {
|
if(inventorySlots instanceof ContainerBase) {
|
||||||
@ -374,7 +359,7 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//all credits for impl to GTNH's EnderCore fork
|
//all credits for impl to GTNH's EnderCore fork
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
|||||||
|
|
||||||
public FluidTank compair;
|
public FluidTank compair;
|
||||||
public SlotMonitor[] monitors;
|
public SlotMonitor[] monitors;
|
||||||
|
|
||||||
protected PneumaticNode node;
|
protected PneumaticNode node;
|
||||||
protected boolean wasAvailable = false;
|
protected boolean wasAvailable = false;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
|||||||
super(slots);
|
super(slots);
|
||||||
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
||||||
this.monitors = new SlotMonitor[slots];
|
this.monitors = new SlotMonitor[slots];
|
||||||
|
|
||||||
for(int i = 0; i < monitors.length; i++) this.monitors[i] = new SlotMonitor(i, this);
|
for(int i = 0; i < monitors.length; i++) this.monitors[i] = new SlotMonitor(i, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,43 +58,43 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
boolean isAvailable = this.isAvailable();
|
boolean isAvailable = this.isAvailable();
|
||||||
|
|
||||||
if(isAvailable != wasAvailable) {
|
if(isAvailable != wasAvailable) {
|
||||||
this.wasAvailable = isAvailable;
|
this.wasAvailable = isAvailable;
|
||||||
for(SlotMonitor monitor : monitors) monitor.availabilityHasChanged();
|
for(SlotMonitor monitor : monitors) monitor.availabilityHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.node == null || this.node.expired) {
|
if(this.node == null || this.node.expired) {
|
||||||
this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||||
|
|
||||||
if(this.node == null || this.node.expired) {
|
if(this.node == null || this.node.expired) {
|
||||||
this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord);
|
this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord);
|
||||||
UniNodespace.createNode(worldObj, this.node);
|
UniNodespace.createNode(worldObj, this.node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node != null && !node.expired && node.hasValidNet()) {
|
if(node != null && !node.expired && node.hasValidNet()) {
|
||||||
this.node.net.storages.add(this);
|
this.node.net.storages.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(worldObj.getTotalWorldTime() % 10 == 0) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
if(worldObj.getTotalWorldTime() % 10 == 0) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
this.trySubscribe(compair.getTankType(), worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
this.trySubscribe(compair.getTankType(), worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.compair.getFill() > 0) {
|
if(this.compair.getFill() > 0) {
|
||||||
int consumption = (int) Math.ceil(this.compair.getFill() * 9 / this.compair.getMaxFill()) + 1;
|
int consumption = (int) Math.ceil(this.compair.getFill() * 9 / this.compair.getMaxFill()) + 1;
|
||||||
this.compair.setFill(Math.max(this.compair.getFill() - consumption, 0));
|
this.compair.setFill(Math.max(this.compair.getFill() - consumption, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateMonitors();
|
this.updateMonitors();
|
||||||
this.networkPackNT(15);
|
this.networkPackNT(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return this.isLoaded && !this.isInvalid() && this.compair.getFill() > 0;
|
return this.isLoaded && !this.isInvalid() && this.compair.getFill() > 0;
|
||||||
}
|
}
|
||||||
@ -104,30 +104,30 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
|||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
for(SlotMonitor monitor : this.monitors) {
|
for(SlotMonitor monitor : this.monitors) {
|
||||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.node != null) {
|
if(this.node != null) {
|
||||||
|
|
||||||
if(node.hasValidNet()) {
|
if(node.hasValidNet()) {
|
||||||
this.node.net.storages.remove(this);
|
this.node.net.storages.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkUnload() {
|
public void onChunkUnload() {
|
||||||
super.onChunkUnload();
|
super.onChunkUnload();
|
||||||
|
|
||||||
for(SlotMonitor monitor : this.monitors) {
|
for(SlotMonitor monitor : this.monitors) {
|
||||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node != null && node.hasValidNet()) {
|
if(node != null && node.hasValidNet()) {
|
||||||
this.node.net.storages.remove(this);
|
this.node.net.storages.remove(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.hbm.tileentity.network.pneumatic;
|
package com.hbm.tileentity.network.pneumatic;
|
||||||
|
|
||||||
|
|
||||||
import com.hbm.interfaces.IControlReceiver;
|
import com.hbm.interfaces.IControlReceiver;
|
||||||
import com.hbm.inventory.container.ContainerPneumoStorageExporter;
|
import com.hbm.inventory.container.ContainerPneumoStorageExporter;
|
||||||
import com.hbm.inventory.gui.GUIPneumoStorageExporter;
|
import com.hbm.inventory.gui.GUIPneumoStorageExporter;
|
||||||
@ -20,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineBase implements IRORInteractive, IControlReceiver, IControlReceiverFilter {
|
public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineBase implements IRORInteractive, IControlReceiver, IControlReceiverFilter {
|
||||||
|
|
||||||
/** If requests should be pulled repeatedly every tick */
|
/** If requests should be pulled repeatedly every tick */
|
||||||
public boolean continuousRequest = false;
|
public boolean continuousRequest = false;
|
||||||
/** If ROR configuration has taken place, ignore manually defined filters entirely */
|
/** If ROR configuration has taken place, ignore manually defined filters entirely */
|
||||||
@ -39,9 +38,9 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
public static final int MODE_FULL_STACK = 1;
|
public static final int MODE_FULL_STACK = 1;
|
||||||
/** All request slots try to pull the desired quantities simultaneously */
|
/** All request slots try to pull the desired quantities simultaneously */
|
||||||
public static final int MODE_FULL_REQUEST = 2;
|
public static final int MODE_FULL_REQUEST = 2;
|
||||||
|
|
||||||
public boolean lastRedstone = false;
|
public boolean lastRedstone = false;
|
||||||
|
|
||||||
public int[] SLOT_ACCESS = new int[] {9, 10, 11, 12, 13, 14, 15, 16, 17};
|
public int[] SLOT_ACCESS = new int[] {9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||||
|
|
||||||
public TileEntityPneumoStorageExporter() {
|
public TileEntityPneumoStorageExporter() {
|
||||||
@ -59,45 +58,45 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++) {
|
for(int i = 0; i < 9; i++) {
|
||||||
if(slotDelay[i] > 0) slotDelay[i]--;
|
if(slotDelay[i] > 0) slotDelay[i]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean redstone = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
boolean redstone = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
if(continuousRequest) {
|
if(continuousRequest) {
|
||||||
this.doRequest(false);
|
this.doRequest(false);
|
||||||
} else {
|
} else {
|
||||||
if(redstone && !lastRedstone) this.doRequest(true);
|
if(redstone && !lastRedstone) this.doRequest(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastRedstone = redstone;
|
this.lastRedstone = redstone;
|
||||||
|
|
||||||
this.networkPackNT(15);
|
this.networkPackNT(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doRequest(boolean force) {
|
public void doRequest(boolean force) {
|
||||||
|
|
||||||
if(this.requestMode != MODE_FULL_REQUEST) {
|
if(this.requestMode != MODE_FULL_REQUEST) {
|
||||||
// handle all filters individually
|
// handle all filters individually
|
||||||
for(int i = 0; i < 9; i++) if(!requestSlot(i, force)) this.slotDelay[i] = SLOT_DELAY;
|
for(int i = 0; i < 9; i++) if(!requestSlot(i, force)) this.slotDelay[i] = SLOT_DELAY;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// check filter delay if forced pulls aren't active
|
// check filter delay if forced pulls aren't active
|
||||||
if(!force) for(int i = 0; i < 9; i++) {
|
if(!force) for(int i = 0; i < 9; i++) {
|
||||||
short[] filter = this.getFilter(i);
|
short[] filter = this.getFilter(i);
|
||||||
if(filter != null && slotDelay[i] > 0) return;
|
if(filter != null && slotDelay[i] > 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if filter demands are met and space is free
|
// check if filter demands are met and space is free
|
||||||
for(int i = 0; i < 9; i++) {
|
for(int i = 0; i < 9; i++) {
|
||||||
short[] filter = this.getFilter(i);
|
short[] filter = this.getFilter(i);
|
||||||
if(filter == null) continue;
|
if(filter == null) continue;
|
||||||
|
|
||||||
int itemId = filter[0];
|
int itemId = filter[0];
|
||||||
Item item = Item.getItemById(itemId);
|
Item item = Item.getItemById(itemId);
|
||||||
int meta = filter[1];
|
int meta = filter[1];
|
||||||
@ -105,7 +104,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
|
|
||||||
int existingSize = 0;
|
int existingSize = 0;
|
||||||
ItemStack existingStack = slots[i + 9];
|
ItemStack existingStack = slots[i + 9];
|
||||||
|
|
||||||
if(existingStack != null) {
|
if(existingStack != null) {
|
||||||
if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) {
|
if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) {
|
||||||
existingSize = existingStack.stackSize;
|
existingSize = existingStack.stackSize;
|
||||||
@ -114,21 +113,21 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack newStack = new ItemStack(item, 1, meta);
|
ItemStack newStack = new ItemStack(item, 1, meta);
|
||||||
int capacityLeft = newStack.getMaxStackSize() - existingSize;
|
int capacityLeft = newStack.getMaxStackSize() - existingSize;
|
||||||
|
|
||||||
if(capacityLeft < requestSize || getAvailability(itemId, meta) < requestSize) {
|
if(capacityLeft < requestSize || getAvailability(itemId, meta) < requestSize) {
|
||||||
this.slotDelay[i] = SLOT_DELAY;
|
this.slotDelay[i] = SLOT_DELAY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything is good, pull items. continues should not happen, but are in place nonetheless
|
// everything is good, pull items. continues should not happen, but are in place nonetheless
|
||||||
for(int i = 0; i < 9; i++) {
|
for(int i = 0; i < 9; i++) {
|
||||||
short[] filter = this.getFilter(i);
|
short[] filter = this.getFilter(i);
|
||||||
if(filter == null) continue;
|
if(filter == null) continue;
|
||||||
|
|
||||||
int itemId = filter[0];
|
int itemId = filter[0];
|
||||||
Item item = Item.getItemById(itemId);
|
Item item = Item.getItemById(itemId);
|
||||||
int meta = filter[1];
|
int meta = filter[1];
|
||||||
@ -137,40 +136,40 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
int existingSize = 0;
|
int existingSize = 0;
|
||||||
ItemStack existingStack = slots[i + 9];
|
ItemStack existingStack = slots[i + 9];
|
||||||
if(existingStack != null) existingSize = existingStack.stackSize;
|
if(existingStack != null) existingSize = existingStack.stackSize;
|
||||||
|
|
||||||
ItemStack newStack = new ItemStack(item, 1, meta);
|
ItemStack newStack = new ItemStack(item, 1, meta);
|
||||||
|
|
||||||
long hash = StackCache.getStackIdentity(itemId, meta, null);
|
long hash = StackCache.getStackIdentity(itemId, meta, null);
|
||||||
if(hash == this.cache.getNullIdentity()) continue; // safeguard
|
if(hash == this.cache.getNullIdentity()) continue; // safeguard
|
||||||
|
|
||||||
CacheSlot cacheSlot = this.cache.cacheSlots.get(hash);
|
CacheSlot cacheSlot = this.cache.cacheSlots.get(hash);
|
||||||
if(cacheSlot == null) continue; // safeguard
|
if(cacheSlot == null) continue; // safeguard
|
||||||
|
|
||||||
slots[i + 9] = newStack;
|
slots[i + 9] = newStack;
|
||||||
slots[i + 9].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, requestSize);
|
slots[i + 9].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, requestSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns false if the slot delay should be reset (unsuccessful) or true of not (successful or delay still active) */
|
/** Returns false if the slot delay should be reset (unsuccessful) or true of not (successful or delay still active) */
|
||||||
public boolean requestSlot(int slot, boolean force) {
|
public boolean requestSlot(int slot, boolean force) {
|
||||||
|
|
||||||
if(!force && slotDelay[slot] > 0) return true;
|
if(!force && slotDelay[slot] > 0) return true;
|
||||||
if(this.cache == null || this.cache.hasExpired) return false;
|
if(this.cache == null || this.cache.hasExpired) return false;
|
||||||
|
|
||||||
short[] filter = this.getFilter(slot);
|
short[] filter = this.getFilter(slot);
|
||||||
if(filter == null) return false;
|
if(filter == null) return false;
|
||||||
|
|
||||||
int itemId = filter[0];
|
int itemId = filter[0];
|
||||||
Item item = Item.getItemById(itemId);
|
Item item = Item.getItemById(itemId);
|
||||||
int meta = filter[1];
|
int meta = filter[1];
|
||||||
int requestSize = filter[2];
|
int requestSize = filter[2];
|
||||||
|
|
||||||
int existingSize = 0;
|
int existingSize = 0;
|
||||||
ItemStack existingStack = slots[slot + 9];
|
ItemStack existingStack = slots[slot + 9];
|
||||||
|
|
||||||
if(existingStack != null) {
|
if(existingStack != null) {
|
||||||
if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) {
|
if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) {
|
||||||
existingSize = existingStack.stackSize;
|
existingSize = existingStack.stackSize;
|
||||||
@ -178,31 +177,31 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack newStack = new ItemStack(item, 1, meta);
|
ItemStack newStack = new ItemStack(item, 1, meta);
|
||||||
int capacityLeft = newStack.getMaxStackSize() - existingSize;
|
int capacityLeft = newStack.getMaxStackSize() - existingSize;
|
||||||
|
|
||||||
// any non-AMAP mode will fail if it can't insert that much before we even check availability from the pneumo sys
|
// any non-AMAP mode will fail if it can't insert that much before we even check availability from the pneumo sys
|
||||||
if(capacityLeft < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false;
|
if(capacityLeft < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false;
|
||||||
long hash = StackCache.getStackIdentity(itemId, meta, null);
|
long hash = StackCache.getStackIdentity(itemId, meta, null);
|
||||||
if(hash == this.cache.getNullIdentity()) return false;
|
if(hash == this.cache.getNullIdentity()) return false;
|
||||||
|
|
||||||
CacheSlot cacheSlot = this.cache.cacheSlots.get(hash);
|
CacheSlot cacheSlot = this.cache.cacheSlots.get(hash);
|
||||||
if(cacheSlot == null) return false;
|
if(cacheSlot == null) return false;
|
||||||
|
|
||||||
// any non-AMAP mode will fail if the system doesn't have the requested amount
|
// any non-AMAP mode will fail if the system doesn't have the requested amount
|
||||||
if(cacheSlot.stacksize < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false;
|
if(cacheSlot.stacksize < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false;
|
||||||
if(cacheSlot.stacksize <= 0) return false;
|
if(cacheSlot.stacksize <= 0) return false;
|
||||||
|
|
||||||
int toPull = (int) BobMathUtil.min(requestSize, cacheSlot.stacksize, capacityLeft);
|
int toPull = (int) BobMathUtil.min(requestSize, cacheSlot.stacksize, capacityLeft);
|
||||||
|
|
||||||
slots[slot + 9] = newStack;
|
slots[slot + 9] = newStack;
|
||||||
slots[slot + 9].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, toPull);
|
slots[slot + 9].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, toPull);
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns item id, meta and request size for the given filter. Returns null if no filter is specified */
|
/** Returns item id, meta and request size for the given filter. Returns null if no filter is specified */
|
||||||
public short[] getFilter(int slot) {
|
public short[] getFilter(int slot) {
|
||||||
if(rorConfiguredMode) {
|
if(rorConfiguredMode) {
|
||||||
@ -216,7 +215,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAvailability(int item, int meta) {
|
public long getAvailability(int item, int meta) {
|
||||||
if(this.cache == null || this.cache.hasExpired) return 0;
|
if(this.cache == null || this.cache.hasExpired) return 0;
|
||||||
long hash = this.cache.getStackIdentity(item, meta, null);
|
long hash = this.cache.getStackIdentity(item, meta, null);
|
||||||
@ -255,7 +254,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
this.continuousRequest = nbt.getBoolean("continuousRequest");
|
this.continuousRequest = nbt.getBoolean("continuousRequest");
|
||||||
this.rorConfiguredMode = nbt.getBoolean("rorConfiguredMode");
|
this.rorConfiguredMode = nbt.getBoolean("rorConfiguredMode");
|
||||||
this.requestMode = nbt.getByte("requestMode");
|
this.requestMode = nbt.getByte("requestMode");
|
||||||
@ -264,7 +263,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
rorFilters[i][1] = nbt.getShort("filter_" + i + "_1");
|
rorFilters[i][1] = nbt.getShort("filter_" + i + "_1");
|
||||||
rorFilters[i][2] = nbt.getShort("filter_" + i + "_2");
|
rorFilters[i][2] = nbt.getShort("filter_" + i + "_2");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastRedstone = nbt.getBoolean("lastRedstone");
|
this.lastRedstone = nbt.getBoolean("lastRedstone");
|
||||||
this.slotDelay = nbt.getIntArray("slotDelay");
|
this.slotDelay = nbt.getIntArray("slotDelay");
|
||||||
}
|
}
|
||||||
@ -276,7 +275,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
nbt.setBoolean("continuousRequest", continuousRequest);
|
nbt.setBoolean("continuousRequest", continuousRequest);
|
||||||
nbt.setBoolean("rorConfiguredMode", rorConfiguredMode);
|
nbt.setBoolean("rorConfiguredMode", rorConfiguredMode);
|
||||||
nbt.setByte("requestMode", (byte) requestMode);
|
nbt.setByte("requestMode", (byte) requestMode);
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++) {
|
for(int i = 0; i < 9; i++) {
|
||||||
nbt.setShort("filter_" + i + "_0", (short) rorFilters[i][0]);
|
nbt.setShort("filter_" + i + "_0", (short) rorFilters[i][0]);
|
||||||
nbt.setShort("filter_" + i + "_1", (short) rorFilters[i][1]);
|
nbt.setShort("filter_" + i + "_1", (short) rorFilters[i][1]);
|
||||||
@ -318,6 +317,15 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
@Override
|
@Override
|
||||||
public void nextMode(int i) { }
|
public void nextMode(int i) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFilterContents(NBTTagCompound nbt) {
|
||||||
|
int slot = nbt.getInteger("slot");
|
||||||
|
NBTTagCompound stack = nbt.getCompoundTag("stack");
|
||||||
|
ItemStack item = ItemStack.loadItemStackFromNBT(stack);
|
||||||
|
this.setInventorySlotContents(slot, item);
|
||||||
|
this.markChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getFunctionInfo() {
|
public String[] getFunctionInfo() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
@ -331,7 +339,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String runRORFunction(String name, String[] params) {
|
public String runRORFunction(String name, String[] params) {
|
||||||
|
|
||||||
if((PREFIX_FUNCTION + "setfilter").equals(name) && params.length == 4) {
|
if((PREFIX_FUNCTION + "setfilter").equals(name) && params.length == 4) {
|
||||||
int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1;
|
int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1;
|
||||||
int itemId = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE);
|
int itemId = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE);
|
||||||
@ -344,25 +352,25 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
this.markChanged();
|
this.markChanged();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((PREFIX_FUNCTION + "setcontinuous").equals(name) && params.length == 1) {
|
if((PREFIX_FUNCTION + "setcontinuous").equals(name) && params.length == 1) {
|
||||||
if("on".equals(params[0])) this.continuousRequest = true;
|
if("on".equals(params[0])) this.continuousRequest = true;
|
||||||
if("off".equals(params[0])) this.continuousRequest = false;
|
if("off".equals(params[0])) this.continuousRequest = false;
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((PREFIX_FUNCTION + "request").equals(name)) {
|
if((PREFIX_FUNCTION + "request").equals(name)) {
|
||||||
this.doRequest(true);
|
this.doRequest(true);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((PREFIX_FUNCTION + "requestslot").equals(name) && params.length == 1) {
|
if((PREFIX_FUNCTION + "requestslot").equals(name) && params.length == 1) {
|
||||||
int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1;
|
int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1;
|
||||||
if(!this.requestSlot(slot, true)) this.slotDelay[slot] = SLOT_DELAY;
|
if(!this.requestSlot(slot, true)) this.slotDelay[slot] = SLOT_DELAY;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((PREFIX_FUNCTION + "checkavailability").equals(name) && params.length == 3) {
|
if((PREFIX_FUNCTION + "checkavailability").equals(name) && params.length == 3) {
|
||||||
int itemId = IRORInteractive.parseInt(params[0], 0, Short.MAX_VALUE);
|
int itemId = IRORInteractive.parseInt(params[0], 0, Short.MAX_VALUE);
|
||||||
int meta = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE);
|
int meta = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE);
|
||||||
@ -371,7 +379,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
|||||||
RTTYSystem.broadcast(worldObj, ret, availability + "");
|
RTTYSystem.broadcast(worldObj, ret, availability + "");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,10 +20,10 @@ public class TileEntityPneumoStorageMono extends TileEntityPneumaticStorageBase
|
|||||||
|
|
||||||
public static final int CAPACITY = 100_000;
|
public static final int CAPACITY = 100_000;
|
||||||
public int[] amounts;
|
public int[] amounts;
|
||||||
|
|
||||||
public TileEntityPneumoStorageMono() {
|
public TileEntityPneumoStorageMono() {
|
||||||
super(3);
|
super(3);
|
||||||
|
|
||||||
this.amounts = new int[this.monitors.length];
|
this.amounts = new int[this.monitors.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +65,19 @@ public class TileEntityPneumoStorageMono extends TileEntityPneumaticStorageBase
|
|||||||
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
return new GUIPneumoStorageMono(player.inventory, this);
|
return new GUIPneumoStorageMono(player.inventory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public long getAmountAt(int index) { return amounts[index]; }
|
@Override public long getAmountAt(int index) { return amounts[index]; }
|
||||||
@Override public boolean allowTypeSetting() { return false; }
|
@Override public boolean allowTypeSetting() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveControl(NBTTagCompound data) {
|
||||||
|
super.receiveControl(data);
|
||||||
|
|
||||||
|
if(data.hasKey("slot")){
|
||||||
|
setFilterContents(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long useUpItem(int index, long amount) {
|
public long useUpItem(int index, long amount) {
|
||||||
if(amounts[index] <= 0) return amount;
|
if(amounts[index] <= 0) return amount;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user