mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-24 06:38:10 +07:00
Fixed bugs with desynced block events
This commit is contained in:
@ -10,6 +10,7 @@ import io.anuke.mindustry.entities.BulletType;
|
|||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.SyncEntity;
|
import io.anuke.mindustry.entities.SyncEntity;
|
||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.io.Platform;
|
import io.anuke.mindustry.io.Platform;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Net.SendMode;
|
import io.anuke.mindustry.net.Net.SendMode;
|
||||||
@ -19,6 +20,7 @@ import io.anuke.mindustry.resource.Item;
|
|||||||
import io.anuke.mindustry.world.Map;
|
import io.anuke.mindustry.world.Map;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.BaseBulletType;
|
import io.anuke.ucore.entities.BaseBulletType;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
@ -273,6 +275,7 @@ public class NetClient extends Module {
|
|||||||
Tile next = tile.getNearby(packet.rotation);
|
Tile next = tile.getNearby(packet.rotation);
|
||||||
tile.entity.items[packet.itemid] --;
|
tile.entity.items[packet.itemid] --;
|
||||||
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
||||||
|
Effects.effect(Fx.transfer, tile.drawx(), tile.drawy(), packet.rotation * 90);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,5 +510,11 @@ public class Fx{
|
|||||||
Draw.text("Respawning in " + (int)((e.lifetime-e.time)/60), e.x, e.y);
|
Draw.text("Respawning in " + (int)((e.lifetime-e.time)/60), e.x, e.y);
|
||||||
Draw.tscl(0.5f);
|
Draw.tscl(0.5f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
}),
|
||||||
|
transfer = new Effect(20, e -> {
|
||||||
|
Draw.color(Color.SCARLET, Color.CLEAR, e.fract());
|
||||||
|
Lines.square(e.x, e.y, 4);
|
||||||
|
Lines.lineAngle(e.x, e.y, e.rotation, 5f);
|
||||||
|
Draw.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,15 @@ public class Net{
|
|||||||
|
|
||||||
/**Connect to an address.*/
|
/**Connect to an address.*/
|
||||||
public static void connect(String ip, int port) throws IOException{
|
public static void connect(String ip, int port) throws IOException{
|
||||||
clientProvider.connect(ip, port);
|
if(!active) {
|
||||||
active = true;
|
clientProvider.connect(ip, port);
|
||||||
server = false;
|
active = true;
|
||||||
|
server = false;
|
||||||
|
|
||||||
Timers.runTask(60f, Platform.instance::updateRPC);
|
Timers.runTask(60f, Platform.instance::updateRPC);
|
||||||
|
}else{
|
||||||
|
throw new IOException("Already connected!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Host a server at an address*/
|
/**Host a server at an address*/
|
||||||
|
@ -2,9 +2,8 @@ package io.anuke.mindustry.ui.fragments;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
|
||||||
import io.anuke.mindustry.entities.enemies.EnemyTypes;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.ucore.scene.builders.button;
|
import io.anuke.ucore.scene.builders.button;
|
||||||
import io.anuke.ucore.scene.builders.label;
|
import io.anuke.ucore.scene.builders.label;
|
||||||
@ -59,7 +58,7 @@ public class DebugFragment implements Fragment {
|
|||||||
netClient.clearRecieved();
|
netClient.clearRecieved();
|
||||||
});
|
});
|
||||||
row();
|
row();
|
||||||
new button("spawn", () -> new Enemy(EnemyTypes.standard).set(player.x, player.y).add());
|
new button("spawn", () -> {try{ Net.connect("localhost", Vars.port); }catch (Exception e){e.printStackTrace();}});
|
||||||
row();
|
row();
|
||||||
new button("stuff", () -> netClient.test());
|
new button("stuff", () -> netClient.test());
|
||||||
row();
|
row();
|
||||||
|
@ -174,7 +174,10 @@ public class Block{
|
|||||||
* Tries to put this item into a nearby container, if there are no available
|
* Tries to put this item into a nearby container, if there are no available
|
||||||
* containers, it gets added to the block's inventory.*/
|
* containers, it gets added to the block's inventory.*/
|
||||||
protected void offloadNear(Tile tile, Item item){
|
protected void offloadNear(Tile tile, Item item){
|
||||||
if(Net.client()) return;
|
if(Net.client()){
|
||||||
|
handleItem(item, tile, tile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
byte i = tile.getDump();
|
byte i = tile.getDump();
|
||||||
byte pdump = (byte)(i % 4);
|
byte pdump = (byte)(i % 4);
|
||||||
|
@ -43,6 +43,8 @@ public class Smelter extends Block{
|
|||||||
final Item item = inputs[i];
|
final Item item = inputs[i];
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.getItem(item)/capacity));
|
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.getItem(item)/capacity));
|
||||||
}
|
}
|
||||||
|
//bars.add(new BlockBar(Color.ORANGE, true, tile -> (float)tile.entity.getItem(fuel)/capacity));
|
||||||
|
//bars.add(new BlockBar(Color.LIGHT_GRAY, true, tile -> (float)tile.entity.getItem(result)/capacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user