Skip to content

Commit

Permalink
fixed BaseCover not using textures from CoverFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Dec 11, 2023
1 parent 9ac1844 commit c092238
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void addInfoFromStack(ItemStack stack) {

@Override
public void setTextures(BiConsumer<String, Texture> texer) {
texer.accept("overlay", new Texture(factory.getDomain(), "block/cover/" + getRenderId()));
texer.accept("overlay", factory.getTextures().isEmpty() ? new Texture(factory.getDomain(), "block/cover/" + getRenderId()) : factory.getTextures().get(0));
}

public Texture[] getTextures() {
Expand Down
23 changes: 9 additions & 14 deletions common/src/main/java/muramasa/antimatter/cover/CoverFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter;
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.AntimatterRemapping;
import muramasa.antimatter.Data;
Expand All @@ -18,10 +19,7 @@
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.BiFunction;

public class CoverFactory implements IAntimatterObject {
Expand All @@ -32,7 +30,8 @@ public class CoverFactory implements IAntimatterObject {
private final CoverSupplier supplier;
private Map<Tier, Item> itemStacks = Collections.emptyMap();
private Item itemStack;
private Iterable<Texture> textures;
private List<Texture> textures;
@Getter
private MenuHandler<?> menuHandler = Data.COVER_MENU_HANDLER;

protected boolean gui = false;
Expand All @@ -56,26 +55,22 @@ public Tier getValidTier() {
return itemStacks.size() > 1 ? itemStacks.keySet().iterator().next() : null;
}

public Iterable<Texture> getTextures() {
return textures == null ? Collections::emptyIterator : textures;
public List<Texture> getTextures() {
return textures == null ? Collections.emptyList() : textures;
}

public ItemStack getItem() {
return itemStack == null ? ItemStack.EMPTY : itemStack.getDefaultInstance();
}

public MenuHandler<?> getMenuHandler() {
return menuHandler;
}

void setItems(Map<Tier, Item> stacks) {
this.itemStack = stacks.remove(null);
if (itemStack == null)
itemStack = Items.AIR;
this.itemStacks = ImmutableMap.copyOf(stacks);
}

void addTextures(Iterable<Texture> textures) {
void addTextures(List<Texture> textures) {
this.textures = textures;
}

Expand Down Expand Up @@ -144,7 +139,7 @@ public static class Builder {
final CoverSupplier supplier;
BiFunction<CoverFactory, Tier, Item> itemBuilder;
boolean gui = false;
Iterable<Texture> textures;
List<Texture> textures;
MenuHandler<?> menuHandler;

public Builder(final CoverSupplier supplier) {
Expand All @@ -171,7 +166,7 @@ public Builder setMenuHandler(MenuHandler<?> handler) {
return this;
}

public Builder addTextures(Iterable<Texture> textures) {
public Builder addTextures(List<Texture> textures) {
this.textures = textures;
return this;
}
Expand Down

0 comments on commit c092238

Please sign in to comment.