Skip to content

Commit

Permalink
filter-repo src
Browse files Browse the repository at this point in the history
git filter-repo --path core/src/mindustryX --invert-paths --prune-empty=never --force
  • Loading branch information
way-zer committed Sep 17, 2024
1 parent 95c3691 commit 50fc921
Show file tree
Hide file tree
Showing 61 changed files with 117 additions and 11,488 deletions.
26 changes: 0 additions & 26 deletions patches/client/0002-API-MindustryXApi.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,3 @@ From: way-zer <[email protected]>
Date: Sun, 17 Sep 2023 11:51:44 +0800
Subject: [PATCH] API: @MindustryXApi

---
core/src/mindustryX/MindustryXApi.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 core/src/mindustryX/MindustryXApi.java

diff --git a/core/src/mindustryX/MindustryXApi.java b/core/src/mindustryX/MindustryXApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..04318b009a90b632bf7947910ca24055c3f7e7bb
--- /dev/null
+++ b/core/src/mindustryX/MindustryXApi.java
@@ -0,0 +1,15 @@
+package mindustryX;
+
+import java.lang.annotation.*;
+
+@Documented
+@Retention(RetentionPolicy.SOURCE)
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
+public @interface MindustryXApi{
+ /** Need Keep for compatibility with vanilla */
+ @Documented
+ @Retention(RetentionPolicy.SOURCE)
+ @Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
+ public @interface Keep{
+ }
+}
33 changes: 4 additions & 29 deletions patches/client/0004-API-Hooks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Date: Wed, 3 Apr 2024 21:57:24 +0800
Subject: [PATCH] API: Hooks

---
core/src/mindustry/ClientLauncher.java | 1 +
core/src/mindustry/Vars.java | 1 +
core/src/mindustryX/Hooks.java | 17 +++++++++++++++++
server/src/mindustry/server/ServerLauncher.java | 1 +
4 files changed, 20 insertions(+)
create mode 100644 core/src/mindustryX/Hooks.java
core/src/mindustry/ClientLauncher.java | 1 +
core/src/mindustry/Vars.java | 1 +
server/src/mindustry/server/ServerLauncher.java | 1 +
3 files changed, 3 insertions(+)

diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java
index c68681b7a9d6caf8e0ed8dace53b839efbf34eb5..1b5a25a7cbbd00c5a8e463ec722fb3b3ac5da9d6 100644
Expand All @@ -35,29 +33,6 @@ index d7756c3df025ba0e76882f656501d7d560c87114..d6b74b8a99a5ae12248f4dead618a374
Groups.init();

