mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-09 05:46:26 +01:00
bf57058e4e
- Set up datagen for basic palette models and blockstates - Overgrown blocks now follow foliage colour - Paved blocks now connect vertically
64 lines
1.7 KiB
Java
64 lines
1.7 KiB
Java
package com.simibubi.create;
|
|
|
|
import java.util.Collection;
|
|
|
|
import com.tterrag.registrate.util.entry.RegistryEntry;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.renderer.ItemRenderer;
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemGroup;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.Items;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
public abstract class CreateItemGroupBase extends ItemGroup {
|
|
|
|
public CreateItemGroupBase(String id) {
|
|
super(getGroupCountSafe(), Create.ID + "." + id);
|
|
}
|
|
|
|
@Override
|
|
@OnlyIn(Dist.CLIENT)
|
|
public void fill(NonNullList<ItemStack> items) {
|
|
addItems(items, true);
|
|
addBlocks(items);
|
|
addItems(items, false);
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public void addBlocks(NonNullList<ItemStack> items) {
|
|
for (RegistryEntry<? extends Block> entry : getBlocks()) {
|
|
Block def = entry.get();
|
|
if (def == null)
|
|
continue;
|
|
Item item = def.asItem();
|
|
if (item != Items.AIR)
|
|
def.fillItemGroup(this, items);
|
|
}
|
|
}
|
|
|
|
protected abstract Collection<RegistryEntry<Block>> getBlocks();
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
|
|
ItemRenderer itemRenderer = Minecraft.getInstance()
|
|
.getItemRenderer();
|
|
|
|
for (AllItems item : AllItems.values()) {
|
|
if (item.get() == null)
|
|
continue;
|
|
IBakedModel model =
|
|
itemRenderer.getItemModelWithOverrides(item.asStack(), Minecraft.getInstance().world, null);
|
|
if (model.isGui3d() != specialItems)
|
|
continue;
|
|
|
|
item.get()
|
|
.fillItemGroup(this, items);
|
|
}
|
|
}
|
|
}
|