This commit is contained in:
Anuken 2020-10-30 09:24:05 -04:00
parent a9f5aa9220
commit 782307374f
6 changed files with 14 additions and 7 deletions

View File

@ -130,7 +130,7 @@ public class SectorInfo{
entity.items.clear(); entity.items.clear();
entity.items.add(items); entity.items.add(items);
//ensure capacity. //ensure capacity.
entity.items.each((i, a) -> entity.items.set(i, Math.min(a, entity.storageCapacity))); entity.items.each((i, a) -> entity.items.set(i, Mathf.clamp(a, 0, entity.storageCapacity)));
} }
} }

View File

@ -21,6 +21,12 @@ public class ItemSeq implements Iterable<ItemStack>, Serializable{
stacks.each(this::add); stacks.each(this::add);
} }
public void checkNegative(){
for(int i = 0; i < values.length; i++){
if(values[i] < 0) values[i] = 0;
}
}
public ItemSeq copy(){ public ItemSeq copy(){
ItemSeq out = new ItemSeq(); ItemSeq out = new ItemSeq();
out.total = total; out.total = total;

View File

@ -170,6 +170,7 @@ public class Sector{
} }
}else if(hasBase()){ }else if(hasBase()){
items.each((item, amount) -> info.items.add(item, Math.min(info.storageCapacity - info.items.get(item), amount))); items.each((item, amount) -> info.items.add(item, Math.min(info.storageCapacity - info.items.get(item), amount)));
info.items.checkNegative();
saveInfo(); saveInfo();
} }
} }

View File

@ -40,7 +40,7 @@ public class MessageBlock extends Block{
int count = 0; int count = 0;
for(int i = 0; i < text.length(); i++){ for(int i = 0; i < text.length(); i++){
char c = text.charAt(i); char c = text.charAt(i);
if(c == '\n' || c == '\r'){ if(c == '\n'){
count ++; count ++;
if(count <= maxNewlines){ if(count <= maxNewlines){
tile.message.append('\n'); tile.message.append('\n');
@ -95,12 +95,12 @@ public class MessageBlock extends Block{
}else{ }else{
BaseDialog dialog = new BaseDialog("@editmessage"); BaseDialog dialog = new BaseDialog("@editmessage");
dialog.setFillParent(false); dialog.setFillParent(false);
TextArea a = dialog.cont.add(new TextArea(message.toString().replace("\n", "\r"))).size(380f, 160f).get(); TextArea a = dialog.cont.add(new TextArea(message.toString().replace("\r", "\n"))).size(380f, 160f).get();
a.setFilter((textField, c) -> { a.setFilter((textField, c) -> {
if(c == '\n' || c == '\r'){ if(c == '\n'){
int count = 0; int count = 0;
for(int i = 0; i < textField.getText().length(); i++){ for(int i = 0; i < textField.getText().length(); i++){
if(textField.getText().charAt(i) == '\n' || textField.getText().charAt(i) == '\r'){ if(textField.getText().charAt(i) == '\n'){
count++; count++;
} }
} }

View File

@ -103,7 +103,7 @@ public class ItemModule extends BlockModule{
public void each(ItemConsumer cons){ public void each(ItemConsumer cons){
for(int i = 0; i < items.length; i++){ for(int i = 0; i < items.length; i++){
if(items[i] > 0){ if(items[i] != 0){
cons.accept(content.item(i), items[i]); cons.accept(content.item(i), items[i]);
} }
} }

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=111e6e5134d06c8b017a126d8884cf49978b219c archash=64d0a3b6aee8ac3da5ae0db6e0ec2074349e996a