Skip to content

Commit 293fcda

Browse files
authored
Add files via upload
1 parent 96cfdf3 commit 293fcda

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repositories{
1212
}
1313

1414
dependencies{
15-
def version = "v120"
15+
def version = "v129.2"
1616
compileOnly "com.github.Anuken.Arc:arc-core:$version"
1717
compileOnly "com.github.Anuken.Mindustry:core:$version"
1818
}
@@ -33,6 +33,6 @@ jar{
3333
}
3434

3535
from(rootDir){
36-
include "plugin.hjson"
36+
include "plugin.json"
3737
}
3838
}

src/routerSnakeMod/routerSnake.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import mindustry.gen.Iconc;
99
import mindustry.content.*;
1010
import mindustry.world.Tile;
11-
import mindustry.entities.comp.*;
1211
import arc.Core.*;
1312
import arc.math.*;
1413
import arc.util.*;
@@ -27,6 +26,7 @@ public class routerSnake{
2726
public Seq<float[]> segments = new Seq<>();
2827
public int length = 12;
2928
public boolean canDecay = false;
29+
public static float[] tmp = new float[2];
3030

3131
public routerSnake(float x, float y, boolean canDecay, int length){
3232
this.x = x;
@@ -41,9 +41,15 @@ public routerSnake(float x, float y, boolean canDecay, int length){
4141
public void update(){
4242
i += Time.delta;
4343
if(i > 10f){
44+
if(length < 1){
45+
routerSnakeMod.snakes.remove(this);
46+
return;
47+
};
4448
Call.label(routerSnakeMod.rout, length / 6f, x, y);
45-
segments.remove(0);
46-
segments.add(new float[]{x, y});
49+
tmp = segments.remove(0);
50+
tmp[0] = x;
51+
tmp[1] = y;
52+
segments.add(tmp);
4753
while(segments.size < length){
4854
segments.add(new float[]{x, y});
4955
};
@@ -70,12 +76,8 @@ public void update(){
7076
target = null;
7177
};
7278
if((length > 12 || canDecay) && Mathf.chance(0.0005f * Math.max((float)length, 10))){
73-
if(length == 1){
74-
routerSnakeMod.snakes.remove(this);
75-
}else{
76-
length--;
77-
segments.remove(0);
78-
};
79+
length--;
80+
segments.remove(0);
7981
};
8082
if(target != null && target.unit().type != null){
8183
heading = Mathf.slerp(heading, Mathf.angle(target.x - x, target.y - y), 0.25f);
@@ -98,10 +100,14 @@ public void update(){
98100
if(newTile != null && newTile.build != null){
99101
Building newBuild = newTile.build;
100102
if(newBuild.block == Blocks.distributor){
101-
newBuild.damage(40f * (float)length / 12f);
103+
newBuild.damage(Math.min(40f * (float)length / 12f, 80f));
102104
x -= Mathf.cosDeg(heading) * 10f;
103105
y -= Mathf.sinDeg(heading) * 10f;
104106
heading = Mathf.angle(x - newBuild.x, y - newBuild.y);
107+
if(Mathf.chance(0.02f * length)){
108+
length++;
109+
segments.add(new float[]{x, y});
110+
};
105111
}else if(newBuild.block == Blocks.router && Mathf.chance((length < 10 && length != 0) ? 0.5f / length : 0.05f)){
106112
if(Mathf.chance(0.005f * length)){
107113
routerSnakeMod.snakes.add(new routerSnake(x, y, true, length / 2));

src/routerSnakeMod/routerSnakeMod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public void init(){
4747
public void registerClientCommands(CommandHandler handler){
4848
handler.<Player>register("spawnsnake", "<x> <y> <canDie> <length>", "Spawn a router snake.", (args, player) -> {
4949
try{
50-
if(Integer.parseInt(args[3]) > 100){
51-
player.sendMessage("The specified length is too long.");
50+
if(Integer.parseInt(args[3]) > 100 || Integer.parseInt(args[3]) < 1){
51+
player.sendMessage("The specified length is invalid.");
5252
}else if(!player.admin){
5353
player.sendMessage("You need to be admin to spawn snakes.");
5454
}else{

0 commit comments

Comments
 (0)