mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
parent
a9f5aa9220
commit
782307374f
@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user