From 3b9b1af2044fca58b02a56bf3aaba4d46a897cb4 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Thu, 14 Aug 2014 23:24:53 +0200 Subject: [PATCH] further work in requesting orders, for #1973 --- .../api/robots/IDockingStation.java | 2 + api/buildcraft/api/robots/IRobotRegistry.java | 13 +++--- api/buildcraft/api/robots/StackRequest.java | 1 + .../assets/buildcraft/lang/en_US.lang | 1 + .../textures/entities/robot_delivery.png | Bin 0 -> 1757 bytes .../triggers/action_station_accept_items.png | Bin 0 -> 522 bytes .../action_station_machine_request.png | Bin 449 -> 455 bytes .../triggers/action_station_request_items.png | Bin 522 -> 520 bytes .../action_station_robot_mandatory.png | Bin 0 -> 332 bytes common/buildcraft/BuildCraftSilicon.java | 10 +++-- .../core/robots/AIRobotDeliverRequested.java | 21 ++++++--- .../core/robots/AIRobotGotoStation.java | 4 +- .../robots/AIRobotGotoStationToUnload.java | 6 +-- .../buildcraft/core/robots/AIRobotUnload.java | 15 +++++-- .../core/robots/DockingStation.java | 1 + .../buildcraft/core/robots/EntityRobot.java | 3 +- .../buildcraft/core/robots/RobotRegistry.java | 23 +++++----- .../buildcraft/core/robots/StationIndex.java | 5 ++- .../core/robots/boards/BoardRobotCrafter.java | 41 +++++++++++++++++- .../statements/ActionRobotGotoStation.java | 3 +- ....java => ActionStationAcceptItemsInv.java} | 10 ++--- ...java => ActionStationAcceptItemsPipe.java} | 4 +- .../statements/ActionStationInputItems.java | 30 +++++++++++++ .../statements/ActionStationRequestItems.java | 41 +++++++++++++++--- .../statements/RobotsActionProvider.java | 1 + .../transport/ItemRobotStation.java | 3 +- 26 files changed, 181 insertions(+), 57 deletions(-) create mode 100755 buildcraft_resources/assets/buildcraft/textures/entities/robot_delivery.png create mode 100755 buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_accept_items.png create mode 100755 buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_robot_mandatory.png rename common/buildcraft/silicon/statements/{ActionStationRequestItemsInv.java => ActionStationAcceptItemsInv.java} (89%) rename common/buildcraft/silicon/statements/{ActionStationRequestItemsPipe.java => ActionStationAcceptItemsPipe.java} (94%) create mode 100755 common/buildcraft/silicon/statements/ActionStationInputItems.java diff --git a/api/buildcraft/api/robots/IDockingStation.java b/api/buildcraft/api/robots/IDockingStation.java index da16f9aa..cb635715 100755 --- a/api/buildcraft/api/robots/IDockingStation.java +++ b/api/buildcraft/api/robots/IDockingStation.java @@ -37,4 +37,6 @@ public interface IDockingStation { void readFromNBT(NBTTagCompound nbt); BlockIndex index(); + + boolean take(EntityRobotBase robot); } diff --git a/api/buildcraft/api/robots/IRobotRegistry.java b/api/buildcraft/api/robots/IRobotRegistry.java index bd48a298..9537b3b3 100755 --- a/api/buildcraft/api/robots/IRobotRegistry.java +++ b/api/buildcraft/api/robots/IRobotRegistry.java @@ -14,7 +14,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.ResourceId; public interface IRobotRegistry { @@ -41,17 +40,17 @@ public interface IRobotRegistry { void releaseResources(EntityRobotBase robot); - DockingStation getStation(int x, int y, int z, ForgeDirection side); + IDockingStation getStation(int x, int y, int z, ForgeDirection side); - Collection getStations(); + Collection getStations(); - void registerStation(DockingStation station); + void registerStation(IDockingStation station); - void removeStation(DockingStation station); + void removeStation(IDockingStation station); - void take(DockingStation station, long robotId); + void take(IDockingStation station, long robotId); - void release(DockingStation station, long robotId); + void release(IDockingStation station, long robotId); void writeToNBT(NBTTagCompound nbt); diff --git a/api/buildcraft/api/robots/StackRequest.java b/api/buildcraft/api/robots/StackRequest.java index 29556cf2..7a6163c8 100755 --- a/api/buildcraft/api/robots/StackRequest.java +++ b/api/buildcraft/api/robots/StackRequest.java @@ -15,4 +15,5 @@ public class StackRequest { public ItemStack stack; public int index; public TileEntity requester; + public IDockingStation station; } diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index b635cb3f..2cd4dbb1 100755 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -63,6 +63,7 @@ gate.action.pipe.wire=%s Pipe Signal gate.action.robot.goto_station=Goto Station gate.action.pipe.close=Close Pipe gate.action.station.provide_items=Provide Items +gate.action.station.accept_items=Accept Items gate.action.station.request_items=Request Items gate.action.station.drop_items_in_pipe=Drop Items In Pipe gate.action.station.craft=Craft diff --git a/buildcraft_resources/assets/buildcraft/textures/entities/robot_delivery.png b/buildcraft_resources/assets/buildcraft/textures/entities/robot_delivery.png new file mode 100755 index 0000000000000000000000000000000000000000..a60cd541a413af551bd88a02882a409d551b4b73 GIT binary patch literal 1757 zcmV<31|s>1P)1VMaVABn(La6N3rnVqafBuI<}}#}4+rJf;LG zJ{z0!KYww)$2sTwe-<#=cl=t|f5oR0=P=4;034EpX_}NO6&#WT!0mrc3mj!MvEy^2 z+z00l)vZD4|dYhb+_K_v7vP=e~UTFnf6L{`(8Uq6Z7>2>g z@5~;GFMpFw{N%a*hh3L|j!VWz+Qf{lrz3?r<9sMMn^&BO5>e?|wX^K*<{Ubh^JqG3?3ROlb*Cphq_E&oss z7@M5j7q8v+4yo&F1A=t}4l`~}R45dRZ02;^*W_1!&Ns|2d=|s&_0rYVg|6!s;}Z*G z2%>;Pmht=jDB(}`(*%f&O-VB}qn75~LAN16OwLJ~mF7a3k%MO9T6 zHe5Vajp|v}s~M1794DX86AFd+a(clV%mX}xXocM>O2(se~SI>`{H!f62Bz1oN@e%;P|8b19oR8_1>MefbLIr>y z{C4&@aN+u(MyVpPmdcY#SEC*7a1sf$p%r1`PZEQV+NhMvB$G+bUV7eO+|$p`ptux7 zQ6k{?qeTANSRvl)r?a!umM>S|@f5vbe|@q$+(v0#M-aVVS9mF+4)NIV?r>W*8m=7g zoQYI#@j?+rankjhQuUsZWj0mSV!XC?k%tc-($jMSm!epVSC`MTxw*L~U#`95adn#y ze%fdIj@RD#rH0L~&W@mNZxafIkYyQv|GfshxOtVG zoix#C6w|EO^2ORa?vw(yZ+s0OKH)hwyy_r{WJW;M9V9aXy}x^zF+UsBY45w+zHI}P}5 zzQEC|)#Dw<+z$|Gp;6QGCwhAD`g|7S=ce936vcW!pxJmke#>M)P0yQ^%AxuJ%|*~& z{FZRQ;{8Di`TT+X0H>m$XS25bfW7#y{Si3se!y$*fJivPdSV^JFc|voGfVj!2>5Y2 zofw8;+YdO1|Jomcjm2>s4%t@EXZ0-MaD*pMmiFui=(@fyUw+*);2=GJiqu!p_!E(2MscR00000NkvXXu0mjfWlCET literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_accept_items.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_accept_items.png new file mode 100755 index 0000000000000000000000000000000000000000..05bd69caabad304a790b3b27959c0b0769ce813d GIT binary patch literal 522 zcmV+l0`>igP)2#iX@VfYaU5*h#`8R? z)vCm4r{apXZBr~3>G%8edOfn)EH_0euBep4bzL463bfm8lv2qD)L)kIeV=?j&))7X zjYfko3@H`nlW$;I7Fug^xg5UlqqRmPR?0OnwHHea21E2Pq_c8tp1yx50RAB4_~i6< zh|}pb`>$PdnRiw^1MuYCf+VtFq6u%k$5+H}zRrm;Q8EUSO0((CQ2V$f0QIf19Q?X} z;}zom;NSZ7t@4#Tj#=y@Ek84ybca||Bb1uv(@~!vGLy{0pUH&v?SReCBNkt+vA#3n z@HE4j4yaTr$*xc<-Q{Ob=ytm}x$$3LCPS;$LPY*Qz(f;f?+h8MfG;0bnX}-*J;nFm zQ8I{odHBQ`oZ*(a6?^X3vxbkR;>7#lb|`gTo!4)Sl2oFA36wg3PC M07*qoM6N<$g5Ch=ga7~l literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_machine_request.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_machine_request.png index fc56cc722e9f0862218deab05bb95bbcbf82a54d..89711f46555b5828178bc9cc3f817a9f6ba19759 100755 GIT binary patch delta 381 zcmV-@0fPR)1IGi9Q-2N=7%ZQo6dM2l0aQsuK~y-)jgzrX!cY{3zeAyk(qaP9NDOhY z2{sxNR}I9)K_}k8#aHqrjFaI37{m!jNa`fII0y+1g+}1I)MBL#z01it_rL%7&wp}- znA2*t)O0$fTrOjpCjEY&dc7`j*lb+UG)=12Dx=Ye;c!SkpMNLmWa5gtuH!fk2bM*r z(?Qqu^aPi+Q(V`jR4Vb@ZqsNq@O>ZKs-#z77zUo_Q79B}T^G;u5Q&AdV$8+a3FGku zZ{pLOWz}`|TL9d#&)di6dJ}V+#=SdNzgNv!P61qPiliDrE#^Gbvr&8{H;w|0A5^76HvxP{0FN+}f*oeTRqFh?-}b^>$}cv^ZFo$HX0Ky?*jOMKhj z^4;ogic1BmtHOLGCK3!%#&rrPg4ltIKlLzA{7nBkMM#1?nV^T*R)y~CJ4aT9Mc|c) bB(CuX2sCoi8+6wY00000NkvXXu0mjfXb7}l delta 375 zcmV--0f_#`1Hl83Q-1>#87iHzSh4^B0ZvIoK~y-)jgvu30$~t_pV3+fT@OkJA?wnH zZGzynNW6FrZ~l}1MSr92U4!tDL0}Mw!gg}&;voeWSND)#7hBtQ7x%ji?=bVuJMZub z5wFwfsO54=u~2yjalYb%ZrJ|CWreRqY$A&?# z*F)2^ngaU5LNMI^G6kTH$(D)adQ zcj3`*k5uLEPyn2{$LMps-NfB=nwKj}{o;PxRsd(WN0Mj-wfg49J_!_Gza5BDt7INX zD$TvMN8_O?0C3I6n!JAP$6g^YNh#$^mkWUjkS83UHhsapPVouUKq00?j~#CM!net9 z6sUpnaVW+TOcKUz3dn<)YZZU;K92oN|0V@U);OMEh?qu+!TSdlqr__Mm59Wi@dtIo VbbOE+fC2yj002ovPDHLkV1knYwch{$ diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_request_items.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_request_items.png index 05bd69caabad304a790b3b27959c0b0769ce813d..8b885053f3657cd6d380f7468ddcb1bceaedc6af 100755 GIT binary patch delta 448 zcmV;x0YCnV1c(HXQhx{z6d5vnw-`A900EUrL_t(I%Z-vxOB+EL#($IDOrzON4x!pb zg&quqfE0U4p}!6XUH%_p+Hu$nM`kkGiPHw)!?X~IEST|# zZ!69{@%oY$#(#{HF%T(-?bZ~ZUw8swZ7wfhKd?V}+t-+yIeZ^-dwhQBJJQmG_MVYNKXRaemIbO>_s zKVK$8qtQS-2*b6dF#BvkEF*q?|H8ZnGkMARpK&sXB01#{_!^NhyeZEDp!JZgUnpm* delta 450 zcmV;z0X_bR1d0TZQhx>(4Hg_8lTg*VOFBL(sC& z+8&IAC=_#vAQ*B9c#=R5{U&~b_UL!$NspFZg%aqWSV&dKp)9?0twJRd$u@6xW3q1# zwnFLF?%ZbP$1uNVMu>@KvuT1Lz;PUG+s5-es@1B*X{X|fwtsC?EEeha`}BG}ve_&* zMJleSl)`mg9u*3-+ijFm$p_S5mhpX`d_K?K?k^f08ea%`Tye<%R{AmsSu^md5T=`{PVU2~atRy+gnm9{FCSK!v*5u!#rNM)GCPQpO5@lek}*6l%>odHBQ`oZ s*(a6?^X3vxbkR;>7#lb|`gTo!4)Sl2oFA36wg3PC07*qoM6N<$g1}4KmH+?% diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_robot_mandatory.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_robot_mandatory.png new file mode 100755 index 0000000000000000000000000000000000000000..e59fb99b5f50aa8013bb459582f4915bfa98d4bd GIT binary patch literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPq2cL)x=Z4d)5kR4vo-U3d7N?g6Z{%t=5ZNQbE7IFN zdCOwK<$8Y^_Ai|OCP`h~Jz8MNxu!;qk`2L2ZXD6t_wni7r#rs)C4?RQ$Ppa->)-P9 zvj?w#E;bPqSwG>0huVg-voAjDo#wDNQ}iFR{-iSpz2$(S{P+5W1KpNpTJarjP~bQq z;T(J2V^YhCo%u_ry%Rqs@yNpMdTGXOvA)L=qOv8vUYe&ixty^4WW&DnipPRbg_ef* zzjvfd<^{H_TD48HAXYrct70CzBFmB~Y2nw`1?=3HHFfs8g!ihGbR$ogMk-Wa-m%;6 YVN+xJlq1n~Ku resourcesTaken = new HashMap(); private HashMap> resourcesTakenByRobot = new HashMap>(); - private HashMap stations = new HashMap(); + private HashMap stations = new HashMap(); private HashMap> stationsTakenByRobot = new HashMap>(); public RobotRegistry(String id) { @@ -190,7 +191,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { .clone(); for (StationIndex s : stationSet) { - DockingStation d = stations.get(s); + DockingStation d = (DockingStation) stations.get(s); if (!d.canRelease()) { if (forceAll) { @@ -208,7 +209,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public DockingStation getStation(int x, int y, int z, ForgeDirection side) { + public IDockingStation getStation(int x, int y, int z, ForgeDirection side) { StationIndex index = new StationIndex(side, x, y, z); if (stations.containsKey(index)) { @@ -219,12 +220,12 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public Collection getStations() { + public Collection getStations() { return stations.values(); } @Override - public void registerStation(DockingStation station) { + public void registerStation(IDockingStation station) { markDirty(); StationIndex index = new StationIndex(station); @@ -237,7 +238,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public void removeStation(DockingStation station) { + public void removeStation(IDockingStation station) { markDirty(); StationIndex index = new StationIndex(station); @@ -252,7 +253,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public void take(DockingStation station, long robotId) { + public void take(IDockingStation station, long robotId) { if (!stationsTakenByRobot.containsKey(robotId)) { stationsTakenByRobot.put(robotId, new HashSet()); } @@ -261,7 +262,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public void release(DockingStation station, long robotId) { + public void release(IDockingStation station, long robotId) { if (stationsTakenByRobot.containsKey(robotId)) { stationsTakenByRobot.get(robotId).remove(new StationIndex(station)); } @@ -280,8 +281,8 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { newRegistry.world = world; - for (DockingStation d : newRegistry.stations.values()) { - d.world = world; + for (IDockingStation d : newRegistry.stations.values()) { + ((DockingStation) d).world = world; } registries[world.provider.dimensionId] = newRegistry; @@ -310,7 +311,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { NBTTagList stationList = new NBTTagList(); - for (Map.Entry e : stations.entrySet()) { + for (Map.Entry e : stations.entrySet()) { NBTTagCompound cpt = new NBTTagCompound(); e.getValue().writeToNBT(cpt); stationList.appendTag(cpt); diff --git a/common/buildcraft/core/robots/StationIndex.java b/common/buildcraft/core/robots/StationIndex.java index 63ba59bb..b390ab61 100755 --- a/common/buildcraft/core/robots/StationIndex.java +++ b/common/buildcraft/core/robots/StationIndex.java @@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.BlockIndex; +import buildcraft.api.robots.IDockingStation; public class StationIndex { @@ -27,8 +28,8 @@ public class StationIndex { index = new BlockIndex(x, y, z); } - public StationIndex(DockingStation station) { - side = station.side; + public StationIndex(IDockingStation station) { + side = station.side(); index = station.index(); } diff --git a/common/buildcraft/core/robots/boards/BoardRobotCrafter.java b/common/buildcraft/core/robots/boards/BoardRobotCrafter.java index bf6ad140..2668f999 100755 --- a/common/buildcraft/core/robots/boards/BoardRobotCrafter.java +++ b/common/buildcraft/core/robots/boards/BoardRobotCrafter.java @@ -28,6 +28,7 @@ import buildcraft.api.boards.RedstoneBoardRobot; import buildcraft.api.boards.RedstoneBoardRobotNBT; import buildcraft.api.gates.ActionParameterItemStack; import buildcraft.api.gates.IActionParameter; +import buildcraft.api.gates.IStatementParameter; import buildcraft.api.recipes.CraftingResult; import buildcraft.api.recipes.IFlexibleRecipe; import buildcraft.api.robots.AIRobot; @@ -49,6 +50,7 @@ import buildcraft.core.robots.AIRobotUnload; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.IStationFilter; import buildcraft.silicon.statements.ActionRobotCraft; +import buildcraft.silicon.statements.ActionStationRequestItems; import buildcraft.silicon.statements.ActionStationRequestItemsMachine; import buildcraft.transport.Pipe; import buildcraft.transport.gates.ActionIterator; @@ -144,7 +146,15 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { craftingBlacklist.clear(); startDelegateAI(new AIRobotGotoSleep(robot)); } else { - currentRequest = getOrderFromRequestingStation(((AIRobotSearchStation) ai).targetStation, true); + currentRequest = getOrderFromRequestingAction(((AIRobotSearchStation) ai).targetStation); + + if (currentRequest == null) { + currentRequest = getOrderFromRequestingStation(((AIRobotSearchStation) ai).targetStation, true); + } + + if (!currentRequest.station.take(robot)) { + currentRequest = null; + } } } else if (ai instanceof AIRobotDeliverRequested) { currentRequest = null; @@ -255,6 +265,8 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { StackRequest request = provider.getAvailableRequest(i); if (request != null && !isBlacklisted(request.stack)) { + request.station = station; + if (take) { if (provider.takeRequest(i, robot)) { return request; @@ -270,11 +282,36 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { return null; } + private StackRequest getOrderFromRequestingAction(DockingStation station) { + boolean actionFound = false; + + Pipe pipe = station.getPipe().pipe; + + for (ActionSlot s : new ActionIterator(pipe)) { + if (s.action instanceof ActionStationRequestItems) { + for (IStatementParameter p : s.parameters) { + ActionParameterItemStack param = (ActionParameterItemStack) p; + + if (param != null && !isBlacklisted(param.getItemStackToDraw())) { + StackRequest req = new StackRequest(); + req.station = station; + req.stack = param.getItemStackToDraw(); + + return req; + } + } + } + } + + return null; + } + private class StationProviderFilter implements IStationFilter { @Override public boolean matches(DockingStation station) { - return getOrderFromRequestingStation(station, false) != null; + return getOrderFromRequestingAction(station) != null + || getOrderFromRequestingStation(station, false) != null; } } } diff --git a/common/buildcraft/silicon/statements/ActionRobotGotoStation.java b/common/buildcraft/silicon/statements/ActionRobotGotoStation.java index d80598f6..a12552a1 100755 --- a/common/buildcraft/silicon/statements/ActionRobotGotoStation.java +++ b/common/buildcraft/silicon/statements/ActionRobotGotoStation.java @@ -72,7 +72,8 @@ public class ActionRobotGotoStation extends BCActionActive { if (index != null) { ForgeDirection side = ItemMapLocation.getSide(item); - DockingStation paramStation = registry.getStation(index.x, + DockingStation paramStation = (DockingStation) + registry.getStation(index.x, index.y, index.z, side); if (paramStation != null) { diff --git a/common/buildcraft/silicon/statements/ActionStationRequestItemsInv.java b/common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java similarity index 89% rename from common/buildcraft/silicon/statements/ActionStationRequestItemsInv.java rename to common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java index 11ef2d53..52b1eb12 100755 --- a/common/buildcraft/silicon/statements/ActionStationRequestItemsInv.java +++ b/common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java @@ -25,20 +25,20 @@ import buildcraft.core.robots.EntityRobot; import buildcraft.core.utils.StringUtils; import buildcraft.transport.gates.ActionSlot; -public class ActionStationRequestItemsInv extends ActionStationRequestItems { +public class ActionStationAcceptItemsInv extends ActionStationInputItems { - public ActionStationRequestItemsInv() { - super("buildcraft:station.request_items"); + public ActionStationAcceptItemsInv() { + super("buildcraft:station.accept_items"); } @Override public String getDescription() { - return StringUtils.localize("gate.action.station.request_items"); + return StringUtils.localize("gate.action.station.accept_items"); } @Override public void registerIcons(IIconRegister iconRegister) { - icon = iconRegister.registerIcon("buildcraft:triggers/action_station_request_items"); + icon = iconRegister.registerIcon("buildcraft:triggers/action_station_accept_items"); } @Override diff --git a/common/buildcraft/silicon/statements/ActionStationRequestItemsPipe.java b/common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java similarity index 94% rename from common/buildcraft/silicon/statements/ActionStationRequestItemsPipe.java rename to common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java index 59ba4fe1..64cdc5ca 100755 --- a/common/buildcraft/silicon/statements/ActionStationRequestItemsPipe.java +++ b/common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java @@ -20,9 +20,9 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TravelingItem; import buildcraft.transport.gates.ActionSlot; -public class ActionStationRequestItemsPipe extends ActionStationRequestItems { +public class ActionStationAcceptItemsPipe extends ActionStationInputItems { - public ActionStationRequestItemsPipe() { + public ActionStationAcceptItemsPipe() { super("buildcraft:station.drop_in_pipe"); } diff --git a/common/buildcraft/silicon/statements/ActionStationInputItems.java b/common/buildcraft/silicon/statements/ActionStationInputItems.java new file mode 100755 index 00000000..dc2331c6 --- /dev/null +++ b/common/buildcraft/silicon/statements/ActionStationInputItems.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.silicon.statements; + +import buildcraft.api.core.IInvSlot; +import buildcraft.core.inventory.filters.StatementParameterStackFilter; +import buildcraft.core.robots.DockingStation; +import buildcraft.core.robots.EntityRobot; +import buildcraft.core.triggers.BCActionPassive; +import buildcraft.transport.gates.ActionSlot; + +public abstract class ActionStationInputItems extends BCActionPassive { + + public ActionStationInputItems(String name) { + super(name); + } + + public boolean insert(DockingStation station, EntityRobot robot, ActionSlot actionSlot, IInvSlot invSlot, + boolean doInsert) { + StatementParameterStackFilter param = new StatementParameterStackFilter(actionSlot.parameters); + + return !param.hasFilter() || param.matches(invSlot.getStackInSlot()); + } +} diff --git a/common/buildcraft/silicon/statements/ActionStationRequestItems.java b/common/buildcraft/silicon/statements/ActionStationRequestItems.java index 8f31ca65..179245ed 100755 --- a/common/buildcraft/silicon/statements/ActionStationRequestItems.java +++ b/common/buildcraft/silicon/statements/ActionStationRequestItems.java @@ -9,21 +9,26 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.IInvSlot; import buildcraft.api.gates.ActionParameterItemStack; import buildcraft.api.gates.IActionParameter; -import buildcraft.core.inventory.filters.StatementParameterStackFilter; +import buildcraft.core.inventory.ITransactor; +import buildcraft.core.inventory.Transactor; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; -import buildcraft.core.triggers.BCActionPassive; import buildcraft.core.utils.StringUtils; import buildcraft.transport.gates.ActionSlot; -public abstract class ActionStationRequestItems extends BCActionPassive { +public class ActionStationRequestItems extends ActionStationInputItems { - public ActionStationRequestItems(String name) { - super(name); + public ActionStationRequestItems() { + super("buildcraft:station.request_items"); } @Override @@ -46,10 +51,32 @@ public abstract class ActionStationRequestItems extends BCActionPassive { return new ActionParameterItemStack(); } + @Override public boolean insert(DockingStation station, EntityRobot robot, ActionSlot actionSlot, IInvSlot invSlot, boolean doInsert) { - StatementParameterStackFilter param = new StatementParameterStackFilter(actionSlot.parameters); + if (!super.insert(station, robot, actionSlot, invSlot, doInsert)) { + return false; + } - return !param.hasFilter() || param.matches(invSlot.getStackInSlot()); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y() + + dir.offsetY, station.z() + + dir.offsetZ); + + if (nearbyTile != null && nearbyTile instanceof IInventory) { + ITransactor trans = Transactor.getTransactorFor(nearbyTile); + + ItemStack added = trans.add(invSlot.getStackInSlot(), dir.getOpposite(), doInsert); + + if (doInsert) { + invSlot.decreaseStackInSlot(added.stackSize); + } + + return true; + + } + } + + return false; } } diff --git a/common/buildcraft/silicon/statements/RobotsActionProvider.java b/common/buildcraft/silicon/statements/RobotsActionProvider.java index 52be71ec..182f054c 100755 --- a/common/buildcraft/silicon/statements/RobotsActionProvider.java +++ b/common/buildcraft/silicon/statements/RobotsActionProvider.java @@ -66,6 +66,7 @@ public class RobotsActionProvider implements IActionProvider { if (((TileGenericPipe) pipe).getTile(dir) instanceof IInventory) { result.add(BuildCraftSilicon.actionStationProvideItems); result.add(BuildCraftSilicon.actionStationRequestItems); + result.add(BuildCraftSilicon.actionStationAcceptItems); } if (((TileGenericPipe) pipe).getTile(dir) instanceof IRequestProvider) { diff --git a/common/buildcraft/transport/ItemRobotStation.java b/common/buildcraft/transport/ItemRobotStation.java index 117ba38f..4cca7e20 100755 --- a/common/buildcraft/transport/ItemRobotStation.java +++ b/common/buildcraft/transport/ItemRobotStation.java @@ -109,7 +109,8 @@ public class ItemRobotStation extends ItemBuildCraft { public void validate(IPipeTile pipe, ForgeDirection direction) { TileGenericPipe gPipe = (TileGenericPipe) pipe; if (!isValid && !gPipe.getWorld().isRemote) { - station = RobotRegistry.getRegistry(gPipe.getWorld()).getStation( + station = (DockingStation) + RobotRegistry.getRegistry(gPipe.getWorld()).getStation( gPipe.xCoord, gPipe.yCoord, gPipe.zCoord,