Flattening part 1

This commit is contained in:
Sebastian Hartte
2020-06-05 22:47:29 +02:00
parent c411a800f6
commit bb453b0d35
43 changed files with 492 additions and 594 deletions
@@ -19,19 +19,6 @@
package appeng.block;
import java.text.MessageFormat;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
@@ -39,6 +26,19 @@ import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.text.MessageFormat;
import java.util.List;
public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage
@@ -46,6 +46,13 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
public AEBaseBlockItemChargeable(Block id, Properties props) {
super(id, props);
addPropertyOverride(new ResourceLocation("appliedenergistics2:fill_level"), (is, world, entity) -> {
double curPower = getAECurrentPower(is);
double maxPower = getAEMaxPower(is);
return (int) Math.round(100 * curPower / maxPower);
});
}
@Override
@@ -153,4 +160,5 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
final CompoundNBT nbt = is.getOrCreateTag();
nbt.putDouble("internalCurrentPower", amt);
}
}
@@ -29,6 +29,7 @@ import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
// FIXME REMOVE
public class BlockEnergyCellRendering extends BlockRenderingCustomizer
{
@@ -42,37 +43,6 @@ public class BlockEnergyCellRendering extends BlockRenderingCustomizer
@Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
// FIXME itemRendering.meshDefinition( this::getItemModel );
// Note: Since we use the block models, we dont need to register custom variants
}
/**
* Determines which version of the energy cell model should be used depending on the fill factor
* of the item stack.
*/
// FIXME private ModelResourceLocation getItemModel( ItemStack is )
// FIXME {
// FIXME double fillFactor = getFillFactor( is );
// FIXME
// FIXME int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor( fillFactor );
// FIXME return new ModelResourceLocation( this.baseModel, "fullness=" + storageLevel );
// FIXME }
/**
* 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;
}
AEBaseBlockItemChargeable itemChargeable = (AEBaseBlockItemChargeable) is.getItem();
double curPower = itemChargeable.getAECurrentPower( is );
double maxPower = itemChargeable.getAEMaxPower( is );
return curPower / maxPower;
}
}