Moved F2R, added TESRs, fixed culling

-Externalized FacingToRotation.
-BlockLightDetector now uses tile based rotations.
-Added TESR methods and TESRs for chests. Can't get it to work in
inventory.
-Fixed rotation bugs involving culling and lighting. Now rotating culled
faces and normals too. Closes #21.
Relates to #9, #10 and #20.
This commit is contained in:
elix-x
2016-07-11 15:38:54 +02:00
parent d64a63992c
commit 524dc52dd6
12 changed files with 415 additions and 134 deletions
+25 -17
View File
@@ -34,8 +34,8 @@ import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@@ -49,10 +49,8 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
@@ -86,29 +84,40 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
{
super( mat, subName );
}
public static final PropertyDirection AE_BLOCK_FORWARD = PropertyDirection.create( "forward" );
public static final PropertyDirection AE_BLOCK_UP = PropertyDirection.create( "up" );
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP };
}
@Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
{
AEBaseTile tile = (AEBaseTile) world.getTileEntity( pos );
return super.getActualState( state, world, pos ).withProperty( AE_BLOCK_FORWARD, tile.getForward()).withProperty( AE_BLOCK_UP, tile.getUp() );
return super.getActualState( state, world, pos ).withProperty( AE_BLOCK_FORWARD, tile.getForward() ).withProperty( AE_BLOCK_UP, tile.getUp() );
}
@Override
public int getMetaFromState( IBlockState state )
{
return 0;
}
@SideOnly( Side.CLIENT )
public TileEntitySpecialRenderer<? extends AEBaseTile> getTESR()
{
return null;
}
public boolean hasItemTESR()
{
return false;
}
@Override
protected void setFeature( final EnumSet<AEFeature> f )
{
@@ -120,13 +129,12 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
{
this.tileEntityType = c;
this.setInventory( IInventory.class.isAssignableFrom( c ) );
this.setTileProvider( this.hasBlockTileEntity() );
}
// update Block value.
private void setTileProvider( final boolean b )
@Override
public boolean hasTileEntity( IBlockState state )
{
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" );
return hasBlockTileEntity();
}
private boolean hasBlockTileEntity()
@@ -134,7 +142,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
return this.tileEntityType != null;
}
public Class<? extends TileEntity> getTileEntityClass()
public Class<? extends AEBaseTile> getTileEntityClass()
{
return this.tileEntityType;
}
@@ -283,7 +291,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
{
if( Platform.isWrench( player, heldItem, pos ) && player.isSneaking() )
{
final IBlockState ids = w.getBlockState( pos );
final IBlockState ids = w.getBlockState( pos );
final Block id = ids.getBlock();
if( id != null )
{
@@ -60,23 +60,10 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
this.setFeature( EnumSet.of( AEFeature.LightDetector ) );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return 0;
}
@Override
public IBlockState getStateFromMeta( final int meta )
{
return this.getDefaultState();
}
@Override
protected IProperty[] getAEStates()
{
//TODO 1.10-R - wtf?
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, BlockTorch.FACING };
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP };
}
@Override
@@ -173,12 +160,7 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
@Override
public boolean usesMetadata()
{
return true;
return false;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
return new MetaRotation( w, pos, true );
}
}
@@ -28,17 +28,23 @@ import javax.annotation.Nullable;
import com.google.common.base.Optional;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.tesr.SkyChestTESR;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.helpers.ICustomCollision;
@@ -69,6 +75,25 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
}
@Override
public EnumBlockRenderType getRenderType( IBlockState state )
{
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
}
@Override
@SideOnly( Side.CLIENT )
public TileEntitySpecialRenderer<TileSkyChest> getTESR()
{
return new SkyChestTESR();
}
@Override
public boolean hasItemTESR()
{
return true;
}
@Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{