Flattened Paintballs, great recipe migratin.

This commit is contained in:
Sebastian Hartte
2020-06-10 16:07:20 +02:00
parent 8c45807ecd
commit 1393b4c9dd
382 changed files with 6453 additions and 7261 deletions
@@ -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 );
}
}