Flattened Paintballs, great recipe migratin.
This commit is contained in:
@@ -114,23 +114,6 @@ public class FeatureFactory
|
||||
return new TileEntityBuilder<>( this, id, teClass, factory ).features( this.defaultFeatures );
|
||||
}
|
||||
|
||||
public AEColoredItemDefinition colored( IItemDefinition target )
|
||||
{
|
||||
ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
|
||||
target.maybeItem().ifPresent( targetItem ->
|
||||
{
|
||||
for( final AEColor color : AEColor.VALID_COLORS )
|
||||
{
|
||||
final ActivityState state = ActivityState.from( true );
|
||||
|
||||
definition.add( color, new ItemStackSrc( targetItem, state ) );
|
||||
}
|
||||
} );
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
public FeatureFactory features( AEFeature... features )
|
||||
{
|
||||
return new FeatureFactory( this, features );
|
||||
|
||||
@@ -96,7 +96,6 @@ import appeng.fluids.registries.BasicFluidCellGuiHandler;
|
||||
import appeng.me.cache.*;
|
||||
import appeng.recipes.conditions.FeaturesEnabled;
|
||||
import appeng.recipes.game.DisassembleRecipe;
|
||||
import appeng.recipes.ingredients.PartIngredientSerializer;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
|
||||
@@ -21,12 +21,16 @@ package appeng.core.api.definitions;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.client.render.crafting.EncodedPatternRenderer;
|
||||
import appeng.client.render.crafting.ItemEncodedPatternRendering;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.ColoredItemDefinition;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.debug.*;
|
||||
import appeng.entity.EntityGrowingCrystal;
|
||||
import appeng.fluids.items.BasicFluidStorageCell;
|
||||
@@ -290,17 +294,8 @@ public final class ApiItems implements IItems
|
||||
.rendering( new ItemEncodedPatternRendering() )
|
||||
.build();
|
||||
|
||||
IItemDefinition paintBall = registry.item( "paint_ball", props -> new ItemPaintBall(props, false) )
|
||||
.features( AEFeature.PAINT_BALLS )
|
||||
.rendering( new ItemPaintBallRendering() )
|
||||
.build();
|
||||
// FIXME these are both wrong
|
||||
this.coloredPaintBall = registry.colored( paintBall );
|
||||
IItemDefinition lumenPaintBall = registry.item( "lumen_paint_ball", props -> new ItemPaintBall(props, true) )
|
||||
.features( AEFeature.PAINT_BALLS )
|
||||
.rendering( new ItemPaintBallRendering() )
|
||||
.build();
|
||||
this.coloredLumenPaintBall = registry.colored( lumenPaintBall );
|
||||
this.coloredPaintBall = createPaintBalls(registry, "_paint_ball", false);
|
||||
this.coloredLumenPaintBall = createPaintBalls(registry, "_lumen_paint_ball", true);
|
||||
|
||||
FeatureFactory debugTools = registry.features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE );
|
||||
this.toolEraser = debugTools.item( "debug_eraser", ToolEraser::new ).build();
|
||||
@@ -312,6 +307,19 @@ public final class ApiItems implements IItems
|
||||
this.dummyFluidItem = registry.item( "dummy_fluid_item", FluidDummyItem::new ).rendering( new FluidDummyItemRendering() ).build();
|
||||
}
|
||||
|
||||
private static AEColoredItemDefinition createPaintBalls(FeatureFactory registry, String idSuffix, boolean lumen) {
|
||||
ColoredItemDefinition colors = new ColoredItemDefinition();
|
||||
for (AEColor color : AEColor.values()) {
|
||||
String id = color.registryPrefix + idSuffix;
|
||||
IItemDefinition paintBall = registry.item(id, props -> new ItemPaintBall(props, color, lumen))
|
||||
.features(AEFeature.PAINT_BALLS)
|
||||
.rendering(new ItemPaintBallRendering(color, lumen))
|
||||
.build();
|
||||
colors.add(color, new ItemStackSrc(paintBall.item(), ActivityState.Enabled));
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzAxe()
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.items.misc;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.items.AEBaseItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -32,12 +33,13 @@ import net.minecraft.util.text.TranslationTextComponent;
|
||||
public class ItemPaintBall extends AEBaseItem
|
||||
{
|
||||
|
||||
private static final String TAG_COLOR = "c";
|
||||
private final AEColor color;
|
||||
|
||||
private final boolean lumen;
|
||||
|
||||
public ItemPaintBall(Properties properties, boolean lumen) {
|
||||
public ItemPaintBall(Properties properties, AEColor color, boolean lumen) {
|
||||
super(properties);
|
||||
this.color = color;
|
||||
this.lumen = lumen;
|
||||
}
|
||||
|
||||
@@ -56,21 +58,11 @@ public class ItemPaintBall extends AEBaseItem
|
||||
|
||||
public AEColor getColor( final ItemStack is )
|
||||
{
|
||||
CompoundNBT tag = is.getTag();
|
||||
if (tag == null || !tag.contains(TAG_COLOR)) {
|
||||
return AEColor.TRANSPARENT;
|
||||
Item item = is.getItem();
|
||||
if (item instanceof ItemPaintBall) {
|
||||
return ((ItemPaintBall) item).color;
|
||||
}
|
||||
int c = tag.getInt(TAG_COLOR);
|
||||
if (c < 0 || c >= AEColor.values().length) {
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
return AEColor.values()[c];
|
||||
}
|
||||
|
||||
public ItemStack setColor( final ItemStack is, AEColor color )
|
||||
{
|
||||
is.getOrCreateTag().putInt(TAG_COLOR, color.ordinal());
|
||||
return is;
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
public boolean isLumen()
|
||||
@@ -78,20 +70,4 @@ public class ItemPaintBall extends AEBaseItem
|
||||
return lumen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for( final AEColor c : AEColor.values() )
|
||||
{
|
||||
if( c != AEColor.TRANSPARENT )
|
||||
{
|
||||
itemStacks.add( setColor(new ItemStack( this ), c) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@ package appeng.items.misc;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
@@ -31,33 +28,36 @@ import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
public class ItemPaintBallRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
|
||||
private final boolean lumen;
|
||||
|
||||
private final AEColor color;
|
||||
|
||||
public ItemPaintBallRendering(AEColor color, boolean lumen) {
|
||||
this.lumen = lumen;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
rendering.color( ItemPaintBallRendering::getColorFromItemstack );
|
||||
// FIXME rendering.meshDefinition( is -> ItemPaintBall.isLumen( is ) ? MODEL_SHIMMER : MODEL_NORMAL );
|
||||
}
|
||||
|
||||
private static int getColorFromItemstack( ItemStack stack, int tintIndex )
|
||||
{
|
||||
ItemPaintBall item = (ItemPaintBall) stack.getItem();
|
||||
final AEColor col = item.getColor( stack );
|
||||
|
||||
boolean lumen = item.isLumen();
|
||||
final int colorValue = lumen ? col.mediumVariant : col.mediumVariant;
|
||||
final int colorValue = lumen ? color.mediumVariant : color.mediumVariant;
|
||||
final int r = ( colorValue >> 16 ) & 0xff;
|
||||
final int g = ( colorValue >> 8 ) & 0xff;
|
||||
final int b = ( colorValue ) & 0xff;
|
||||
|
||||
int renderColor;
|
||||
if( lumen )
|
||||
{
|
||||
final float fail = 0.7f;
|
||||
final int full = (int) ( 255 * 0.3 );
|
||||
return (int) ( full + r * fail ) << 16 | (int) ( full + g * fail ) << 8 | (int) ( full + b * fail ) | 0xff << 24;
|
||||
renderColor = (int) ( full + r * fail ) << 16 | (int) ( full + g * fail ) << 8 | (int) ( full + b * fail ) | 0xff << 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
return r << 16 | g << 8 | b | 0xff << 24;
|
||||
renderColor = r << 16 | g << 8 | b | 0xff << 24;
|
||||
}
|
||||
|
||||
rendering.color( (is, tintIndex) -> renderColor );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user