if(loadLocales){
diff --git a/core/src/mindustryX/Hooks.java b/core/src/mindustryX/Hooks.java
new file mode 100644
index 0000000000000000000000000000000000000000..499a9f3403c6769288ad44e7fb4a68ffb36bc591
--- /dev/null
+++ b/core/src/mindustryX/Hooks.java
@@ -0,0 +1,17 @@
+package mindustryX;
+
+import arc.*;
+import arc.util.*;
+
+public class Hooks implements ApplicationListener{
+ /** invoke before `Vars.init`. Note that may be executed from `Vars.loadAsync` */
+ public static void beforeInit(){
+ Log.infoTag("MindustryX", "Hooks.beforeInit");
+ }
+
+ /** invoke after loading, just before `Mod::init` */
+ @Override
+ public void init(){
+ Log.infoTag("MindustryX", "Hooks.init");
+ }
+}
diff --git a/server/src/mindustry/server/ServerLauncher.java b/server/src/mindustry/server/ServerLauncher.java
index 1aea11b2cc877ef9a35280575e6419d9fab16f01..1799c999b2affdc0de392841212edc1f544e4751 100644
--- a/server/src/mindustry/server/ServerLauncher.java
Expand Down
49 changes: 2 additions & 47 deletions patches/client/0005-CS-Bundle-Extend.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,10 @@ Date: Tue, 9 Apr 2024 18:21:28 +0800
Subject: [PATCH] CS: Bundle Extend

---
core/assets/bundles/bundle-mdtx.properties | 0
core/src/mindustryX/Hooks.java | 22 ++++++++++++++++++++++
2 files changed, 22 insertions(+)
core/assets/bundles/bundle-mdtx.properties | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 core/assets/bundles/bundle-mdtx.properties

diff --git a/core/assets/bundles/bundle-mdtx.properties b/core/assets/bundles/bundle-mdtx.properties
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/core/src/mindustryX/Hooks.java b/core/src/mindustryX/Hooks.java
index 499a9f3403c6769288ad44e7fb4a68ffb36bc591..ca6144798666f96ee074838e489b51df1a10d19d 100644
--- a/core/src/mindustryX/Hooks.java
+++ b/core/src/mindustryX/Hooks.java
@@ -1,12 +1,16 @@
package mindustryX;

import arc.*;
+import arc.files.*;
import arc.util.*;

+import java.util.*;
+
public class Hooks implements ApplicationListener{
/** invoke before `Vars.init`. Note that may be executed from `Vars.loadAsync` */
public static void beforeInit(){
Log.infoTag("MindustryX", "Hooks.beforeInit");
+ registerBundle();
}

/** invoke after loading, just before `Mod::init` */
@@ -14,4 +18,22 @@ public class Hooks implements ApplicationListener{
public void init(){
Log.infoTag("MindustryX", "Hooks.init");
}
+
+ private static void registerBundle(){
+ //MDTX: bundle overwrite
+ try{
+ I18NBundle originBundle = Core.bundle;
+ Fi handle = Core.files.internal("bundles/bundle-mdtx");
+ Core.bundle = I18NBundle.createBundle(handle, Locale.getDefault());
+ Reflect.set(Core.bundle, "locale", originBundle.getLocale());
+ Log.info("MDTX: bundle has been loaded.");
+ var rootBundle = Core.bundle;
+ while(rootBundle.getParent() != null){
+ rootBundle = rootBundle.getParent();
+ }
+ Reflect.set(rootBundle, "parent", originBundle);
+ }catch(Throwable e){
+ Log.err(e);
+ }
+ }
}
47 changes: 3 additions & 44 deletions patches/client/0008-API-add-SendPacketEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ Date: Fri, 23 Jun 2023 16:18:22 +0800
Subject: [PATCH] API: add SendPacketEvent

---
core/src/mindustry/net/ArcNetProvider.java | 3 ++
core/src/mindustry/net/Net.java | 6 +++-
.../mindustryX/events/SendPacketEvent.java | 33 +++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
create mode 100644 core/src/mindustryX/events/SendPacketEvent.java
core/src/mindustry/net/ArcNetProvider.java | 3 +++
core/src/mindustry/net/Net.java | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/core/src/mindustry/net/ArcNetProvider.java b/core/src/mindustry/net/ArcNetProvider.java
index e7a1a33dd6b4a523900d841d08246d0383ce2f30..23e8b294d646f2835750a1b085ae826032c3c627 100644
Expand Down Expand Up @@ -72,42 +70,3 @@ index 145238bf8856c7b83da468b89362c3d1df5d5928..7db098b1985ea7df7516f43ab4b0c49f
con.send(object, reliable);
}
}
diff --git a/core/src/mindustryX/events/SendPacketEvent.java b/core/src/mindustryX/events/SendPacketEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..11e0817d8d2f2fc95cb40027660372f6662b9b6b
--- /dev/null
+++ b/core/src/mindustryX/events/SendPacketEvent.java
@@ -0,0 +1,33 @@
+package mindustryX.events;
+
+import arc.*;
+import arc.util.*;
+import mindustry.net.*;
+import mindustryX.*;
+
+@MindustryXApi
+public class SendPacketEvent{
+ /** null for all, may emit again */
+ @Nullable
+ public NetConnection con;
+ /** only when call in sendExcept */
+ @Nullable
+ public NetConnection except;
+ public Object packet;
+ public boolean isCancelled;
+
+ private SendPacketEvent(){
+ }
+
+ private static final SendPacketEvent inst = new SendPacketEvent();
+
+ /** @return isCancelled */
+ public static boolean emit(@Nullable NetConnection con, @Nullable NetConnection except, Object packet){
+ inst.isCancelled = false;
+ inst.con = con;
+ inst.except = except;
+ inst.packet = packet;
+ Events.fire(inst);
+ return inst.isCancelled;
+ }
+}
37 changes: 4 additions & 33 deletions patches/client/0011-API-add-LogicAssembledEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Date: Thu, 3 Aug 2023 12:20:38 +0800
Subject: [PATCH] API: add LogicAssembledEvent

