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