Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry (For discussion only) #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
*/
package com.flowpowered.api.event.cause;

import com.flowpowered.api.geo.cuboid.Block;
import com.flowpowered.api.material.BaseMaterial;
import com.flowpowered.events.Cause;

import com.flowpowered.api.geo.cuboid.Block;
import com.flowpowered.api.material.Material;
public class MaterialCause<T extends BaseMaterial> extends Cause<T> {

public class MaterialCause<T extends Material> extends Cause<T> {
private final T material;
private final Block block;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
package com.flowpowered.api.generator;

import com.flowpowered.api.geo.World;
import com.flowpowered.api.geo.cuboid.Chunk;
import com.flowpowered.api.material.BlockMaterial;
import com.flowpowered.api.material.BlockBaseMaterial;
import com.flowpowered.api.util.cuboid.CuboidBlockMaterialBuffer;

/**
* Generates an empty world using air blocks
*/
public class EmptyWorldGenerator implements WorldGenerator {

@Override
public void generate(CuboidBlockMaterialBuffer blockData, World world) {
blockData.flood(BlockMaterial.AIR);
blockData.flood(BlockBaseMaterial.AIR);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,33 @@
package com.flowpowered.api.generator;

import com.flowpowered.api.geo.World;
import com.flowpowered.api.material.BlockMaterial;
import com.flowpowered.api.material.BlockBaseMaterial;
import com.flowpowered.api.util.cuboid.CuboidBlockMaterialBuffer;

/**
* Generates a flat world of a material
*/
public class FlatWorldGenerator implements WorldGenerator {
private final BlockMaterial material;

private final BlockBaseMaterial material;

public FlatWorldGenerator() {
material = BlockMaterial.SOLID_BLUE;
material = BlockBaseMaterial.SOLID_BLUE;
}

public FlatWorldGenerator(BlockMaterial material) {
public FlatWorldGenerator(BlockBaseMaterial material) {
this.material = material;
}

@Override
public void generate(CuboidBlockMaterialBuffer blockData, World world) {
int flooredY = blockData.getBase().getFloorY();
int flooredY = blockData.getBase().getFloorY();
if (flooredY < 0) {
blockData.setHorizontalLayer(flooredY, (blockData.getSize().getFloorY() / 2), material);
blockData.setHorizontalLayer(flooredY, (blockData.getSize().getFloorY() / 2), material);
blockData.flood(material);
} else {
blockData.flood(BlockMaterial.AIR);
}
blockData.flood(BlockBaseMaterial.AIR);
}
}

@Override
Expand All @@ -60,5 +61,5 @@ public Populator[] getPopulators() {
@Override
public String getName() {
return "FlatWorld";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
package com.flowpowered.api.generator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.flowpowered.api.geo.World;
import com.flowpowered.api.geo.cuboid.Chunk;
import com.flowpowered.api.material.BlockMaterial;
import com.flowpowered.api.material.BlockBaseMaterial;
import com.flowpowered.api.util.cuboid.CuboidBlockMaterialBuffer;

/**
* A world generator that generates using previously-specified layers of blocks
*/
public class LayeredWorldGenerator implements WorldGenerator {

private List<Layer> layers = new ArrayList<>();
private int minimum = Integer.MAX_VALUE;
private int height = Integer.MIN_VALUE;
Expand Down Expand Up @@ -94,14 +93,14 @@ public List<Layer> getLayers() {
*
* @param material of the layer
*/
protected void setFloorLayer(BlockMaterial material) {
protected void setFloorLayer(BlockBaseMaterial material) {
this.setFloorLayer(material.getId(), material.getData());
}

/**
* Sets the floor layer material, the material for below the lowest layer<br> By default this layer is full of empty material (air)
*
* @param id of the material of the layer
* @param id of the material of the layer
* @param data of the layer
*/
protected void setFloorLayer(short id, short data) {
Expand All @@ -112,19 +111,19 @@ protected void setFloorLayer(short id, short data) {
/**
* Stacks a new layer on top of a previous one<br> At least one layer added using addLayer should be defined before calling this method<br> Otherwise the y-coordinate of this layer will be incorrect
*
* @param height of the new layer
* @param height of the new layer
* @param material of the layer
*/
protected void stackLayer(int height, BlockMaterial material) {
protected void stackLayer(int height, BlockBaseMaterial material) {
this.addLayer(this.height, height, material);
}

/**
* Stacks a new layer on top of a previous one<br> At least one layer added using addLayer should be defined before calling this method<br> Otherwise the y-coordinate of this layer will be incorrect
*
* @param height of the new layer
* @param id of the material of the layer
* @param data of the layer
* @param id of the material of the layer
* @param data of the layer
*/
protected void stackLayer(int height, short id, short data) {
this.addLayer(this.height, height, id, data);
Expand All @@ -133,21 +132,21 @@ protected void stackLayer(int height, short id, short data) {
/**
* Adds a single layer
*
* @param y - coordinate of the start of the layer
* @param height of the layer
* @param y - coordinate of the start of the layer
* @param height of the layer
* @param material of the layer
*/
protected void addLayer(int y, int height, BlockMaterial material) {
protected void addLayer(int y, int height, BlockBaseMaterial material) {
this.addLayer(y, height, material.getId(), material.getData());
}

/**
* Adds a single layer
*
* @param y - coordinate of the start of the layer
* @param y - coordinate of the start of the layer
* @param height of the layer
* @param id of the material of the layer
* @param data of the layer
* @param id of the material of the layer
* @param data of the layer
*/
protected void addLayer(int y, int height, short id, short data) {
final Layer layer = new Layer(y, height, id, data);
Expand All @@ -157,6 +156,7 @@ protected void addLayer(int y, int height, short id, short data) {
}

public static class Layer {

private final short id, data;
private final int y, height, topy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,27 @@
package com.flowpowered.api.generator;

import com.flowpowered.api.geo.World;
import com.flowpowered.api.material.BlockMaterial;
import com.flowpowered.api.material.BlockBaseMaterial;
import com.flowpowered.api.util.cuboid.CuboidBlockMaterialBuffer;

/**
* Generates a solid world of a material
*/
public class SolidWorldGenerator implements WorldGenerator {
private final BlockMaterial material;

private final BlockBaseMaterial material;

public SolidWorldGenerator() {
material = BlockMaterial.SOLID_BLUE;
material = BlockBaseMaterial.SOLID_BLUE;
}

public SolidWorldGenerator(BlockMaterial material) {
public SolidWorldGenerator(BlockBaseMaterial material) {
this.material = material;
}

@Override
public void generate(CuboidBlockMaterialBuffer blockData, World world) {
blockData.flood(material);
blockData.flood(material);
}

@Override
Expand All @@ -54,5 +55,5 @@ public Populator[] getPopulators() {
@Override
public String getName() {
return "SolidWorld";
}
}
}
Loading