Mechanical Arm Round Robin

- added a scroll option to the arm that enables round robin for in- and output
This commit is contained in:
Zelophed 2020-08-31 16:01:26 +02:00
parent 6cf36e47bf
commit 53e0c61da7
13 changed files with 191 additions and 45 deletions

View file

@ -130,7 +130,7 @@ de8a40b7daf1497d5aecee47a43b3e0b1d030b00 assets/create/blockstates/fancy_scoria_
fc9ac0a7e7191b93516719455a17177fa6524ecc assets/create/blockstates/fancy_weathered_limestone_bricks_slab.json fc9ac0a7e7191b93516719455a17177fa6524ecc assets/create/blockstates/fancy_weathered_limestone_bricks_slab.json
b2a7c321b1795f20e7433f81a55ce4683de081b8 assets/create/blockstates/fancy_weathered_limestone_bricks_stairs.json b2a7c321b1795f20e7433f81a55ce4683de081b8 assets/create/blockstates/fancy_weathered_limestone_bricks_stairs.json
6372fe02ba0065acb0758121c45a15a1a8fdc5de assets/create/blockstates/fancy_weathered_limestone_bricks_wall.json 6372fe02ba0065acb0758121c45a15a1a8fdc5de assets/create/blockstates/fancy_weathered_limestone_bricks_wall.json
fe9169716dd21a81a3710a89f0a9b7ea4dcd4d51 assets/create/blockstates/fluid_pipe.json d96007df2f19d5af2924dce680ae9bc960a2e6da assets/create/blockstates/fluid_pipe.json
f0eaab18e16c4f3f65ebf3b55b08f0dc445720fe assets/create/blockstates/fluid_tank.json f0eaab18e16c4f3f65ebf3b55b08f0dc445720fe assets/create/blockstates/fluid_tank.json
e9da1794b6ece7f9aa8bcb43d42c23a55446133b assets/create/blockstates/flywheel.json e9da1794b6ece7f9aa8bcb43d42c23a55446133b assets/create/blockstates/flywheel.json
ac00d40e1ef50a37041c0481afa1a23a14dea78e assets/create/blockstates/framed_glass.json ac00d40e1ef50a37041c0481afa1a23a14dea78e assets/create/blockstates/framed_glass.json
@ -303,7 +303,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl
3a739f9d4276828d83f2d2750bf3227c87bcd438 assets/create/blockstates/pulley_magnet.json 3a739f9d4276828d83f2d2750bf3227c87bcd438 assets/create/blockstates/pulley_magnet.json
469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets/create/blockstates/pulse_repeater.json 469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets/create/blockstates/pulse_repeater.json
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json 92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
8d7e653bfd9846e684a0d3725595714a19201017 assets/create/blockstates/radial_chassis.json 4439fc83a8c7370ab44b211a3fd48abde20a4728 assets/create/blockstates/radial_chassis.json
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
8929677f2cc5354aa19ef182af69f9f0b41eb242 assets/create/blockstates/redstone_contact.json 8929677f2cc5354aa19ef182af69f9f0b41eb242 assets/create/blockstates/redstone_contact.json
c29213b77ac0c78d8979c5f6188d2b265696f9b9 assets/create/blockstates/redstone_link.json c29213b77ac0c78d8979c5f6188d2b265696f9b9 assets/create/blockstates/redstone_link.json
@ -361,16 +361,16 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json 7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
1fe3d6fb515b8951750daf6ff274006e14c96b32 assets/create/lang/en_ud.json 1fe3d6fb515b8951750daf6ff274006e14c96b32 assets/create/lang/en_ud.json
5854ea893224d4c8f316055fe351bc901663b7c5 assets/create/lang/en_us.json 78132f4ad6bb368cfede5759614a51996642dbaf assets/create/lang/en_us.json
a72da7a232cf1fde241a6bfa1625aa16437dcf55 assets/create/lang/unfinished/de_de.json 89e41a7841615a8600e0c9875dbbf8102116bc54 assets/create/lang/unfinished/de_de.json
ba2b39cb59687f0baa78355f6adff30faf3306de assets/create/lang/unfinished/fr_fr.json 12b8c64ebfa1e9616db6ffd6dd7f702bb6b7d286 assets/create/lang/unfinished/fr_fr.json
f15f964d19eaf33c29f31daf7349c182183e6615 assets/create/lang/unfinished/it_it.json b6b65233c4c85abc1a32f3dbc079993cbb6184c7 assets/create/lang/unfinished/it_it.json
1ada6540b9cefe1421b59b62d7908d798576f2d1 assets/create/lang/unfinished/ja_jp.json d5c762f5a17d4736db53d4001ad4431e76bb3387 assets/create/lang/unfinished/ja_jp.json
38a726b5442a0cff2ca85d82244046a29e2f7ab8 assets/create/lang/unfinished/ko_kr.json 885a0593c22386cf88d9f221ef08883a02ec589b assets/create/lang/unfinished/ko_kr.json
b7adfb420ffca283f8d1dbbe5f0cd48ee5e159c1 assets/create/lang/unfinished/nl_nl.json da888d1e22b0a191770fdf39e0221c956fa274fb assets/create/lang/unfinished/nl_nl.json
4996a7078d8fec5c02faae83f831b626cf8edf29 assets/create/lang/unfinished/pt_br.json bf72f08cae43a08d4fb729a82a7470e33146e6c7 assets/create/lang/unfinished/pt_br.json
461a3ded936c9a53df319f09313e94cf35c53baf assets/create/lang/unfinished/ru_ru.json a9c15400e799bad4fb74b897e1be8b6bfc74ea69 assets/create/lang/unfinished/ru_ru.json
02de79ff2a8762bbeed85cfacf6e9174b951634c assets/create/lang/unfinished/zh_cn.json bc857a89d28460d79f67c6f10358455434faecf0 assets/create/lang/unfinished/zh_cn.json
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets/create/models/block/acacia_window.json 846200eb548d3bfa2e77b41039de159b4b6cfb45 assets/create/models/block/acacia_window.json
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets/create/models/block/acacia_window_pane_noside.json 1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets/create/models/block/acacia_window_pane_noside.json
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets/create/models/block/acacia_window_pane_noside_alt.json 1763ea2c9b981d187f5031ba608f3d5d3be3986a assets/create/models/block/acacia_window_pane_noside_alt.json