---
core/src/mindustry/logic/LParser.java | 4 +++-
core/src/mindustry/logic/LStatements.java | 11 ++++++++++
.../world/blocks/logic/LogicBlock.java | 4 ++++
.../events/LogicAssembledEvent.java | 21 +++++++++++++++++++
4 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 core/src/mindustryX/events/LogicAssembledEvent.java
core/src/mindustry/logic/LParser.java | 4 +++-
core/src/mindustry/logic/LStatements.java | 11 +++++++++++
core/src/mindustry/world/blocks/logic/LogicBlock.java | 4 ++++
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/core/src/mindustry/logic/LParser.java b/core/src/mindustry/logic/LParser.java
index 6f65e9981f2291d1c892c23f3ec8603aec8e3a4c..32133826223d3e4fe1be991c8abd3bc23d720779 100644
Expand Down Expand Up @@ -90,30 +88,3 @@ index b0af04af3eb5311bee7ef27fa0208f99d23d7894..12cda95f81156b8b5ce60d3ab97aa6db
executor.load(asm);
}catch(Exception e){
//handle malformed code and replace it with nothing
diff --git a/core/src/mindustryX/events/LogicAssembledEvent.java b/core/src/mindustryX/events/LogicAssembledEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..4db97d52e70a6cd0b53346d86461b3677da44138
--- /dev/null
+++ b/core/src/mindustryX/events/LogicAssembledEvent.java
@@ -0,0 +1,21 @@
+package mindustryX.events;
+
+import mindustry.logic.*;
+import mindustry.world.blocks.logic.LogicBlock.*;
+import mindustryX.*;
+
+/**
+ * Fired after LAssembler finish assemble and about to load to LExecutor
+ * Allow mods to modify LAssembler, try parse InvalidStatement again.
+ * Not fired when LogicBlock load empty code.
+ */
+@MindustryXApi
+public class LogicAssembledEvent{
+ public LogicBuild build;
+ public LAssembler assembler;
+
+ public LogicAssembledEvent(LogicBuild build, LAssembler assembler){
+ this.build = build;
+ this.assembler = assembler;
+ }
+}
39 changes: 0 additions & 39 deletions patches/client/0014-API-Hooks-onHttp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,3 @@ From: way-zer <[email protected]>
Date: Tue, 9 Apr 2024 18:23:19 +0800
Subject: [PATCH] API(Hooks) onHttp

---
core/src/mindustryX/Hooks.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/core/src/mindustryX/Hooks.java b/core/src/mindustryX/Hooks.java
index ca6144798666f96ee074838e489b51df1a10d19d..7cace088409de5b701577465f38ae01eb8b87a1c 100644
--- a/core/src/mindustryX/Hooks.java
+++ b/core/src/mindustryX/Hooks.java
@@ -4,6 +4,7 @@ import arc.*;
import arc.files.*;
import arc.util.*;

+import java.net.*;
import java.util.*;

public class Hooks implements ApplicationListener{
@@ -19,6 +20,22 @@ public class Hooks implements ApplicationListener{
Log.infoTag("MindustryX", "Hooks.init");
}

+ @SuppressWarnings("unused")//call before arc.util.Http$HttpRequest.block
+ public static void onHttp(Http.HttpRequest req){
+ if(Core.settings.getBool("githubMirror")){
+ try{
+ String url = req.url;
+ String host = new URL(url).getHost();
+ if(host.contains("github.com") || host.contains("raw.githubusercontent.com")){
+ url = "https://gh.tinylake.tech/" + url;
+ req.url = url;
+ }
+ }catch(Exception e){
+ //ignore
+ }
+ }
+ }
+
private static void registerBundle(){
//MDTX: bundle overwrite
try{
65 changes: 3 additions & 62 deletions patches/client/0015-API-RenderExt.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ Date: Tue, 26 Mar 2024 19:22:00 +0800
Subject: [PATCH] API: RenderExt

---
core/src/mindustry/core/Renderer.java | 3 ++-
.../src/mindustry/graphics/BlockRenderer.java | 3 ++-
core/src/mindustryX/Hooks.java | 5 ++++
core/src/mindustryX/features/RenderExt.java | 27 +++++++++++++++++++
4 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 core/src/mindustryX/features/RenderExt.java
core/src/mindustry/core/Renderer.java | 3 ++-
core/src/mindustry/graphics/BlockRenderer.java | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java
index ae3ae07e384731434e66a31ee13bfaa1576a83a8..01b2872b6ab744ad12f44049feb6146ce8ad84d5 100644
Expand Down Expand Up @@ -53,59 +50,3 @@ index aec39b666137666976321336b698e80177b05f84..5c57b1309660e500c38099d362b46a62
Draw.reset();
Draw.z(Layer.block);

diff --git a/core/src/mindustryX/Hooks.java b/core/src/mindustryX/Hooks.java
index 7cace088409de5b701577465f38ae01eb8b87a1c..1548f3d6ae0d362575a05ef38ea1575af65f5afc 100644
--- a/core/src/mindustryX/Hooks.java
+++ b/core/src/mindustryX/Hooks.java
@@ -3,6 +3,8 @@ package mindustryX;
import arc.*;
import arc.files.*;
import arc.util.*;
+import mindustry.*;
+import mindustryX.features.*;

import java.net.*;
import java.util.*;
@@ -18,6 +20,9 @@ public class Hooks implements ApplicationListener{
@Override
public void init(){
Log.infoTag("MindustryX", "Hooks.init");
+ if(!Vars.headless){
+ RenderExt.init();
+ }
}

@SuppressWarnings("unused")//call before arc.util.Http$HttpRequest.block
diff --git a/core/src/mindustryX/features/RenderExt.java b/core/src/mindustryX/features/RenderExt.java
new file mode 100644
index 0000000000000000000000000000000000000000..835b5d7b801f03683cbb7502ea98025ff2c24d40
--- /dev/null
+++ b/core/src/mindustryX/features/RenderExt.java
@@ -0,0 +1,27 @@
+package mindustryX.features;
+
+import arc.*;
+import arc.util.*;
+import mindustry.game.EventType.*;
+import mindustry.gen.*;
+import mindustry.world.*;
+
+public class RenderExt{
+ public static void init(){
+ Events.run(Trigger.preDraw, () -> {
+ });
+ Events.run(Trigger.draw, RenderExt::draw);
+ }
+
+ private static void draw(){
+
+ }
+
+ public static void onGroupDraw(Drawc t){
+ t.draw();
+ }
+
+ public static void onBlockDraw(Tile tile, Block block, @Nullable Building build){
+ block.drawBase(tile);
+ }
+}
Loading

0 comments on commit 50fc921

Please sign in to comment.