Skip to content

Commit 2601471

Browse files
committed
Updated for 1.21.1
1 parent eca5759 commit 2601471

40 files changed

Lines changed: 464 additions & 432 deletions

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<artifactId>BasicCircuits</artifactId>
77
<packaging>jar</packaging>
88
<name>BasicCircuits</name>
9-
<version>1.1-SNAPSHOT</version>
9+
<version>1.0-SNAPSHOT</version>
1010
<url>http://maven.apache.org</url>
1111
<build>
1212
<plugins>
@@ -30,10 +30,17 @@
3030
</plugins>
3131
</build>
3232
<dependencies>
33+
<dependency>
34+
<groupId>org.bukkit</groupId>
35+
<artifactId>bukkit</artifactId>
36+
<version>1.15.2-R0.1-SNAPSHOT</version>
37+
<type>jar</type>
38+
<scope>provided</scope>
39+
</dependency>
3340
<dependency>
3441
<groupId>org.redstonechips</groupId>
3542
<artifactId>RedstoneChips</artifactId>
36-
<version>1.0-SNAPSHOT</version>
43+
<version>1.1-SNAPSHOT</version>
3744
</dependency>
3845
</dependencies>
3946
<properties>

src/main/java/org/redstonechips/basiccircuits/BasicCircuits.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public Class[] getCircuitClasses() {
1515
multiplexer.class, multiplier.class, or.class, pisoregister.class, print.class, random.class, receiver.class,
1616
shiftregister.class, transmitter.class, xor.class, decoder.class, encoder.class, pixel.class, pulse.class, not.class,
1717
synth.class, srnor.class, terminal.class, router.class, ringcounter.class, iptransmitter.class, ipreceiver.class,
18-
comparator.class, delay.class, repeater.class, nand.class, nor.class, xnor.class, segdriver.class, dregister.class,
18+
comparator.class, delay.class, repeater.class, nand.class, nor.class, xnor.class, segdriver.class, dregister.class,
1919
sram.class, bintobcd.class, display.class, burst.class, ramwatch.class };
2020
}
2121

src/main/java/org/redstonechips/basiccircuits/SignWriter.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
56
import org.bukkit.Location;
67
import org.bukkit.block.Block;
78
import org.bukkit.block.BlockFace;
@@ -24,48 +25,48 @@ public enum DisplayMode {
2425
}
2526

2627
public static final int LineWidth = 15;
27-
28+
2829
private final Type type;
2930
private final DisplayMode display;
30-
31+
3132
private final StringBuffer textBuffer = new StringBuffer();
3233

