2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-12-19 22:35:45 +01:00
|
|
|
import com.simibubi.create.foundation.item.IAddedByOther;
|
2020-04-13 08:58:57 +02:00
|
|
|
import com.tterrag.registrate.util.RegistryEntry;
|
2019-09-12 10:00:15 +02:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2020-02-03 16:47:58 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.ItemRenderer;
|
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
2020-04-13 08:58:57 +02:00
|
|
|
import net.minecraft.item.Item;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraft.item.ItemGroup;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2020-04-13 08:58:57 +02:00
|
|
|
import net.minecraft.item.Items;
|
2019-09-12 10:00:15 +02:00
|
|
|
import net.minecraft.util.NonNullList;
|
2020-02-03 16:47:58 +01:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-07-11 09:03:08 +02:00
|
|
|
|
|
|
|
public final class CreateItemGroup extends ItemGroup {
|
|
|
|
|
|
|
|
public CreateItemGroup() {
|
|
|
|
super(getGroupCountSafe(), Create.ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack createIcon() {
|
2020-05-04 19:57:16 +02:00
|
|
|
return AllBlocksNew.asStack(AllBlocksNew.COGWHEEL);
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
2019-12-19 22:35:45 +01:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
@Override
|
2020-02-03 16:47:58 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-09-12 10:00:15 +02:00
|
|
|
public void fill(NonNullList<ItemStack> items) {
|
2019-12-19 22:35:45 +01:00
|
|
|
addItems(items, true);
|
|
|
|
addBlocks(items);
|
|
|
|
addItems(items, false);
|
|
|
|
}
|
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-12-19 22:35:45 +01:00
|
|
|
public void addBlocks(NonNullList<ItemStack> items) {
|
2020-04-26 06:58:38 +02:00
|
|
|
for (RegistryEntry<? extends Block> entry : Create.registrate().getAll(Block.class)) {
|
|
|
|
Block def = entry.get();
|
2020-01-05 19:41:38 +01:00
|
|
|
if (def == null)
|
2019-09-12 10:00:15 +02:00
|
|
|
continue;
|
2020-01-05 19:41:38 +01:00
|
|
|
if (def instanceof IAddedByOther)
|
2019-12-19 22:35:45 +01:00
|
|
|
continue;
|
|
|
|
|
2020-04-13 08:58:57 +02:00
|
|
|
Item item = def.asItem();
|
2020-05-02 18:07:46 +02:00
|
|
|
if (item != Items.AIR)
|
2020-04-13 08:58:57 +02:00
|
|
|
item.fillItemGroup(this, items);
|
2019-09-12 10:00:15 +02:00
|
|
|
}
|
|
|
|
}
|
2019-12-19 22:35:45 +01:00
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
|
|
|
|
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
|
|
|
|
2019-12-19 22:35:45 +01:00
|
|
|
for (AllItems item : AllItems.values()) {
|
|
|
|
if (item.get() == null)
|
|
|
|
continue;
|
2020-03-29 06:07:49 +02:00
|
|
|
IBakedModel model = itemRenderer.getItemModelWithOverrides(item.asStack(), Minecraft.getInstance().world, null);
|
2020-02-04 14:48:21 +01:00
|
|
|
if (model.isGui3d() != specialItems)
|
2019-12-19 22:35:45 +01:00
|
|
|
continue;
|
|
|
|
if (item.get() instanceof IAddedByOther)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
item.get().fillItemGroup(this, items);
|
|
|
|
}
|
|
|
|
}
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|