Fixes #675 No disabled feature should log spam or crash anymore.
Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
@@ -30,10 +30,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -66,11 +67,21 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
|
||||
|
||||
private double getMaxEnergyCapacity()
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( this );
|
||||
if ( blk == AEApi.instance().blocks().blockEnergyCell.block() )
|
||||
return 200000;
|
||||
else
|
||||
return 8 * 200000;
|
||||
Block blockID = Block.getBlockFromItem( this );
|
||||
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
|
||||
for ( Block block : energyCell.maybeBlock().asSet() )
|
||||
{
|
||||
if ( blockID == block )
|
||||
{
|
||||
return 200000;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 8 * 200000;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private double getInternal(ItemStack is)
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -35,15 +37,38 @@ import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
|
||||
public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
{
|
||||
|
||||
public BlockCraftingMonitor() {
|
||||
public BlockCraftingMonitor()
|
||||
{
|
||||
super( BlockCraftingMonitor.class );
|
||||
|
||||
this.setTileEntity( TileCraftingMonitorTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
if ( direction != ForgeDirection.SOUTH.ordinal() )
|
||||
{
|
||||
for ( Block craftingUnitBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() )
|
||||
{
|
||||
return craftingUnitBlock.getIcon( direction, metadata );
|
||||
}
|
||||
}
|
||||
|
||||
switch ( metadata )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
@@ -51,24 +76,8 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
if ( direction != ForgeDirection.SOUTH.ordinal() )
|
||||
return AEApi.instance().blocks().blockCraftingUnit.block().getIcon( direction, metadata );
|
||||
|
||||
switch (metadata)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
|
||||
{
|
||||
itemStacks.add( new ItemStack( this, 1, 0 ) );
|
||||
}
|
||||
|
||||
@@ -42,7 +42,11 @@ public class ItemCraftingStorage extends AEBaseItemBlock
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
return AEApi.instance().blocks().blockCraftingUnit.stack( 1 );
|
||||
}
|
||||
for ( ItemStack stack : AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
|
||||
if ( tile instanceof TileCharger )
|
||||
{
|
||||
TileCharger tc = (TileCharger) tile;
|
||||
if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( tc.getStackInSlot( 0 ) ) )
|
||||
{
|
||||
|
||||
if ( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getStackInSlot( 0 ) ) )
|
||||
{
|
||||
double xOff = 0.0;
|
||||
double yOff = 0.0;
|
||||
double zOff = 0.0;
|
||||
@@ -112,7 +112,6 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,10 +424,10 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
|
||||
|
||||
public void setupTile()
|
||||
{
|
||||
this.setTileEntity( noTesrTile = Api.INSTANCE.partHelper.getCombinedInstance( TileCableBus.class.getName() ) );
|
||||
this.setTileEntity( noTesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBus.class.getName() ) );
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
tesrTile = Api.INSTANCE.partHelper.getCombinedInstance( TileCableBusTESR.class.getName() );
|
||||
tesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBusTESR.class.getName() );
|
||||
GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" );
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( tesrTile, this );
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,6 +32,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQuartzOre;
|
||||
@@ -37,12 +40,11 @@ import appeng.core.features.AEFeature;
|
||||
|
||||
public class OreQuartz extends AEBaseBlock
|
||||
{
|
||||
private int boostBrightnessLow;
|
||||
private int boostBrightnessHigh;
|
||||
private boolean enhanceBrightness;
|
||||
|
||||
public int boostBrightnessLow;
|
||||
public int boostBrightnessHigh;
|
||||
public boolean enhanceBrightness;
|
||||
|
||||
public OreQuartz(Class self) {
|
||||
public OreQuartz(Class<? extends OreQuartz> self) {
|
||||
super( self, Material.rock );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
this.setHardness( 3.0F );
|
||||
@@ -73,9 +75,13 @@ public class OreQuartz extends AEBaseBlock
|
||||
j1 = Math.max( j1 >> 20, j1 >> 4 );
|
||||
|
||||
if ( j1 > 4 )
|
||||
{
|
||||
j1 += this.boostBrightnessHigh;
|
||||
}
|
||||
else
|
||||
{
|
||||
j1 += this.boostBrightnessLow;
|
||||
}
|
||||
|
||||
if ( j1 > 15 )
|
||||
j1 = 15;
|
||||
@@ -88,21 +94,27 @@ public class OreQuartz extends AEBaseBlock
|
||||
this( OreQuartz.class );
|
||||
}
|
||||
|
||||
ItemStack getItemDropped()
|
||||
{
|
||||
return AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Item getItemDropped(int id, Random rand, int meta)
|
||||
{
|
||||
return this.getItemDropped().getItem();
|
||||
for ( Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
|
||||
{
|
||||
return crystalItem;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int id)
|
||||
{
|
||||
return this.getItemDropped().getItemDamage();
|
||||
for ( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return crystalStack.getItemDamage();
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,4 +156,18 @@ public class OreQuartz extends AEBaseBlock
|
||||
}
|
||||
}
|
||||
|
||||
public void setBoostBrightnessLow( int boostBrightnessLow )
|
||||
{
|
||||
this.boostBrightnessLow = boostBrightnessLow;
|
||||
}
|
||||
|
||||
public void setBoostBrightnessHigh( int boostBrightnessHigh )
|
||||
{
|
||||
this.boostBrightnessHigh = boostBrightnessHigh;
|
||||
}
|
||||
|
||||
public void setEnhanceBrightness( boolean enhanceBrightness )
|
||||
{
|
||||
this.enhanceBrightness = enhanceBrightness;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,17 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.client.render.effects.ChargedOreFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
@@ -37,14 +39,20 @@ public class OreQuartzCharged extends OreQuartz
|
||||
|
||||
public OreQuartzCharged() {
|
||||
super( OreQuartzCharged.class );
|
||||
this.boostBrightnessLow = 2;
|
||||
this.boostBrightnessHigh = 5;
|
||||
this.setBoostBrightnessLow( 2 );
|
||||
this.setBoostBrightnessHigh( 5 );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
ItemStack getItemDropped()
|
||||
public Item getItemDropped( int id, Random rand, int meta )
|
||||
{
|
||||
return AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 );
|
||||
for ( Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() )
|
||||
{
|
||||
return charged;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,15 +21,16 @@ package appeng.block.stair;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.block.solids.BlockQuartzChiseled;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class ChiseledQuartzStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public ChiseledQuartzStairBlock( BlockQuartzChiseled block )
|
||||
public ChiseledQuartzStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ public class FluixStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public FluixStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,16 @@ package appeng.block.stair;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.block.solids.BlockQuartzPillar;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class QuartzPillarStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public QuartzPillarStairBlock( BlockQuartzPillar block )
|
||||
public QuartzPillarStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,16 @@ package appeng.block.stair;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.block.solids.BlockQuartz;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class QuartzStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public QuartzStairBlock( BlockQuartz block )
|
||||
public QuartzStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ public class SkyStoneBlockStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneBlockStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ public class SkyStoneBrickStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneBrickStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,6 @@ public class SkyStoneSmallBrickStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneSmallBrickStairBlock( Block block, int meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,6 @@ public class SkyStoneStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,13 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -81,9 +83,12 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
if ( metadata == 1 )
|
||||
return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, 1 );
|
||||
return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, metadata );
|
||||
for ( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() )
|
||||
{
|
||||
return skyStoneBlock.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
return Blocks.stone.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user