Added Rotatable Blocks integration.
This commit is contained in:
+34
-22
@@ -48,6 +48,7 @@ import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -158,6 +159,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
|
||||
}
|
||||
|
||||
public IIcon unmappedGetIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return super.getIcon( w, x, y, z, s );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
@@ -169,6 +175,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) );
|
||||
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
|
||||
isInventory = IInventory.class.isAssignableFrom( c );
|
||||
setTileProvider( hasBlockTileEntity() );
|
||||
}
|
||||
|
||||
protected void setfeature(EnumSet<AEFeature> f)
|
||||
@@ -181,6 +188,13 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
setLightOpacity( 15 );
|
||||
setLightLevel( 0 );
|
||||
setHardness( 1.2F );
|
||||
setTileProvider( false );
|
||||
}
|
||||
|
||||
// update Block value.
|
||||
private void setTileProvider(boolean b)
|
||||
{
|
||||
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" );
|
||||
}
|
||||
|
||||
protected AEBaseBlock(Class<?> c, Material mat, String subname) {
|
||||
@@ -231,12 +245,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return tileEntityType != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean hasTileEntity(int metadata)
|
||||
{
|
||||
return hasBlockTileEntity();
|
||||
}
|
||||
|
||||
public Class<? extends TileEntity> getTileEntityClass()
|
||||
{
|
||||
return tileEntityType;
|
||||
@@ -267,14 +275,18 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@Override
|
||||
final public TileEntity createNewTileEntity(World var1, int var2)
|
||||
{
|
||||
try
|
||||
if ( hasBlockTileEntity() )
|
||||
{
|
||||
return tileEntityType.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
try
|
||||
{
|
||||
return tileEntityType.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
|
||||
@@ -294,7 +306,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void customRotateBlock(IOrientable rotateable, ForgeDirection axis)
|
||||
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -302,28 +314,28 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@Override
|
||||
final public boolean rotateBlock(World w, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
IOrientable rotateable = null;
|
||||
IOrientable rotatable = null;
|
||||
|
||||
if ( hasBlockTileEntity() )
|
||||
{
|
||||
rotateable = (AEBaseTile) getTileEntity( w, x, y, z );
|
||||
rotatable = (AEBaseTile) getTileEntity( w, x, y, z );
|
||||
}
|
||||
else if ( this instanceof IOrientableBlock )
|
||||
{
|
||||
rotateable = ((IOrientableBlock) this).getOrientable( w, x, y, z );
|
||||
rotatable = ((IOrientableBlock) this).getOrientable( w, x, y, z );
|
||||
}
|
||||
|
||||
if ( rotateable != null && rotateable.canBeRotated() )
|
||||
if ( rotatable != null && rotatable.canBeRotated() )
|
||||
{
|
||||
if ( hasCustomRotation() )
|
||||
{
|
||||
customRotateBlock( rotateable, axis );
|
||||
customRotateBlock( rotatable, axis );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForgeDirection forward = rotateable.getForward();
|
||||
ForgeDirection up = rotateable.getUp();
|
||||
ForgeDirection forward = rotatable.getForward();
|
||||
ForgeDirection up = rotatable.getUp();
|
||||
|
||||
for (int rs = 0; rs < 4; rs++)
|
||||
{
|
||||
@@ -332,14 +344,14 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
|
||||
if ( this.isValidOrientation( w, x, y, z, forward, up ) )
|
||||
{
|
||||
rotateable.setOrientation( forward, up );
|
||||
rotatable.setOrientation( forward, up );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.rotateBlock( w, x, y, z, axis );
|
||||
}
|
||||
|
||||
public ForgeDirection mapRotation(IOrientable ori, ForgeDirection dir)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class AEDecorativeBlock extends AEBaseBlock
|
||||
{
|
||||
|
||||
protected AEDecorativeBlock(Class<?> c, Material mat) {
|
||||
super( c, mat );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return super.unmappedGetIcon( w, x, y, z, s );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,11 +37,11 @@ public class BlockInterface extends AEBaseBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRotateBlock(IOrientable rotateable, ForgeDirection axis)
|
||||
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
|
||||
{
|
||||
if ( rotateable instanceof TileInterface )
|
||||
if ( rotatable instanceof TileInterface )
|
||||
{
|
||||
((TileInterface) rotateable).setSide( axis );
|
||||
((TileInterface) rotatable).setSide( axis );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,10 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.LocationRotation;
|
||||
|
||||
public class BlockFluix extends AEBaseBlock implements IOrientableBlock
|
||||
public class BlockFluix extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockFluix() {
|
||||
@@ -18,10 +14,4 @@ public class BlockFluix extends AEBaseBlock implements IOrientableBlock
|
||||
setfeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
return new LocationRotation( w, x, y, z );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockQuartz extends AEBaseBlock
|
||||
public class BlockQuartz extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockQuartz() {
|
||||
|
||||
@@ -3,10 +3,10 @@ package appeng.block.solids;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockQuartzChiseled extends AEBaseBlock
|
||||
public class BlockQuartzChiseled extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockQuartzChiseled() {
|
||||
|
||||
@@ -9,23 +9,28 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import rblocks.api.RotatableBlockEnable;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.WorldSettings;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.LocationRotation;
|
||||
import appeng.helpers.NullRotation;
|
||||
import appeng.integration.abstraction.IRB;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@RotatableBlockEnable
|
||||
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
|
||||
@@ -79,8 +84,20 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( "RB" ) )
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( te != null )
|
||||
{
|
||||
IOrientable out = ((IRB) AppEng.instance.getIntegration( "RB" )).getOrientable( te );
|
||||
if ( out != null )
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
if ( w.getBlockMetadata( x, y, z ) == 0 )
|
||||
return new LocationRotation( w, x, y, z );
|
||||
|
||||
return new NullRotation();
|
||||
}
|
||||
|
||||
@@ -145,4 +162,10 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
||||
}
|
||||
|
||||
// use AE2's enderer, no rotatable blocks.
|
||||
int getRealRenderType()
|
||||
{
|
||||
return getRenderType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user