Created
November 12, 2018 18:50
-
-
Save Drullkus/69a9d8662c23a726aa1c7e698e7fe11d to your computer and use it in GitHub Desktop.
Item Gallery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Charms", | |
"icon": "twilightforest:charm_of_keeping_3", | |
"category": "treasures", | |
"pages": [ | |
{ | |
"type": "twilightforest:gallery", | |
"item_list": "twilightforest:charm_of_keeping_1|twilightforest:charm_of_keeping_2|twilightforest:charm_of_keeping_3" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"components": [ | |
{ | |
"type": "custom", | |
"class": "twilightforest.compat.patchouli.GalleryComponent", | |
"table_x": 6, | |
"items": "#item_list" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package twilightforest.compat.patchouli; | |
import com.google.gson.annotations.SerializedName; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.item.ItemStack; | |
import twilightforest.TwilightForestMod; | |
import vazkii.patchouli.api.ICustomComponent; | |
import vazkii.patchouli.api.VariableHolder; | |
import vazkii.patchouli.common.util.ItemStackUtil; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
@SuppressWarnings("unused") | |
public class GalleryComponent implements ICustomComponent { | |
int x, y; | |
@SuppressWarnings("WeakerAccess") | |
@SerializedName("table_x") | |
int xCount = 6; | |
@SuppressWarnings("WeakerAccess") | |
@VariableHolder | |
String items; | |
private transient List<ItemStack> stacks; | |
private static final transient Minecraft mc = Minecraft.getMinecraft(); | |
@Override | |
public void build(int x, int y, int pageNum) { | |
TwilightForestMod.LOGGER.info(xCount); | |
TwilightForestMod.LOGGER.info(items); | |
stacks = Arrays.stream(items.split("\\|")).map(ItemStackUtil::loadStackFromString).filter(i -> !i.isEmpty()).collect(Collectors.toList()); | |
if (xCount <= 0 || xCount > 6) | |
xCount = Math.min(stacks.size(), 6); | |
} | |
@Override | |
public void render(float partialTicks) { | |
int listSize = stacks.size(); | |
for (int c = 0; c < listSize; c++) | |
mc.getRenderItem().renderItemAndEffectIntoGUI(stacks.get(c), Math.floorMod(c, xCount), c / xCount); | |
mc.fontRenderer.drawString(items, 0, 0, 0xFFAADD); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment