Fix CreativeTab ordering and erronous adding to all item groups for some items.
This commit is contained in:
@@ -50,12 +50,12 @@ public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell>
|
||||
{
|
||||
super.fillItemGroup( group, itemStacks );
|
||||
|
||||
final ItemStack charged = new ItemStack( this, 1 );
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble("internalCurrentPower", this.getMaxPower());
|
||||
tag.putDouble("internalMaxPower", this.getMaxPower());
|
||||
|
||||
itemStacks.add( charged );
|
||||
itemStacks.add(charged);
|
||||
}
|
||||
|
||||
public double getMaxPower()
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.AEItemGroup;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -63,7 +64,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
|
||||
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
|
||||
|
||||
private ItemGroup itemGroup = CreativeTab.instance;
|
||||
private ItemGroup itemGroup = CreativeTab.INSTANCE;
|
||||
|
||||
private TileEntityDefinition tileEntityDefinition;
|
||||
|
||||
@@ -190,14 +191,21 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
}
|
||||
}
|
||||
|
||||
T definition;
|
||||
if( block instanceof AEBaseTileBlock )
|
||||
{
|
||||
return (T) new TileDefinition( this.registryName, (AEBaseTileBlock) block, item, features );
|
||||
definition = (T) new TileDefinition( this.registryName, (AEBaseTileBlock<?>) block, item, features );
|
||||
}
|
||||
else
|
||||
{
|
||||
return (T) new BlockDefinition( this.registryName, block, item, features );
|
||||
definition = (T) new BlockDefinition( this.registryName, block, item, features );
|
||||
}
|
||||
|
||||
if (itemGroup instanceof AEItemGroup) {
|
||||
((AEItemGroup) itemGroup).add(definition);
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -28,13 +28,13 @@ import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.core.AEItemGroup;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.dispenser.IDispenseItemBehavior;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.api.features.AEFeature;
|
||||
@@ -64,7 +64,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ItemRendering itemRendering;
|
||||
|
||||
private ItemGroup itemGroup = CreativeTab.instance;
|
||||
private ItemGroup itemGroup = CreativeTab.INSTANCE;
|
||||
|
||||
ItemDefinitionBuilder( FeatureFactory factory, String registryName, Function<Item.Properties, Item> itemFactory )
|
||||
{
|
||||
@@ -167,6 +167,10 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
this.itemRendering.apply( this.factory, item );
|
||||
}
|
||||
|
||||
if (itemGroup instanceof AEItemGroup) {
|
||||
((AEItemGroup) itemGroup).add(definition);
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package appeng.core;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AEItemGroup extends ItemGroup {
|
||||
|
||||
private final List<IItemDefinition> itemDefs = new ArrayList<>();
|
||||
|
||||
public AEItemGroup(String label) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
return blocks.controller().stack(1);
|
||||
}
|
||||
|
||||
public void add(IItemDefinition itemDef) {
|
||||
this.itemDefs.add(itemDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(NonNullList<ItemStack> items) {
|
||||
for (IItemDefinition itemDef : this.itemDefs) {
|
||||
itemDef.item().fillItemGroup(this, items);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,31 +19,13 @@
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
|
||||
|
||||
public final class CreativeTab
|
||||
{
|
||||
public static ItemGroup instance = null;
|
||||
|
||||
static void init()
|
||||
{
|
||||
instance = new ItemGroup( "appliedenergistics2" )
|
||||
{
|
||||
public static AEItemGroup INSTANCE;
|
||||
|
||||
@Override
|
||||
public ItemStack createIcon()
|
||||
{
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
return blocks.controller().stack(1);
|
||||
}
|
||||
|
||||
};
|
||||
public static void init() {
|
||||
INSTANCE = new AEItemGroup( "appliedenergistics2" );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public final class ApiParts implements IParts
|
||||
|
||||
private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id, PartType type, Function<ItemStack, T> factory) {
|
||||
return registry.item(id, props -> new ItemPart<>(props, type, factory))
|
||||
.itemGroup(CreativeTab.instance)
|
||||
.itemGroup(CreativeTab.INSTANCE)
|
||||
.rendering(new ItemPartRendering())
|
||||
.build();
|
||||
}
|
||||
@@ -234,7 +234,7 @@ public final class ApiParts implements IParts
|
||||
String id = color.registryPrefix + '_' + idSuffix;
|
||||
|
||||
IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color))
|
||||
.itemGroup(CreativeTab.instance)
|
||||
.itemGroup(CreativeTab.INSTANCE)
|
||||
.rendering(new ItemPartRendering(color))
|
||||
.build();
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ public class ItemPaintBall extends AEBaseItem
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for( final AEColor c : AEColor.values() )
|
||||
{
|
||||
if( c != AEColor.TRANSPARENT )
|
||||
|
||||
@@ -88,12 +88,14 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
super.fillItemGroup(group, items);
|
||||
|
||||
final ItemStack charged = new ItemStack( this, 1 );
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower( charged ));
|
||||
tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower( charged ));
|
||||
if (this.isInGroup(group)) {
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
|
||||
items.add( charged );
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user