View file

@ -848,6 +848,11 @@
"create.mechanical_mixer.min_ingredients": "Min. Ingredients", "create.mechanical_mixer.min_ingredients": "Min. Ingredients",
"create.mechanical_arm.selection_mode": "Selection Mode",
"create.mechanical_arm.selection_mode.default": "First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "Enforce Round Robin",
"create.gui.config.overlay1": "Hi :)", "create.gui.config.overlay1": "Hi :)",
"create.gui.config.overlay2": "This is a sample overlay", "create.gui.config.overlay2": "This is a sample overlay",
"create.gui.config.overlay3": "Click or drag with your mouse", "create.gui.config.overlay3": "Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 817", "_": "Missing Localizations: 821",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "UNLOCALIZED: Min. Ingredients", "create.mechanical_mixer.min_ingredients": "UNLOCALIZED: Min. Ingredients",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 420", "_": "Missing Localizations: 424",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "Ingrédients min.", "create.mechanical_mixer.min_ingredients": "Ingrédients min.",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 404", "_": "Missing Localizations: 408",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "Ingredienti Min.", "create.mechanical_mixer.min_ingredients": "Ingredienti Min.",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 399", "_": "Missing Localizations: 403",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "最小 材料", "create.mechanical_mixer.min_ingredients": "最小 材料",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 404", "_": "Missing Localizations: 408",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "최소 재료 종류", "create.mechanical_mixer.min_ingredients": "최소 재료 종류",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 754", "_": "Missing Localizations: 758",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "Min. Ingredieënten", "create.mechanical_mixer.min_ingredients": "Min. Ingredieënten",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 824", "_": "Missing Localizations: 828",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "UNLOCALIZED: Min. Ingredients", "create.mechanical_mixer.min_ingredients": "UNLOCALIZED: Min. Ingredients",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 818", "_": "Missing Localizations: 822",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "UNLOCALIZED: Min. Ingredients", "create.mechanical_mixer.min_ingredients": "UNLOCALIZED: Min. Ingredients",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,5 +1,5 @@
{ {
"_": "Missing Localizations: 80", "_": "Missing Localizations: 84",
"_": "->------------------------] Game Elements [------------------------<-", "_": "->------------------------] Game Elements [------------------------<-",
@ -849,6 +849,11 @@
"create.mechanical_mixer.min_ingredients": "最少物品种类数", "create.mechanical_mixer.min_ingredients": "最少物品种类数",
"create.mechanical_arm.selection_mode": "UNLOCALIZED: Selection Mode",
"create.mechanical_arm.selection_mode.default": "UNLOCALIZED: First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "UNLOCALIZED: Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "UNLOCALIZED: Enforce Round Robin",
"create.gui.config.overlay1": "UNLOCALIZED: Hi :)", "create.gui.config.overlay1": "UNLOCALIZED: Hi :)",
"create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay", "create.gui.config.overlay2": "UNLOCALIZED: This is a sample overlay",
"create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse", "create.gui.config.overlay3": "UNLOCALIZED: Click or drag with your mouse",

View file

@ -1,18 +1,18 @@
package com.simibubi.create.content.logistics.block.mechanicalArm; package com.simibubi.create.content.logistics.block.mechanicalArm;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPoint.Jukebox; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPoint.Jukebox;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPoint.Mode; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPoint.Mode;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.widgets.InterpolatedAngle; import com.simibubi.create.foundation.gui.widgets.InterpolatedAngle;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.JukeboxBlock; import net.minecraft.block.JukeboxBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -20,9 +20,14 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT; import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.Constants.NBT;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ArmTileEntity extends KineticTileEntity { public class ArmTileEntity extends KineticTileEntity {
// Server // Server
@ -46,6 +51,11 @@ public class ArmTileEntity extends KineticTileEntity {
float previousBaseAngle; float previousBaseAngle;
boolean updateInteractionPoints; boolean updateInteractionPoints;
//
protected ScrollOptionBehaviour<SelectionMode> selectionMode;
protected int lastInputIndex = -1;
protected int lastOutputIndex = -1;
enum Phase { enum Phase {
SEARCH_INPUTS, MOVE_TO_INPUT, SEARCH_OUTPUTS, MOVE_TO_OUTPUT, DANCING SEARCH_INPUTS, MOVE_TO_INPUT, SEARCH_OUTPUTS, MOVE_TO_OUTPUT, DANCING
} }
@ -66,6 +76,18 @@ public class ArmTileEntity extends KineticTileEntity {
updateInteractionPoints = true; updateInteractionPoints = true;
} }
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
selectionMode = new ScrollOptionBehaviour<>(SelectionMode.class, Lang.translate("mechanical_arm.selection_mode"), this,
new CenteredSideValueBoxTransform((blockState, direction) -> {
return direction != Direction.DOWN && direction != Direction.UP;
}));
selectionMode.requiresWrench();
behaviours.add(selectionMode);
}
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
@ -163,37 +185,80 @@ public class ArmTileEntity extends KineticTileEntity {
} }
protected void searchForItem() { protected void searchForItem() {
for (int index = 0; index < inputs.size(); index++) { boolean foundInput = false;
ArmInteractionPoint armInteractionPoint = inputs.get(index); //for round robin, we start looking after the last used index, for default we start at 0;
for (int i = 0; i < armInteractionPoint.getSlotCount(world); i++) { int startIndex = selectionMode.get() == SelectionMode.DEFAULT ? 0 : lastInputIndex + 1;
if (getDistributableAmount(armInteractionPoint, i) == 0)
//if we enforce round robin, only look at the next input in the list, otherwise, look at all inputs
int scanRange = selectionMode.get() == SelectionMode.ROUND_ROBIN_HARD ? lastInputIndex + 2 : inputs.size();
if (scanRange > inputs.size())
scanRange = inputs.size();
InteractionPoints: for (int i = startIndex; i < scanRange; i++) {
ArmInteractionPoint armInteractionPoint = inputs.get(i);
for (int j = 0; j < armInteractionPoint.getSlotCount(world); j++) {
if (getDistributableAmount(armInteractionPoint, j) == 0)
continue; continue;
phase = Phase.MOVE_TO_INPUT; selectIndex(true, i);
chasedPointIndex = index; foundInput = true;
chasedPointProgress = 0; break InteractionPoints;
sendData();
markDirty();
return;
} }
} }
if (!foundInput && selectionMode.get() == SelectionMode.ROUND_ROBIN_SOFT) {
//if we didn't find an input, but don't want to enforce round robin, reset the last index
lastInputIndex = -1;
}
if (lastInputIndex == inputs.size() - 1) {
//if we reached the last input in the list, reset the last index
lastInputIndex = -1;
}
} }
protected void searchForDestination() { protected void searchForDestination() {
ItemStack held = heldItem.copy(); ItemStack held = heldItem.copy();
for (int index = 0; index < outputs.size(); index++) {
ArmInteractionPoint armInteractionPoint = outputs.get(index); boolean foundOutput = false;
//for round robin, we start looking after the last used index, for default we start at 0;
int startIndex = selectionMode.get() == SelectionMode.DEFAULT ? 0 : lastOutputIndex + 1;
//if we enforce round robin, only look at the next index in the list, otherwise, look at all
int scanRange = selectionMode.get() == SelectionMode.ROUND_ROBIN_HARD ? lastOutputIndex + 2 : outputs.size();
if (scanRange > outputs.size())
scanRange = outputs.size();
for (int i = startIndex; i < scanRange; i++) {
ArmInteractionPoint armInteractionPoint = outputs.get(i);
ItemStack remainder = armInteractionPoint.insert(world, held, true); ItemStack remainder = armInteractionPoint.insert(world, held, true);
if (remainder.equals(heldItem, false)) if (remainder.equals(heldItem, false))
continue; continue;
phase = Phase.MOVE_TO_OUTPUT; selectIndex(false, i);
foundOutput = true;
break;
}
if (!foundOutput && selectionMode.get() == SelectionMode.ROUND_ROBIN_SOFT) {
//if we didn't find an input, but don't want to enforce round robin, reset the last index
lastOutputIndex = -1;
}
if (lastOutputIndex == outputs.size() - 1) {
//if we reached the last input in the list, reset the last index
lastOutputIndex = -1;
}
}
//input == true => select input, false => select output
private void selectIndex(boolean input, int index) {
phase = input ? Phase.MOVE_TO_INPUT : Phase.MOVE_TO_OUTPUT;
chasedPointIndex = index; chasedPointIndex = index;
chasedPointProgress = 0; chasedPointProgress = 0;
if (input)
lastInputIndex = index;
else
lastOutputIndex = index;
sendData(); sendData();
markDirty(); markDirty();
return;
}
} }
protected int getDistributableAmount(ArmInteractionPoint armInteractionPoint, int i) { protected int getDistributableAmount(ArmInteractionPoint armInteractionPoint, int i) {
@ -322,4 +387,30 @@ public class ArmTileEntity extends KineticTileEntity {
} }
} }
public enum SelectionMode implements INamedIconOptions {
DEFAULT(AllIcons.I_TOOL_MIRROR),//first valid interaction points gets used
ROUND_ROBIN_SOFT(AllIcons.I_TOOL_ROTATE),//attempt round robin, but skip invalid points
ROUND_ROBIN_HARD(AllIcons.I_TOOL_ROTATE),//enforce round robin, wait for invalid points to be ready again
;
private final String translationKey;
private final AllIcons icon;
SelectionMode(AllIcons icon) {
this.icon = icon;
this.translationKey = "mechanical_arm.selection_mode." + Lang.asId(name());
}
@Override
public AllIcons getIcon() {
return icon;
}
@Override
public String getTranslationKey() {
return translationKey;
}
}
} }

View file

@ -343,6 +343,11 @@
"create.tooltip.analogStrength": "Analog Strength: %1$s/15", "create.tooltip.analogStrength": "Analog Strength: %1$s/15",
"create.mechanical_mixer.min_ingredients": "Min. Ingredients", "create.mechanical_mixer.min_ingredients": "Min. Ingredients",
"create.mechanical_arm.selection_mode": "Selection Mode",
"create.mechanical_arm.selection_mode.default": "First Valid Target",
"create.mechanical_arm.selection_mode.round_robin_soft": "Attempt Round Robin",
"create.mechanical_arm.selection_mode.round_robin_hard": "Enforce Round Robin",
"create.gui.config.overlay1": "Hi :)", "create.gui.config.overlay1": "Hi :)",
"create.gui.config.overlay2": "This is a sample overlay", "create.gui.config.overlay2": "This is a sample overlay",
"create.gui.config.overlay3": "Click or drag with your mouse", "create.gui.config.overlay3": "Click or drag with your mouse",