diff --git a/client/src/main/resources/textures/items/editor.png b/client/src/main/resources/textures/items/editor.png index 2cb6dd74..6271569e 100755 Binary files a/client/src/main/resources/textures/items/editor.png and b/client/src/main/resources/textures/items/editor.png differ diff --git a/common/src/main/java/common/init/SpeciesRegistry.java b/common/src/main/java/common/init/SpeciesRegistry.java index 68c38edd..67f11b65 100755 --- a/common/src/main/java/common/init/SpeciesRegistry.java +++ b/common/src/main/java/common/init/SpeciesRegistry.java @@ -97,7 +97,7 @@ public abstract class SpeciesRegistry { registerSpecies("Elf", EntityElf.class, "gharoth", "Elbe", 0x054100, 0xd2d2d2, ":highelf", "Thranduil", 0x82888b, 0xeae7bd); registerSpecies("WoodElf", EntityWoodElf.class, "gharoth", "Waldelbe", 0x054100, 0x00bb00); registerSpecies("BloodElf", EntityBloodElf.class, "kyroth", "Blutelbe", 0x054100, 0x960000); - registerSpecies("Human", EntityHuman.class, EntityHuman.ClassType.class, "terra", "NSC", 0x4f7d9a, 0x034c7a, + registerSpecies("Human", EntityHuman.class, EntityHuman.ClassType.class, "terra", "Mensch", 0x4f7d9a, 0x034c7a, EntityHuman.ClassType.KNIGHT, ":knight_1", ":knight_2", ":knight_3", ":knight_4", ":knight_5", ":knight_6", ":knight_7", ":knight_8", EntityHuman.ClassType.PEASANT, diff --git a/server/src/main/java/server/command/CommandEnvironment.java b/server/src/main/java/server/command/CommandEnvironment.java index cb2b63b2..df7cea16 100644 --- a/server/src/main/java/server/command/CommandEnvironment.java +++ b/server/src/main/java/server/command/CommandEnvironment.java @@ -279,5 +279,7 @@ public class CommandEnvironment { this.registerExecutable(new CommandEffect()); this.registerExecutable(new CommandExterminatus()); this.registerExecutable(new CommandReset()); + + this.registerExecutable(new CommandSet()); } } diff --git a/server/src/main/java/server/command/commands/CommandSet.java b/server/src/main/java/server/command/commands/CommandSet.java new file mode 100644 index 00000000..dc239a44 --- /dev/null +++ b/server/src/main/java/server/command/commands/CommandSet.java @@ -0,0 +1,87 @@ +package server.command.commands; + +import java.util.Collection; + +import common.block.Block; +import common.collect.Iterables; +import common.collect.Lists; +import common.init.BlockRegistry; +import common.tags.TagObject; +import common.tileentity.TileEntity; +import common.util.BlockPos.MutableBlockPos; +import common.world.State; +import server.command.Command; +import server.command.CommandEnvironment; +import server.command.Executor; +import server.command.RunException; +import server.command.StringCompleter; +import server.network.Player; +import server.world.WorldServer; + +public class CommandSet extends Command { + public CommandSet() { + super("set"); + + this.setParamsOptional(); + this.addString("block", false, new StringCompleter() { + public Collection complete(CommandEnvironment env, String last) { + int idx = last.indexOf(','); + if(idx >= 0) { + Block block = BlockRegistry.byNameExact(last.substring(0, idx)); + if(block != null) + return Lists.newArrayList(Iterables.transform(block.getSavedStates(), state -> BlockRegistry.getName(state))); + } + return BlockRegistry.getKeys(); + } + }); + this.addTag("tag", 't'); + } + + public Object exec(CommandEnvironment env, Executor exec, String block, TagObject tag) { + if(!exec.isPlayer() || ((Player)exec).getPresentEntity() == null) + throw new RunException("Nur Spieler können diesen Befehl ausführen"); + Player player = (Player)exec; + Iterable blocks = player.getSelectedBlocks(); + if(blocks == null) + throw new RunException("Es ist keine Auswahl vorhanden"); + State state; + if(block == null) { + if(player.getPresentEntity().getHeldItem() == null) + throw new RunException("Es befindet sich kein Gegenstand in der Hand"); + else if(player.getPresentEntity().getHeldItem().getItem().getBlock() == null) + throw new RunException("Der Gegenstand in der Hand ist kein Block"); + state = player.getPresentEntity().getHeldItem().getItem().getBlock().getState(); + } + else { + state = BlockRegistry.byName(block, null); + if(state == null) + throw new RunException("Block '%s' existiert nicht", block); + } + WorldServer world = (WorldServer)player.getPresentEntity().getServerWorld(); + int changed = 0; + for(MutableBlockPos pos : blocks) { + boolean success = world.setState(pos, state); + if(tag != null) { + TileEntity tile = world.getTileEntity(pos); + if(tile != null) { + TagObject te = new TagObject(); + tile.writeTags(te); + te.merge(tag); + TileEntity newTile = TileEntity.createAndLoadEntity(world, world.getChunk(pos), pos, te); + if(newTile != null) { + world.removeTileEntity(pos); + world.setTileEntity(pos, newTile); + success = true; + } + } + } + if(success) + ++changed; + } + if(changed > 0) + exec.log("%d * %s platziert", changed, state.getBlock().getDisplay()); + else + exec.log("Es wurden keine Blöcke verändert"); + return changed; + } +} diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 112b1a0f..dbdf327d 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -106,6 +106,7 @@ import common.tileentity.TileEntity; import common.tileentity.TileEntityDevice; import common.tileentity.TileEntitySign; import common.util.BlockPos; +import common.util.BlockPos.MutableBlockPos; import common.util.BoundingBox; import common.util.ChunkPos; import common.util.ExtMath; @@ -1486,6 +1487,13 @@ public class Player extends User implements Executor, IPlayer return newValue; } + public Iterable getSelectedBlocks() { + if(this.selectionDim == Integer.MIN_VALUE || this.selectionDim != UniverseRegistry.getId(this.entity.worldObj.dimension) || + this.selPos1 == null || this.selPos2 == null) + return null; + return BlockPos.getAllInBoxMutable(this.selPos1, this.selPos2); + } + private boolean copyClipboard() { if(this.selectionDim == Integer.MIN_VALUE || this.selectionDim != UniverseRegistry.getId(this.entity.worldObj.dimension) || this.selPos1 == null || this.selPos2 == null)