2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-12-22 01:31:40 +01:00
|
|
|
import com.simibubi.create.foundation.block.IHaveNoBlockItem;
|
2019-12-19 22:35:45 +01:00
|
|
|
import com.simibubi.create.foundation.item.IAddedByOther;
|
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;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraft.item.ItemGroup;
|
|
|
|
import net.minecraft.item.ItemStack;
|
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() {
|
2019-10-05 19:00:43 +02:00
|
|
|
return new ItemStack(AllBlocks.COGWHEEL.get());
|
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) {
|
2019-09-12 10:00:15 +02:00
|
|
|
for (AllBlocks block : AllBlocks.values()) {
|
2020-01-05 19:41:38 +01:00
|
|
|
Block def = block.get();
|
|
|
|
if (def == null)
|
2019-09-12 10:00:15 +02:00
|
|
|
continue;
|
|
|
|
if (!block.module.isEnabled())
|
|
|
|
continue;
|
2020-01-05 19:41:38 +01:00
|
|
|
if (def instanceof IHaveNoBlockItem && !((IHaveNoBlockItem) def).hasBlockItem())
|
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-01-05 19:41:38 +01:00
|
|
|
def.asItem().fillItemGroup(this, items);
|
2019-09-12 10:00:15 +02:00
|
|
|
for (Block alsoRegistered : block.alsoRegistered)
|
|
|
|
alsoRegistered.asItem().fillItemGroup(this, items);
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
if (!item.module.isEnabled())
|
|
|
|
continue;
|
2020-02-03 16:47:58 +01:00
|
|
|
IBakedModel model = itemRenderer.getModelWithOverrides(item.asStack());
|
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
|
|
|
}
|