3334
private String[] lines = new String[] { "", "", "", "" };
3435
private int scrollPos = 0;
3536
private final List<Location> signList;
36-
37+
3738
public SignWriter(DisplayMode displayMode, Type type, List<Location> signList) {
3839
this.type = type;
3940
this.display = displayMode;
4041
this.signList = signList;
4142
}
42-
43+
4344
public DisplayMode getDisplayMode() {
4445
return display;
4546
}
46-
47+
4748
public String[] getLines() { return lines; }
48-
49-
public void setLines(String[] lines) {
49+
50+
public void setLines(String[] lines) {
5051
this.lines = lines;
5152
}
52-
53+
5354
public String getText() {
5455
return textBuffer.toString();
5556
}
56-
57+
5758
public void setText(String text) {
5859
textBuffer.setLength(0);
5960
textBuffer.append(text.toString());
60-
61+
6162
if (display==DisplayMode.scroll)
6263
prepScrollLines();
6364
else prepWrapLines();
6465
updateSigns();
6566
}
66-
67+
6768
List<Location> getSigns() { return signList; }
68-
69+
6970
public void write(String text) {
7071
if (display==DisplayMode.add) {
7172
add(text);
@@ -79,22 +80,22 @@ public void write(String text) {
7980
add(text);
8081
prepScrollLines();
8182
}
82-
83+
8384
updateSigns();
8485
}
85-
86+
8687
public void write(boolean[] bits, int start, int length) {
8788
write(convertBits(bits, start, length));
8889
}
89-
90+
9091
public void clear() {
9192
textBuffer.setLength(0);
9293
scrollPos = 0;
9394
lines[0] = "";
9495
lines[1] = "";
9596
lines[2] = "";
9697
lines[3] = "";
97-
updateSigns();
98+
updateSigns();
9899
}
99100

100101
public void scroll(int amount) {
@@ -105,9 +106,9 @@ public void scroll(int amount) {
105106

106107
prepScrollLines();
107108

108-
updateSigns();
109+
updateSigns();
109110
}
110-
111+
111112
private void add(String text) {
112113
if (type==Type.ascii || textBuffer.length()==0) {
113114
textBuffer.append(text);
@@ -123,9 +124,9 @@ private void updateSigns() {
123124
s.setLine(2, lines[2]);
124125
s.setLine(3, lines[3]);
125126
s.update();
126-
}
127+
}
127128
}
128-
129+
129130
private void prepScrollLines() {
130131
String window;
131132

@@ -142,7 +143,7 @@ private void prepScrollLines() {
142143
lines[2] = "";
143144
lines[3] = "";
144145
}
145-
146+
146147
private void prepWrapLines() {
147148
if (textBuffer.length()>LineWidth*3) {
148149
String line4 = textBuffer.substring(LineWidth*3);
@@ -160,7 +161,7 @@ private void prepWrapLines() {
160161
} else if (textBuffer.length()>LineWidth) {
161162
lines[0] = textBuffer.substring(0,LineWidth);
162163
lines[1] = textBuffer.substring(LineWidth);
163-
lines[2] = "";
164+
lines[2] = "";
164165
lines[3] = "";
165166
} else {
166167
lines[0] = textBuffer.toString();
@@ -169,7 +170,7 @@ private void prepWrapLines() {
169170
lines[3] = "";
170171
}
171172
}
172-
173+
173174
private String convertBits(boolean[] bits, int start, int length) {
174175
String text = null;
175176

@@ -191,7 +192,7 @@ private String convertBits(boolean[] bits, int start, int length) {
191192

192193
return text;
193194
}
194-
195+
195196
public static SignWriter getSignWriter(DisplayMode mode, Type type, Location... aroundBlocks) {
196197
List<Location> signs = new ArrayList<>();
197198

@@ -209,10 +210,10 @@ public static SignWriter getSignWriter(DisplayMode mode, Type type, Location...
209210
if (checkBlock(i, east)) { signs.add(east); }
210211
if (checkBlock(i, up)) { signs.add(up); }
211212
}
212-
213-
return new SignWriter(mode, type, signs);
213+
214+
return new SignWriter(mode, type, signs);
214215
}
215-
216+
216217
private static boolean checkBlock(Block i, Location s) {
217218
// TODO: Check whether this method loads the chunk or not.
218219
Block sign = s.getBlock();
@@ -223,5 +224,5 @@ private static boolean checkBlock(Block i, Location s) {
223224

224225
} else return false;
225226
}
226-
227+
227228
}

src/main/java/org/redstonechips/basiccircuits/adder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected void bitSetChanged(int bitSetIdx, boolean[] set) {
3535
if (constant != 0) {
3636
output = BooleanArrays.add(output, constant, outputlen);
3737
}
38-
38+
3939
// write result
4040
this.writeBits(output);
4141
}
@@ -53,13 +53,13 @@ public Circuit init(String[] args) {
5353
}
5454

5555
if ((inputlen % wordlength)==0) {
56-
int inBitSetCount = inputlen / wordlength;
57-
inputBitSets = new boolean[inBitSetCount][wordlength];
56+
int inBitSetCount = inputlen / wordlength;
57+
inputBitSets = new boolean[inBitSetCount][wordlength];
5858
} else return error("Invalid number of inputs (" + inputlen + "). Number of inputs must be a multiple of the word length.");
5959

6060
if (args[args.length-1].equalsIgnoreCase("subtract"))
6161
subtract = true;
62-
62+
6363
if ((args.length>1 && !subtract) || (args.length>2)) {
6464
try {
6565
constant = Integer.decode(args[1]);
@@ -68,14 +68,14 @@ public Circuit init(String[] args) {
6868
return error("Bad constant argument: " + args[1] + " expecting a number.");
6969
}
7070
}
71-
71+
7272
int maxResult = ((int)Math.pow(2, wordlength)-1) * inputBitSets.length + constant;
7373
int expectedOutputs = (int)Math.ceil(Math.log(maxResult)/Math.log(2));
7474

75-
if (outputlen<expectedOutputs)
75+
if (outputlen<expectedOutputs)
7676
info(ChatColor.LIGHT_PURPLE + "Warning: Output might overflow. Circuit should have " + expectedOutputs + " output bits.");
77-
78-
info("Activating adder with " + inputBitSets.length + " input set(s) of " + wordlength +
77+
78+
info("Activating adder with " + inputBitSets.length + " input set(s) of " + wordlength +
7979
" bits each. The chip is running in " + (subtract?"subtract":"add") + " mode" + (constant!=0? ", with a constant value of " + constant:"") + ".");
8080
return this;
8181
}

src/main/java/org/redstonechips/basiccircuits/and.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected void bitSetChanged(int bitSetIdx, boolean[] set) {
1717
for (int i=1; i<this.inputBitSets.length; i++) {
1818
BooleanArrays.and(buf, buf, inputBitSets[i]);
1919
}
20-
20+
2121
this.writeBits(buf);
2222
}
2323
}

src/main/java/org/redstonechips/basiccircuits/bintobcd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void input(boolean state, int inIdx) {
1616
value = Long.toString(BooleanArrays.toUnsignedInt(inputs, 0, inputlen));
1717
for (int i=0; i<digits; i++) {
1818
String d;
19-
int digit;
19+
int digit;
2020
if (i<value.length()) {
2121
d = Character.toString(value.charAt(value.length()-i-1));
2222
digit = Integer.decode(d);

src/main/java/org/redstonechips/basiccircuits/burst.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
package org.redstonechips.basiccircuits;
33

4-
import org.redstonechips.parsing.UnitParser;
54
import org.redstonechips.circuit.Circuit;
5+
import org.redstonechips.parsing.UnitParser;
66
import org.redstonechips.util.BooleanArrays;
77

88
/**
@@ -65,7 +65,7 @@ public Circuit init(String[] args) {
6565
} catch (NumberFormatException ne) {
6666
return error("Bad pulse count argument: " + args[0]);
6767
}
68-
68+
6969
try {
7070
frequency = Math.round(UnitParser.parse(args[1]));
7171
} catch (IllegalArgumentException e) {
@@ -78,7 +78,7 @@ public Circuit init(String[] args) {
7878
if (inputlen==0) return error("Expecting at least 1 input pin.");
7979

8080
if (activator!=null) clearOutputs();
81-
81+
8282
burstTask = new BurstTask();
8383
return this;
8484
}
@@ -87,7 +87,7 @@ public Circuit init(String[] args) {
8787
public boolean isStateless() {
8888
return false;
8989
}
90-
90+
9191
private void startBurst() {
9292
if (bursting) return;
9393

@@ -101,7 +101,7 @@ private void startBurst() {
101101
bursting = false;
102102
}
103103
}
104-
104+
105105
private void stopBurst() {
106106
if (!bursting) return;
107107

@@ -110,18 +110,18 @@ private void stopBurst() {
110110
rc.getServer().getScheduler().cancelTask(taskId);
111111
bursting = false;
112112
}
113-
113+
114114
@Override
115115
public void disable() {
116116
stopBurst();
117117
}
118-
118+
119119
@Override
120120
public void shutdown() {
121121
stopBurst();
122122
}
123-
124-
private class BurstTask implements Runnable {
123+
124+
private class BurstTask implements Runnable {
125125
@Override
126126
public void run() {
127127
if (!bursting) return;

0 commit comments

Comments
 (0)