Skip to content

Commit

Permalink
fix biome widget
Browse files Browse the repository at this point in the history
  • Loading branch information
valoeghese committed May 25, 2020
1 parent 4d57ff5 commit 7d4507b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/main/java/tk/valoeghese/fc0/client/Client2fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ public void saveWorld() {

public void createWorld() {
this.saveWorld();
this.time = 0;
this.save = new Save("save", new Random().nextLong());
this.world = new ClientChunkSelection(this.save, this.save.getSeed(), 9);
this.time = 0;

if (this.save.spawnLocPos != null) {
this.spawnLoc = this.save.spawnLocPos;
} else {
Expand Down Expand Up @@ -145,7 +146,9 @@ private void tick() {

if (!this.titleScreen && zone != this.player.cachedZone) {
this.player.cachedZone = zone;
this.biomeWidget.changeText(this.language.translate(zone.toString()));
String newValue = this.language.translate(zone.toString());
System.out.println(newValue);
this.biomeWidget.changeText(newValue);
}

++this.time;
Expand All @@ -166,7 +169,7 @@ private void init() {
this.titleText = new Text("Click to start.", -0.85f, 0.5f, 2.2f);
this.world.populateChunks();
this.player.getCamera().rotateYaw((float) Math.PI);
this.biomeWidget = new Text("ecozone.placeholder", -0.85f, 0.5f, 1.0f);
this.biomeWidget = new Text(this.language.translate("ecozone.temperate_grassland"), -0.85f, 0.8f, 1.0f);
}

private void handleKeybinds() {
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/tk/valoeghese/fc0/client/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected GUI(int texture) {
private FloatList vTemp = new FloatArrayList();
private int vTempIndex = 0;
private IntList iTemp = new IntArrayList();
private List<VertexArray> vertexArrays = new ArrayList<>();
protected List<VertexArray> vertexArrays = new ArrayList<>();
private final int mode;
private final Shader shader;
private final int texture;
Expand All @@ -50,7 +50,8 @@ public void destroy() {
glDeleteVertexArrays(array.vao);
}

this.vertexArrays = new ArrayList<>();
this.vertexArrays.clear();
this.vTempIndex = 0;
}

protected void generateBuffers() {
Expand Down Expand Up @@ -88,8 +89,8 @@ public final void render() {
glDrawElements(GL_TRIANGLES, array.elementCount, GL_UNSIGNED_INT, NULL);
}

glBindTexture(GL_TEXTURE_2D, 0);
unbind();
glBindTexture(GL_TEXTURE_2D, 0);
}

public Shader getShader() {
Expand All @@ -100,13 +101,18 @@ public static final void unbind() {
glBindVertexArray(0);
}

private static class VertexArray {
protected static class VertexArray {
private VertexArray(int vao, int elementCount) {
this.vao = vao;
this.elementCount = elementCount;
}

private final int vao;
private final int elementCount;

@Override
public String toString() {
return "{vao: " + this.vao + ", elementCount: " + this.elementCount + "}";
}
}
}
1 change: 1 addition & 0 deletions src/main/java/tk/valoeghese/fc0/world/ChunkSelection.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

public abstract class ChunkSelection<T extends Chunk> implements World, ChunkAccess {
public ChunkSelection(@Nullable Save save, long seed, int size, WorldGen.ChunkConstructor<T> constructor, IntFunction<T[]> arraySupplier) {
WorldGen.updateSeed(seed);
this.seed = seed;
this.offset = size - 1;
this.diameter = 1 + this.offset * 2;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/tk/valoeghese/fc0/world/gen/WorldGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
import java.util.Random;

public final class WorldGen {
public static <T extends Chunk> T generateChunk(ChunkConstructor<T> constructor, ChunkAccess parent, int chunkX, int chunkZ, long seed, Random rand) {
public static void updateSeed(long seed) {
if (noise == null || seed != cachedSeed) {
noise = new Noise(new Random(seed));
ridges = new RidgedNoise(new Random(seed + 12));
sand = new Noise(new Random(seed - 29));
ecoZone = new Noise(new Random(seed + 31));
}
}

public static <T extends Chunk> T generateChunk(ChunkConstructor<T> constructor, ChunkAccess parent, int chunkX, int chunkZ, long seed, Random rand) {
byte[] tiles = new byte[16 * 16 * World.WORLD_HEIGHT];
byte[] meta = new byte[tiles.length];

Expand Down
Binary file modified src/main/resources/assets/texture/font_atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7d4507b

Please sign in to comment.