Permalink
Browse files

Added random 3/5 bit ICs.

  • Loading branch information...
me4502 committed Jun 29, 2017
1 parent 74f4d75 commit abb08b519a497ab9fc06a75fba1ff2f16e0d7ef2
@@ -85,6 +85,8 @@
registerICType(new ICType<>("MC1421", "CLOCK", "Clock", "Outputs high every X ticks when input is high.", new Clock.Factory()));
//SI3O
registerICType(new ICType<>("MC2020", "RANDOM 3", "Random 3-Bit", "Randomly sets the outputs on high.", new RandomBit.Factory(), "SI3O"));
registerICType(new ICType<>("MC2300", "ROM GET", "ROM Get", "Gets the memory state from a file for usage in the MemorySetter/Access IC group.", new MemoryAccess.Factory(), "SI3O"));
//3ISO
@@ -113,6 +115,8 @@
registerICType(new ICType<>("MC4100", "FULL SUBTR", "Full Subtractor", "A compact full-subtractor", new FullSubtractor.Factory(), "3I3O"));
registerICType(new ICType<>("MC4110", "HALF SUBTR", "Half Subtractor", "A compact half-subtractor", new HalfSubtractor.Factory(), "3I3O"));
registerICType(new ICType<>("MC4200", "DISPATCH", "Dispatcher", "Outputs the centre input on the appropriate outputs when input is high.", new Dispatcher.Factory(), "3I3O"));
registerICType(new ICType<>("MC6020", "RANDOM 5", "Random 5-Bit", "Randomly sets the outputs on high.", new RandomBit.Factory(), "SI5O"));
}
public static void registerICType(ICType<? extends IC> ic) {
@@ -106,6 +106,7 @@ public RandomBit createInstance(Location<World> location) {
@Override
public String[][] getPinHelp() {
return new String[][] {
new String[] {
"High to output random state"
@@ -0,0 +1,60 @@
/*
* CraftBook Copyright (C) 2010-2017 sk89q <http://www.sk89q.com>
* CraftBook Copyright (C) 2011-2017 me4502 <http://www.me4502.com>
* CraftBook Copyright (C) Contributors
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not,
* see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.craftbook.sponge.mechanics.ics.pinsets;
import com.sk89q.craftbook.sponge.mechanics.ics.IC;
import com.sk89q.craftbook.sponge.util.SignUtil;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
public class PinsSI5O extends PinSet {
@Override
public int getInputCount() {
return 1;
}
@Override
public int getOutputCount() {
return 5;
}
@Override
public String getName() {
return "SI5O";
}
@Override
public Location<World> getPinLocation(int id, IC ic) {
switch(id) {
case 0:
return ic.getBlock().getRelative(SignUtil.getFront(ic.getBlock()));
case 1:
return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock()));
case 2:
return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getLeft(ic.getBlock()));
case 3:
return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getRight(ic.getBlock()));
case 4:
return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getLeft(ic.getBlock()));
case 5:
return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getRight(ic.getBlock()));
default:
return null;
}
}
}

0 comments on commit abb08b5

Please sign in to comment.