generated from Anuken/MindustryJavaModTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bridge conveyors of custom length
- Loading branch information
Mars
committed
May 3, 2023
1 parent
43d3454
commit 15f31f9
Showing
5 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.mars.blocks; | ||
|
||
import arc.Events; | ||
import mindustry.content.Blocks; | ||
import mindustry.game.EventType.ContentInitEvent; | ||
import mindustry.world.Block; | ||
import mindustry.world.blocks.distribution.BufferedItemBridge; | ||
import mindustry.world.blocks.power.PowerNode; | ||
|
||
public class BlockHandler { | ||
public static void init() { | ||
Events.on(ContentInitEvent.class, contentInitEvent -> { | ||
new WeavedNode((PowerNode) Blocks.powerNode); | ||
new ShortBridge((BufferedItemBridge) Blocks.itemBridge, 2); | ||
new ShortBridge((BufferedItemBridge) Blocks.itemBridge, 3); | ||
}); | ||
} | ||
|
||
public static void cloneStats(Block block, Block target) { | ||
block.health = target.health; | ||
block.size = target.size; | ||
block.buildCost = target.buildCost; | ||
block.requirements(target.category, target.requirements.clone()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package me.mars.blocks; | ||
|
||
import arc.util.Reflect; | ||
import mindustry.ctype.MappableContent; | ||
import mindustry.entities.units.BuildPlan; | ||
import mindustry.world.blocks.distribution.BufferedItemBridge; | ||
|
||
public class ShortBridge extends BufferedItemBridge { | ||
BufferedItemBridge parent; | ||
public ShortBridge(BufferedItemBridge parent, int range) { | ||
super(parent.name+"["+range+"]"); | ||
this.parent = parent; | ||
BlockHandler.cloneStats(this, parent); | ||
this.range = Math.min(parent.range-1, range); | ||
this.itemCapacity = parent.itemCapacity; | ||
this.bufferCapacity = parent.bufferCapacity; | ||
this.init(); | ||
} | ||
|
||
@Override | ||
public void load() { | ||
String name = this.name; | ||
Reflect.set(MappableContent.class, this, "name", parent.name); | ||
super.load(); | ||
Reflect.set(MappableContent.class, this, "name", name); | ||
this.region = parent.region; | ||
} | ||
|
||
@Override | ||
public void loadIcon() { | ||
String name = this.name; | ||
Reflect.set(MappableContent.class, this, "name", parent.name); | ||
super.loadIcon(); | ||
Reflect.set(MappableContent.class, this, "name", name); | ||
this.region = parent.region; | ||
} | ||
|
||
@Override | ||
public void onNewPlan(BuildPlan plan) { | ||
plan.block = this.parent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters