use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories-core by Hugobros3.
the class VoxelPane method getVoxelRenderer.
@Override
public VoxelModel getVoxelRenderer(CellData info) {
Voxel vox;
vox = info.getNeightborVoxel(0);
boolean connectLeft = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(1);
boolean connectFront = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(2);
boolean connectRight = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(3);
boolean connectBack = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
String type = "default";
if (connectLeft && connectFront && connectRight && connectBack)
type = "allDir";
else if (connectLeft && connectFront && connectRight)
type = "allButBack";
else if (connectLeft && connectFront && connectBack)
type = "allButRight";
else if (connectLeft && connectBack && connectRight)
type = "allButFront";
else if (connectBack && connectFront && connectRight)
type = "allButLeft";
else if (connectLeft && connectRight)
type = "allX";
else if (connectFront && connectBack)
type = "allZ";
else if (connectLeft && connectBack)
type = "leftBack";
else if (connectRight && connectBack)
type = "rightBack";
else if (connectLeft && connectFront)
type = "leftFront";
else if (connectRight && connectFront)
type = "rightFront";
else if (connectLeft)
type = "left";
else if (connectRight)
type = "right";
else if (connectFront)
type = "front";
else if (connectBack)
type = "back";
else
type = "allDir";
return store.models().getVoxelModel("pane" + "." + type);
}
use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories-core by Hugobros3.
the class VoxelPane method getCollisionBoxes.
@Override
public CollisionBox[] getCollisionBoxes(CellData info) {
// System.out.println("kek");
CollisionBox[] boxes = null;
Voxel vox;
vox = info.getNeightborVoxel(0);
boolean connectLeft = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(1);
boolean connectFront = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(2);
boolean connectRight = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(3);
boolean connectBack = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
if (connectLeft && connectFront && connectRight && connectBack) {
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 1.0), new CollisionBox(0.0, 0.0, 0.45, 1.0, 1, 0.1) };
} else if (connectLeft && connectFront && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.45, 1.0, 1, 0.1), new CollisionBox(0.1, 1, 0.5).translate(0.45, 0, 0.5) };
else if (connectLeft && connectFront && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 1.0), new CollisionBox(0.5, 1, 0.1).translate(0.0, 0, 0.45) };
else if (connectLeft && connectBack && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.45, 1.0, 1, 0.1), new CollisionBox(0.1, 1, 0.5).translate(0.45, 0, 0.0) };
else if (connectBack && connectFront && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 1.0), new CollisionBox(0.5, 1, 0.1).translate(0.5, 0, 0.45) };
else if (connectLeft && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.45, 1.0, 1, 0.1) };
else if (connectFront && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 1.0) };
else if (connectLeft && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.55, 1, 0.1).translate(0.0, 0, 0.45), new CollisionBox(0.1, 1, 0.55).translate(0.45, 0, 0.0) };
else if (connectRight && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.55, 1, 0.1).translate(0.45, 0, 0.45), new CollisionBox(0.1, 1, 0.55).translate(0.45, 0, 0.0) };
else if (connectLeft && connectFront)
boxes = new CollisionBox[] { new CollisionBox(0.55, 1, 0.1).translate(0, 0, 0.45), new CollisionBox(0.1, 1, 0.55).translate(0.45, 0, 0.45) };
else if (connectRight && connectFront)
boxes = new CollisionBox[] { new CollisionBox(0.55, 1, 0.1).translate(0.45, 0, 0.45), new CollisionBox(0.1, 1, 0.55).translate(0.45, 0, 0.45) };
else if (connectLeft)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.45, 0.5, 1, 0.1).translate(0, 0, 0) };
else if (connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.45, 0.5, 1, 0.1).translate(0.5, 0, 0) };
else if (connectFront)
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 0.5).translate(0, 0, 0.5) };
else if (connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 0.5).translate(0, 0, 0.0) };
else
boxes = new CollisionBox[] { new CollisionBox(0.45, 0.0, 0.0, 0.1, 1, 1.0), new CollisionBox(0.0, 0.0, 0.45, 1.0, 1, 0.1) };
return boxes;
}
use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories-core by Hugobros3.
the class VoxelStoneWall method getCollisionBoxes.
@Override
public CollisionBox[] getCollisionBoxes(CellData info) {
// System.out.println("kek");
CollisionBox[] boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.25, 0.5, 1.0, 0.5) };
Voxel vox;
vox = info.getNeightborVoxel(0);
boolean connectLeft = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(1);
boolean connectFront = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(2);
boolean connectRight = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
vox = info.getNeightborVoxel(3);
boolean connectBack = (vox.getDefinition().isSolid() && vox.getDefinition().isOpaque()) || vox.equals(this);
if (connectLeft && connectFront && connectRight && connectBack) {
boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.0, 0.5, 1, 1.0), new CollisionBox(0.0, 0.0, 0.25, 1.0, 1, 0.5) };
} else if (connectLeft && connectFront && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.25, 1.0, 1, 0.5), new CollisionBox(0.25, 0.0, 0.25, 0.5, 1, 0.5).translate(0, 0, 0.25) };
else if (connectLeft && connectFront && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.0, 0.5, 1, 1.0), new CollisionBox(0.25, 0.0, 0.25, 0.5, 1, 0.5).translate(-0.25, 0, 0) };
else if (connectLeft && connectBack && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.25, 1.0, 1, 0.5), new CollisionBox(0.25, 0.0, 0.25, 0.5, 1, 0.5).translate(0, 0, -0.25) };
else if (connectBack && connectFront && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.0, 0.5, 1, 1.0), new CollisionBox(0.25, 0.0, 0.25, 0.5, 1, 0.5).translate(0.25, 0, 0) };
else if (connectLeft && connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.0, 0.0, 0.25, 1.0, 1, 0.5) };
else if (connectFront && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.0, 0.5, 1, 1.0) };
else if (connectLeft && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.125, 0.0, 0.25, 0.75, 1, 0.5).translate(-0.125, 0, 0), new CollisionBox(0.25, 0.0, 0.125, 0.5, 1, 0.75).translate(0, 0, -0.125) };
else if (connectRight && connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.125, 0.0, 0.25, 0.75, 1, 0.5).translate(0.125, 0, 0), new CollisionBox(0.25, 0.0, 0.125, 0.5, 1, 0.75).translate(0, 0, -0.125) };
else if (connectLeft && connectFront)
boxes = new CollisionBox[] { new CollisionBox(0.125, 0.0, 0.25, 0.75, 1, 0.5).translate(-0.125, 0, 0), new CollisionBox(0.25, 0.0, 0.125, 0.5, 1, 0.75).translate(0, 0, 0.125) };
else if (connectRight && connectFront)
boxes = new CollisionBox[] { new CollisionBox(0.125, 0.0, 0.25, 0.75, 1, 0.5).translate(0.125, 0, 0), new CollisionBox(0.25, 0.0, 0.125, 0.5, 1, 0.750).translate(0, 0, 0.125) };
else if (connectLeft)
boxes = new CollisionBox[] { new CollisionBox(0.125, 0.0, 0.25, 0.75, 1, 0.5).translate(-0.125, 0, 0) };
else if (connectRight)
boxes = new CollisionBox[] { new CollisionBox(0.125, 0.0, 0.25, 0.75, 1, 0.5).translate(0.125, 0, 0) };
else if (connectFront)
boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.125, 0.5, 1, 0.75).translate(0, 0, 0.125) };
else if (connectBack)
boxes = new CollisionBox[] { new CollisionBox(0.25, 0.0, 0.125, 0.5, 1, 0.75).translate(0.0, 0.0, -0.125) };
return boxes;
}
use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories by Hugobros3.
the class TaskBuildHeightmap method task.
@Override
protected boolean task(TaskExecutor taskExecutor) {
ConverterWorkerThread cwt = (ConverterWorkerThread) taskExecutor;
// We wait on a bunch of stuff to load everytime
CompoundFence loadRelevantData = new CompoundFence();
HeightmapImplementation summary = csWorld.getRegionsSummariesHolder().aquireHeightmap(cwt, regionX, regionZ);
loadRelevantData.add(summary.waitForLoading());
// Aquires the chunks we want to make the summaries of.
for (int innerCX = 0; innerCX < 8; innerCX++) for (int innerCZ = 0; innerCZ < 8; innerCZ++) for (int chunkY = 0; chunkY < OfflineWorldConverter.mcWorldHeight / 32; chunkY++) {
ChunkHolder holder = csWorld.aquireChunkHolder(cwt, regionX * 8 + innerCX, chunkY, regionZ * 8 + innerCZ);
if (holder != null) {
loadRelevantData.add(holder.waitForLoading());
if (cwt.registeredCS_Holders.add(holder))
cwt.chunksAquired++;
}
}
// Wait until all of that crap loads
loadRelevantData.traverse();
// Descend from top
for (int i = 0; i < 256; i++) for (int j = 0; j < 256; j++) {
for (int h = OfflineWorldConverter.mcWorldHeight; h > 0; h--) {
CellData data = csWorld.peekSafely(regionX * 256 + i, h, regionZ * 256 + j);
if (!data.getVoxel().isAir()) {
Voxel vox = data.getVoxel();
if (vox.getDefinition().isSolid() || vox.getDefinition().isLiquid()) {
summary.setTopCell(data);
break;
}
}
}
}
Fence waitForSummarySave = summary.saveSummary();
// cwt.converter().verbose("Waiting for summary saving...");
waitForSummarySave.traverse();
// cwt.converter().verbose("Done.");
// We don't need the summary anymore
summary.unregisterUser(cwt);
return true;
}
use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories by Hugobros3.
the class GiveCommand method handleCommand.
@Override
public boolean handleCommand(CommandEmitter emitter, Command command, String[] arguments) {
if (!emitter.hasPermission("server.give")) {
emitter.sendMessage("You don't have the permission.");
return true;
}
if (!(emitter instanceof Player)) {
emitter.sendMessage("You need to be a player to use this command.");
return true;
}
Content gameContent = server.getContent();
Player player = (Player) emitter;
if (arguments.length == 0) {
player.sendMessage("#FF969BSyntax : /give <item> [amount] [to]");
return true;
}
int amount = 1;
Player to = player;
String itemName = arguments[0];
// Look for the item first
ItemDefinition type = gameContent.items().getItemDefinition(itemName);
// If the type was found we are simply trying to spawn an item
Item item = null;
if (type != null)
item = type.newItem();
else {
String voxelName = itemName;
int voxelMeta = 0;
if (voxelName.contains(":")) {
voxelMeta = Integer.parseInt(voxelName.split(":")[1]);
voxelName = voxelName.split(":")[0];
}
// Try to find a matching voxel
Voxel voxel = gameContent.voxels().getVoxel(itemName);
if (voxel != null) {
// Spawn new itemPile in his inventory
ItemVoxel itemVoxel = (ItemVoxel) gameContent.items().getItemDefinition("item_voxel").newItem();
itemVoxel.voxel = voxel;
itemVoxel.voxelMeta = voxelMeta;
item = itemVoxel;
}
}
if (item == null) {
player.sendMessage("#FF969BItem or voxel \"" + arguments[0] + " can't be found.");
return true;
}
if (arguments.length >= 2) {
amount = Integer.parseInt(arguments[1]);
}
if (arguments.length >= 3) {
if (gameContent instanceof ServerInterface)
to = ((ServerInterface) gameContent).getPlayerByName(arguments[2]);
else {
player.sendMessage("#FF969BThis is a singleplayer world - there are no other players");
return true;
}
}
if (to == null) {
player.sendMessage("#FF969BPlayer \"" + arguments[2] + " can't be found.");
return true;
}
ItemPile itemPile = new ItemPile(item);
itemPile.setAmount(amount);
((EntityWithInventory) to.getControlledEntity()).getInventory().addItemPile(itemPile);
player.sendMessage("#FF969BGave " + (amount > 1 ? amount + "x " : "") + "#4CFF00" + itemPile.getItem().getName() + " #FF969Bto " + to.getDisplayName());
return true;
}
Aggregations