Merge remote-tracking branch 'origin/1.10-rv3-rendering' into 1.10-rv3-rendering

# Conflicts:
#	src/main/java/appeng/decorative/solid/BlockQuartzGlass.java

#	src/main/resources/assets/appliedenergistics2/blockstates/QuartzGlassBlock.json
# Changed naming convention.
This commit is contained in:
elix-x
2016-08-19 12:49:25 +02:00
57 changed files with 2566 additions and 168 deletions
+22 -5
View File
@@ -23,16 +23,17 @@ import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.client.ClientHelper;
import appeng.core.features.AEFeature;
import appeng.core.features.FeatureNameExtractor;
import appeng.core.features.IAEFeature;
@@ -106,11 +107,27 @@ public abstract class AEBaseItem extends Item implements IAEFeature
super.addInformation( stack, player, lines, displayMoreInfo );
}
@SideOnly( Side.CLIENT )
public void registerCustomIcon( final TextureMap map ){}
protected void getCheckedSubItems( final Item sameItem, final CreativeTabs creativeTab, final List<ItemStack> itemStacks )
{
super.getSubItems( sameItem, creativeTab, itemStacks );
}
/**
* During registration of the item in the registry, this method is used to determine which models need to be registered for the item to be
* rendered. If your item subclass requires more than just the default, override this method and add them to the list, or replace it entirely.
*/
@SideOnly( Side.CLIENT )
public List<ResourceLocation> getItemVariants() {
return Lists.newArrayList( getRegistryName() );
}
/**
* If this item requires special logic to select the model for rendering, this method can be overriden to return that selection logic.
* Return null to use the standard logic.
*/
@SideOnly( Side.CLIENT )
public ItemMeshDefinition getItemMeshDefinition() {
return null;
}
}
@@ -30,10 +30,12 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@@ -46,6 +48,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@@ -61,7 +64,6 @@ import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
import appeng.client.ClientHelper;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.features.IStackSrc;
@@ -143,11 +145,8 @@ public final class ItemMultiItem extends AEBaseItem implements IStorageComponent
public MaterialType getTypeByStack( final ItemStack is )
{
if( this.dmgToMaterial.containsKey( is.getItemDamage() ) )
{
return this.dmgToMaterial.get( is.getItemDamage() );
}
return MaterialType.InvalidType;
MaterialType type = this.dmgToMaterial.get( is.getItemDamage() );
return (type != null) ? type : MaterialType.InvalidType;
}
@Override
@@ -446,4 +445,23 @@ public final class ItemMultiItem extends AEBaseItem implements IStorageComponent
return o1.compareTo( o2 );
}
}
@Override
@SideOnly( Side.CLIENT )
public List<ResourceLocation> getItemVariants()
{
// Register a resource location for every material type
return Arrays.stream( MaterialType.values() )
.map( MaterialType::getModel )
.collect( Collectors.toList() );
}
@Override
@SideOnly( Side.CLIENT )
public ItemMeshDefinition getItemMeshDefinition()
{
return is -> getTypeByStack( is ).getModel();
}
}
@@ -21,13 +21,11 @@ package appeng.items.materials;
import java.util.EnumSet;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
@@ -118,9 +116,7 @@ public enum MaterialType
CardCrafting( 53 );
private final EnumSet<AEFeature> features;
// TextureAtlasSprite for the material.
@SideOnly( Side.CLIENT )
private TextureAtlasSprite IIcon;
private final ModelResourceLocation model = new ModelResourceLocation( "appliedenergistics2:ItemMaterial." + name() );
private Item itemInstance;
private int damageValue;
// stack!
@@ -221,16 +217,6 @@ public enum MaterialType
this.itemInstance = itemInstance;
}
TextureAtlasSprite getIIcon()
{
return this.IIcon;
}
void setIIcon( final TextureAtlasSprite iIcon )
{
this.IIcon = iIcon;
}
MaterialStackSrc getStackSrc()
{
return this.stackSrc;
@@ -241,4 +227,8 @@ public enum MaterialType
this.stackSrc = stackSrc;
}
public ModelResourceLocation getModel() {
return model;
}
}
@@ -21,21 +21,21 @@ package appeng.items.misc;
import java.util.EnumSet;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
@@ -45,7 +45,6 @@ import appeng.api.AEApi;
import appeng.api.definitions.IMaterials;
import appeng.api.implementations.items.IGrowableCrystal;
import appeng.api.recipes.ResolverResult;
import appeng.client.ClientHelper;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.core.localization.ButtonToolTips;
@@ -91,11 +90,11 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
private static ItemStack newStyle( final ItemStack itemStack )
{
( (ItemCrystalSeed) itemStack.getItem() ).getProgress( itemStack );
getProgress( itemStack );
return itemStack;
}
private int getProgress( final ItemStack is )
private static int getProgress( final ItemStack is )
{
if( is.hasTagCompound() )
{
@@ -115,7 +114,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
@Override
public ItemStack triggerGrowth( final ItemStack is )
{
final int newDamage = this.getProgress( is ) + 1;
final int newDamage = getProgress( is ) + 1;
final IMaterials materials = AEApi.instance().definitions().materials();
final int size = is.stackSize;
@@ -166,7 +165,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
public void addCheckedInformation( final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo )
{
lines.add( ButtonToolTips.DoesntDespawn.getLocal() );
final int progress = this.getProgress( stack ) % SINGLE_OFFSET;
final int progress = getProgress( stack ) % SINGLE_OFFSET;
lines.add( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
@@ -181,7 +180,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
@Override
public String getUnlocalizedName( final ItemStack is )
{
final int damage = this.getProgress( is );
final int damage = getProgress( is );
if( damage < CERTUS + SINGLE_OFFSET )
{
@@ -234,12 +233,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
egc.motionY = location.motionY;
egc.motionZ = location.motionZ;
if( location instanceof EntityItem )
{
// TODO: DELAY BEFORE PICKUP
// NEEDS FIXING?!?!
// egc.delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup;
}
// Cannot read the pickup delay of the original item, so we
// use the pickup delay used for items dropped by a player instead
egc.setPickupDelay(40);
return egc;
}
@@ -262,4 +258,73 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
itemStacks.add( newStyle( new ItemStack( this, 1, LEVEL_OFFSET * 2 + NETHER ) ) );
itemStacks.add( newStyle( new ItemStack( this, 1, LEVEL_OFFSET * 2 + FLUIX ) ) );
}
private static final ModelResourceLocation[] MODELS_CERTUS = {
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Certus" ),
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Certus2" ),
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Certus3" )
};
private static final ModelResourceLocation[] MODELS_FLUIX = {
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Fluix" ),
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Fluix2" ),
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Fluix3" )
};
private static final ModelResourceLocation[] MODELS_NETHER = {
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Nether" ),
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Nether2" ),
new ModelResourceLocation( "appliedenergistics2:ItemCrystalSeed.Nether3" )
};
@Override
@SideOnly( Side.CLIENT )
public List<ResourceLocation> getItemVariants()
{
return ImmutableList.<ResourceLocation>builder().add( MODELS_CERTUS ).add( MODELS_FLUIX ).add( MODELS_NETHER ).build();
}
@Override
@SideOnly( Side.CLIENT )
public ItemMeshDefinition getItemMeshDefinition()
{
return is -> {
int damage = getProgress( is );
// Split the damage value into crystal type and growth level
int type = damage / SINGLE_OFFSET;
int level = ( damage % SINGLE_OFFSET ) / LEVEL_OFFSET;
// Determine which list of models to use based on the type of crystal
ModelResourceLocation[] models;
switch( type )
{
case 0:
models = MODELS_CERTUS;
break;
case 1:
models = MODELS_NETHER;
break;
case 2:
models = MODELS_FLUIX;
break;
default:
// We use this as the fallback for broken items
models = MODELS_CERTUS;
break;
}
// Return one of the 3 models based on the level
if( level < 0 )
{
level = 0;
}
else if( level >= models.length )
{
level = models.length - 1;
}
return models[level];
};
}
}
@@ -22,26 +22,21 @@ package appeng.items.misc;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor;
import appeng.client.ClientHelper;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ItemPaintBall extends AEBaseItem
@@ -107,4 +102,44 @@ public class ItemPaintBall extends AEBaseItem
final int dmg = is.getItemDamage();
return dmg >= DAMAGE_THRESHOLD;
}
public static int getColorFromItemstack( ItemStack stack, int tintIndex )
{
final AEColor col = ( (ItemPaintBall) stack.getItem() ).getColor( stack );
final int colorValue = stack.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant;
final int r = ( colorValue >> 16 ) & 0xff;
final int g = ( colorValue >> 8 ) & 0xff;
final int b = ( colorValue ) & 0xff;
if( stack.getItemDamage() >= 20 )
{
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;
}
else
{
return r << 16 | g << 8 | b | 0xff << 24;
}
}
private static final ModelResourceLocation MODEL_NORMAL = new ModelResourceLocation( "appliedenergistics2:ItemPaintBall" );
private static final ModelResourceLocation MODEL_SHIMMER = new ModelResourceLocation( "appliedenergistics2:ItemPaintBallShimmer" );
@Override
public List<ResourceLocation> getItemVariants()
{
return ImmutableList.of(
MODEL_NORMAL,
MODEL_SHIMMER
);
}
@Override
@SideOnly( Side.CLIENT )
public ItemMeshDefinition getItemMeshDefinition()
{
return is -> isLumen( is ) ? MODEL_SHIMMER : MODEL_NORMAL;
}
}