Major Refactoring of Bootstrap Code (#75)
- Refactored boostrap code: * Completely reworked item/block/tile registration. * Fixed server side startup. * Fixed server side startup. * More documentation. * More heavy cleanup * More cleanups. * Major refactoring of state mapping and fixes a lot of other issue related to item rendering. * Fixes sky chest item models (no item TESR). * Only use CachingRotatingBakedModel for tile entities automatically. Fix default rotation of quartz pillar for item model. * Used method reference instead of lambda for ItemMeshDefinition for multiparts. * Removed unnecessary IHasSpecialItemModel * Removed unused IconReg class. * Updated resource pack version.
This commit is contained in:
committed by
Sebastian Hartte
parent
66df324ef0
commit
6f2bbfab4c
@@ -19,14 +19,11 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -34,11 +31,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
@@ -66,7 +59,6 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
|
||||
this.setTileEntity( TileEnergyCell.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,48 +83,7 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, ENERGY_STORAGE };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends AEBaseItemBlock> getItemBlockClass()
|
||||
{
|
||||
return AEBaseItemBlockChargeable.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
|
||||
* Returns 0 if the item stack has no fill factor.
|
||||
*/
|
||||
private static double getFillFactor( ItemStack is ) {
|
||||
if( !( is.getItem() instanceof IAEItemPowerStorage ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem();
|
||||
double curPower = itemChargeable.getAECurrentPower( is );
|
||||
double maxPower = itemChargeable.getAEMaxPower( is );
|
||||
|
||||
return curPower / maxPower;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which version of the energy cell model should be used depending on the fill factor
|
||||
* of the item stack.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public ItemMeshDefinition getItemMeshDefinition()
|
||||
{
|
||||
return is -> {
|
||||
double fillFactor = getFillFactor( is );
|
||||
|
||||
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor(fillFactor);
|
||||
|
||||
return new ModelResourceLocation( "appliedenergistics2:tile.BlockEnergyCell", "fullness=" + storageLevel );
|
||||
|
||||
};
|
||||
return new IProperty[] { ENERGY_STORAGE };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user