mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 23:37:51 +07:00
outlaw separator desycning (#5516)
* Seed separators * Sync separators * Seed from tile position
This commit is contained in:

committed by
GitHub

parent
c80e800ac9
commit
10dcd9cb2d
@ -30,6 +30,7 @@ public class Separator extends Block{
|
|||||||
solid = true;
|
solid = true;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
hasLiquids = true;
|
hasLiquids = true;
|
||||||
|
sync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,6 +46,12 @@ public class Separator extends Block{
|
|||||||
public float progress;
|
public float progress;
|
||||||
public float totalProgress;
|
public float totalProgress;
|
||||||
public float warmup;
|
public float warmup;
|
||||||
|
public int seed;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void created(){
|
||||||
|
seed = Mathf.randomSeed(tile.pos(), 0, Integer.MAX_VALUE - 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldAmbientSound(){
|
public boolean shouldAmbientSound(){
|
||||||
@ -91,7 +98,7 @@ public class Separator extends Block{
|
|||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(ItemStack stack : results) sum += stack.amount;
|
for(ItemStack stack : results) sum += stack.amount;
|
||||||
|
|
||||||
int i = Mathf.random(sum);
|
int i = Mathf.randomSeed(seed++, 0, sum);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Item item = null;
|
Item item = null;
|
||||||
|
|
||||||
@ -121,11 +128,17 @@ public class Separator extends Block{
|
|||||||
return !consumes.itemFilters.get(item.id);
|
return !consumes.itemFilters.get(item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte version(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(Writes write){
|
public void write(Writes write){
|
||||||
super.write(write);
|
super.write(write);
|
||||||
write.f(progress);
|
write.f(progress);
|
||||||
write.f(warmup);
|
write.f(warmup);
|
||||||
|
write.i(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -133,6 +146,7 @@ public class Separator extends Block{
|
|||||||
super.read(read, revision);
|
super.read(read, revision);
|
||||||
progress = read.f();
|
progress = read.f();
|
||||||
warmup = read.f();
|
warmup = read.f();
|
||||||
|
if(revision == 1) seed = read.i();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user