Skip to content

Commit

Permalink
dont register delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
valoeghese committed Aug 31, 2020
1 parent 9265efa commit c9c67c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/tk/valoeghese/fc0/client/Client2fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private void initGameRendering() {

uvRequests = name -> new Vec2i(Textures.ITEM_ATLAS_OBJ.imageLocationMap.get(name));

for (ItemType item : ItemType.BY_ID) {
for (ItemType item : ItemType.ITEMS) {
if (item != null) {
item.requestUV(uvRequests);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static void loadGeneratedAtlases() {

entries.add("./$break"); // key for tile end, item begin

for (ItemType item : ItemType.BY_ID) {
for (ItemType item : ItemType.ITEMS) {
if (item != null) {
item.requestUV(str -> { // dummy code to collect textures yet once more
entries.add(str);
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/tk/valoeghese/fc0/world/player/ItemType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

import tk.valoeghese.fc0.util.maths.Vec2i;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

public class ItemType {
public ItemType(String textureName, int id) {
this.id = id;
BY_ID[id] = this;

if (id != -1) {
BY_ID[id] = this;
}

ITEMS.add(this);

this.textureName = textureName;
}

Expand Down Expand Up @@ -41,7 +49,9 @@ public String toString() {
return this.translationKey;
}

public static final List<ItemType> ITEMS = new ArrayList<>();
public static final ItemType[] BY_ID = new ItemType[128];
// An ID of negative one symbolises a delegate item.
public static final ItemType TORCH = new ItemType("torch", -1).setName("torch");
public static final ItemType POMELO = new ItemType("pomelo", 0).setName("pomelo");
public static final ItemType TORCH = new ItemType("torch", 1).setName("torch");
}

0 comments on commit c9c67c5

Please sign in to comment.