mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-08-01 23:50:17 +07:00
Made server log stop command, partial teleporter fix
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#Autogenerated file. Do not modify.
|
||||
#Wed Feb 14 17:49:43 EST 2018
|
||||
#Wed Feb 14 23:25:13 EST 2018
|
||||
version=beta
|
||||
androidBuildCode=219
|
||||
androidBuildCode=226
|
||||
name=Mindustry
|
||||
code=3.3
|
||||
build=custom build
|
||||
|
@ -20,7 +20,6 @@ import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.mindustry.world.blocks.types.distribution.Teleporter;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.BaseBulletType;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
@ -281,8 +280,8 @@ public class NetClient extends Module {
|
||||
tile.entity.items[packet.itemid] --;
|
||||
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
||||
|
||||
if(tile.block() instanceof Teleporter)
|
||||
Log.info("Recieved dump for teleporter! items: {0}", tile.entity.totalItems());
|
||||
//if(tile.block() instanceof Teleporter)
|
||||
// Log.info("Recieved dump for teleporter! items: {0}", tile.entity.totalItems());
|
||||
};
|
||||
|
||||
if(threads.isEnabled()){
|
||||
@ -292,11 +291,11 @@ public class NetClient extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
Net.handleClient(ItemAddPacket.class, packet -> {
|
||||
Net.handleClient(ItemSetPacket.class, packet -> {
|
||||
Runnable r = () -> {
|
||||
Tile tile = world.tile(packet.position);
|
||||
if (tile == null || tile.entity == null) return;
|
||||
tile.entity.items[packet.itemid] ++;
|
||||
tile.entity.items[packet.itemid] = packet.amount;
|
||||
};
|
||||
|
||||
if(threads.isEnabled()){
|
||||
|
@ -138,10 +138,11 @@ public class NetEvents {
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
|
||||
public static void handleItemAdd(Tile tile, Item item){
|
||||
ItemAddPacket packet = new ItemAddPacket();
|
||||
public static void handleItemSet(Tile tile, Item item, byte amount){
|
||||
ItemSetPacket packet = new ItemSetPacket();
|
||||
packet.position = tile.packedPosition();
|
||||
packet.itemid = (byte)item.id;
|
||||
packet.amount = amount;
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
|
||||
|
@ -523,20 +523,22 @@ public class Packets {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemAddPacket implements Packet, UnimportantPacket{
|
||||
public static class ItemSetPacket implements Packet, UnimportantPacket{
|
||||
public int position;
|
||||
public byte itemid;
|
||||
public byte itemid, amount;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.putInt(position);
|
||||
buffer.put(itemid);
|
||||
buffer.put(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
position = buffer.getInt();
|
||||
itemid = buffer.get();
|
||||
amount = buffer.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class Registrator {
|
||||
MapAckPacket.class,
|
||||
EntitySpawnPacket.class,
|
||||
ItemTransferPacket.class,
|
||||
ItemAddPacket.class,
|
||||
ItemSetPacket.class,
|
||||
ItemOffloadPacket.class
|
||||
};
|
||||
private static ObjectIntMap<Class<?>> ids = new ObjectIntMap<>();
|
||||
|
@ -2,14 +2,14 @@ package io.anuke.mindustry.world.blocks.types;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Floor extends Block{
|
||||
protected Predicate<Block> blends = block -> block != this;
|
||||
protected boolean blend = true;
|
||||
@ -45,7 +45,7 @@ public class Floor extends Block{
|
||||
int sx = -dx*8+2, sy = -dy*8+2;
|
||||
int x = Mathf.clamp(sx, 0, 12);
|
||||
int y = Mathf.clamp(sy, 0, 12);
|
||||
int w = Mathf.clamp(sx+8, 0, 12)-x, h = Mathf.clamp(sy+8, 0, 12)-y;
|
||||
int w = Mathf.clamp(sx+8, 0, 12) - x, h = Mathf.clamp(sy+8, 0, 12) - y;
|
||||
|
||||
float rx = Mathf.clamp(dx*8, 0, 8-w);
|
||||
float ry = Mathf.clamp(dy*8, 0, 8-h);
|
||||
|
@ -142,7 +142,7 @@ public class Teleporter extends PowerBlock{
|
||||
Tile target = links.random();
|
||||
target.entity.addItem(item, 1);
|
||||
|
||||
if(Net.server()) NetEvents.handleItemAdd(target, item);
|
||||
if(Net.server()) NetEvents.handleItemSet(target, item, (byte)1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ public class Teleporter extends PowerBlock{
|
||||
}
|
||||
|
||||
for(Tile remove : removal)
|
||||
teleporters[entity.color].remove(remove);
|
||||
teleporters[entity.color].remove(remove);
|
||||
|
||||
return returns;
|
||||
}
|
||||
|
Reference in New Issue
Block a user