Merge branch 'master' into crater
This commit is contained in:
@@ -904,10 +904,11 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
junction = new Junction("junction"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 1), true);
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 2), true);
|
||||
speed = 26;
|
||||
capacity = 12;
|
||||
health = 30;
|
||||
buildCostMultiplier = 6f;
|
||||
}};
|
||||
|
||||
itemBridge = new BufferedItemBridge("bridge-conveyor"){{
|
||||
@@ -927,16 +928,18 @@ public class Blocks implements ContentList{
|
||||
|
||||
sorter = new Sorter("sorter"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.lead, 2, Items.copper, 2));
|
||||
buildCostMultiplier = 3f;
|
||||
}};
|
||||
|
||||
invertedSorter = new Sorter("inverted-sorter"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.lead, 2, Items.copper, 2));
|
||||
buildCostMultiplier = 3f;
|
||||
invert = true;
|
||||
}};
|
||||
|
||||
router = new Router("router"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 3));
|
||||
|
||||
buildCostMultiplier = 2f;
|
||||
}};
|
||||
|
||||
distributor = new Router("distributor"){{
|
||||
@@ -946,6 +949,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
overflowGate = new OverflowGate("overflow-gate"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.lead, 2, Items.copper, 4));
|
||||
buildCostMultiplier = 3f;
|
||||
}};
|
||||
|
||||
massDriver = new MassDriver("mass-driver"){{
|
||||
|
||||
@@ -321,6 +321,11 @@ public class NetServer implements ApplicationListener{
|
||||
VoteSession[] currentlyKicking = {null};
|
||||
|
||||
clientCommands.<Player>register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> {
|
||||
if(!Config.enableVotekick.bool()){
|
||||
player.sendMessage("[scarlet]Vote-kick is disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(playerGroup.size() < 3){
|
||||
player.sendMessage("[scarlet]At least 3 players are needed to start a votekick.");
|
||||
return;
|
||||
@@ -443,7 +448,7 @@ public class NetServer implements ApplicationListener{
|
||||
if(!player.con.hasDisconnected){
|
||||
if(player.con.hasConnected){
|
||||
Events.fire(new PlayerLeave(player));
|
||||
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
|
||||
if(Config.showConnectMessages.bool()) Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
|
||||
Call.onPlayerDisconnect(player.id);
|
||||
}
|
||||
|
||||
@@ -581,7 +586,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
player.add();
|
||||
player.con.hasConnected = true;
|
||||
Call.sendMessage("[accent]" + player.name + "[accent] has connected.");
|
||||
if(Config.showConnectMessages.bool()) Call.sendMessage("[accent]" + player.name + "[accent] has connected.");
|
||||
Log.info("&lm[{1}] &y{0} has connected. ", player.name, player.uuid);
|
||||
|
||||
Events.fire(new PlayerJoin(player));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
create(item, x, y, to, () -> to.addItem(item));
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void transferItemTo(Item item, int amount, float x, float y, Tile tile){
|
||||
if(tile == null || tile.entity == null || tile.entity.items == null) return;
|
||||
for(int i = 0; i < Mathf.clamp(amount / 3, 1, 8); i++){
|
||||
|
||||
@@ -7,6 +7,7 @@ import arc.math.*;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.Call;
|
||||
import mindustry.graphics.*;
|
||||
@@ -38,11 +39,26 @@ public interface MinerTrait extends Entity{
|
||||
/** Returns whether or not this builder can mine a specific item type. */
|
||||
boolean canMine(Item item);
|
||||
|
||||
/** @return whether to offload mined items immediately at the core. if false, items are collected and dropped in a burst. */
|
||||
default boolean offloadImmediately(){
|
||||
return false;
|
||||
}
|
||||
|
||||
default void updateMining(){
|
||||
Unit unit = (Unit)this;
|
||||
Tile tile = getMineTile();
|
||||
TileEntity core = unit.getClosestCore();
|
||||
|
||||
if(core != null && tile != null && tile.drop() != null && !unit.acceptsItem(tile.drop()) && unit.dst(core) < mineTransferRange){
|
||||
int accepted = core.tile.block().acceptStack(unit.item().item, unit.item().amount, core.tile, unit);
|
||||
if(accepted > 0){
|
||||
Call.transferItemTo(unit.item().item, accepted,
|
||||
tile.worldx() + Mathf.range(tilesize / 2f),
|
||||
tile.worldy() + Mathf.range(tilesize / 2f), core.tile);
|
||||
unit.clearItem();
|
||||
}
|
||||
}
|
||||
|
||||
if(tile == null || core == null || tile.block() != Blocks.air || dst(tile.worldx(), tile.worldy()) > getMiningRange()
|
||||
|| tile.drop() == null || !unit.acceptsItem(tile.drop()) || !canMine(tile.drop())){
|
||||
setMineTile(null);
|
||||
@@ -52,12 +68,13 @@ public interface MinerTrait extends Entity{
|
||||
|
||||
if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * getMinePower())){
|
||||
|
||||
if(unit.dst(core) < mineTransferRange && core.tile.block().acceptStack(item, 1, core.tile, unit) == 1){
|
||||
if(unit.dst(core) < mineTransferRange && core.tile.block().acceptStack(item, 1, core.tile, unit) == 1 && offloadImmediately()){
|
||||
Call.transferItemTo(item, 1,
|
||||
tile.worldx() + Mathf.range(tilesize / 2f),
|
||||
tile.worldy() + Mathf.range(tilesize / 2f), core.tile);
|
||||
}else if(unit.acceptsItem(item)){
|
||||
Call.transferItemToUnit(item,
|
||||
//this is clientside, since items are synced anyway
|
||||
ItemTransfer.transferItemToUnit(item,
|
||||
tile.worldx() + Mathf.range(tilesize / 2f),
|
||||
tile.worldy() + Mathf.range(tilesize / 2f),
|
||||
unit);
|
||||
|
||||
@@ -119,6 +119,11 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offloadImmediately(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeID getTypeID(){
|
||||
return TypeIDs.player;
|
||||
|
||||
@@ -320,6 +320,8 @@ public class Administration{
|
||||
name("The server name as displayed on clients.", "Server", "servername"),
|
||||
port("The port to host on.", Vars.port),
|
||||
autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false),
|
||||
showConnectMessages("Whether to display connect/disconnect messages.", true),
|
||||
enableVotekick("Whether votekick is enabled.", true),
|
||||
startCommands("Commands run at startup. This should be a comma-separated list.", ""),
|
||||
crashReport("Whether to send crash reports.", false, "crashreport"),
|
||||
logging("Whether to log everything to files.", true),
|
||||
|
||||
@@ -376,7 +376,7 @@ public class Tile implements Position, TargetTrait{
|
||||
return state.teams.canInteract(team, getTeam());
|
||||
}
|
||||
|
||||
public Item drop(){
|
||||
public @Nullable Item drop(){
|
||||
return overlay == Blocks.air || overlay.itemDrop == null ? floor.itemDrop : overlay.itemDrop;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ public class BuildBlock extends Block{
|
||||
return;
|
||||
}
|
||||
|
||||
if(entity.previous == null) return;
|
||||
if(entity.previous == null || entity.cblock == null) return;
|
||||
|
||||
if(Core.atlas.isFound(entity.previous.icon(mindustry.ui.Cicon.full))){
|
||||
Draw.rect(entity.previous.icon(Cicon.full), tile.drawx(), tile.drawy(), entity.previous.rotate ? tile.rotation() * 90 : 0);
|
||||
@@ -257,7 +257,7 @@ public class BuildBlock extends Block{
|
||||
if(cblock != null){
|
||||
ItemStack[] requirements = cblock.requirements;
|
||||
if(requirements.length != accumulator.length || totalAccumulator.length != requirements.length){
|
||||
setDeconstruct(previous);
|
||||
setDeconstruct(cblock);
|
||||
}
|
||||
|
||||
//make sure you take into account that you can't deconstruct more than there is deconstructed
|
||||
@@ -342,12 +342,12 @@ public class BuildBlock extends Block{
|
||||
this.progress = 1f;
|
||||
if(previous.buildCost >= 0.01f){
|
||||
this.cblock = previous;
|
||||
this.accumulator = new float[previous.requirements.length];
|
||||
this.totalAccumulator = new float[previous.requirements.length];
|
||||
this.buildCost = previous.buildCost * state.rules.buildCostMultiplier;
|
||||
}else{
|
||||
this.buildCost = 20f; //default no-requirement build cost is 20
|
||||
}
|
||||
this.accumulator = new float[previous.requirements.length];
|
||||
this.totalAccumulator = new float[previous.requirements.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user