reformatted all src files (#141)
This commit is contained in:
@@ -19,12 +19,29 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.integration.abstraction.IAEFacade;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.CableBusTESR;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
@@ -61,439 +78,354 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.UnlistedProperty;
|
||||
import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.integration.abstraction.IAEFacade;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.CableBusTESR;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockCableBus extends AEBaseTileBlock implements IAEFacade
|
||||
{
|
||||
|
||||
public static final UnlistedProperty<CableBusRenderState> RENDER_STATE_PROPERTY = new UnlistedProperty<>( "cable_bus_render_state", CableBusRenderState.class );
|
||||
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
|
||||
private static Class<? extends AEBaseTile> noTesrTile;
|
||||
|
||||
private static Class<? extends AEBaseTile> tesrTile;
|
||||
|
||||
public BlockCableBus()
|
||||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
this.setLightOpacity( 0 );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
|
||||
// this will actually be overwritten later through setupTile and the
|
||||
// combined layers
|
||||
this.setTileEntity( TileCableBus.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, new IProperty[0], new IUnlistedProperty[] { RENDER_STATE_PROPERTY } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
CableBusRenderState renderState = this.cb( world, pos ).getRenderState();
|
||||
renderState.setWorld( world );
|
||||
renderState.setPos( pos );
|
||||
return ( (IExtendedBlockState) state ).withProperty( RENDER_STATE_PROPERTY, renderState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( final IBlockState state, final World worldIn, final BlockPos pos, final Random rand )
|
||||
{
|
||||
this.cb( worldIn, pos ).randomDisplayTick( worldIn, pos, rand );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange( final IBlockAccess w, final BlockPos pos, final BlockPos neighbor )
|
||||
{
|
||||
this.cb( w, pos ).onNeighborChanged( w, pos, neighbor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side )
|
||||
{
|
||||
return this.cb( w, pos ).isProvidingWeakPower( side.getOpposite() ); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower( final IBlockState state )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock( final World w, final BlockPos pos, final IBlockState state, final Entity entityIn )
|
||||
{
|
||||
this.cb( w, pos ).onEntityCollision( entityIn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side )
|
||||
{
|
||||
return this.cb( w, pos ).isProvidingStrongPower( side.getOpposite() ); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue( final IBlockState state, final IBlockAccess world, final BlockPos pos )
|
||||
{
|
||||
if( state.getBlock() != this )
|
||||
{
|
||||
return state.getBlock().getLightValue( state, world, pos );
|
||||
}
|
||||
return this.cb( world, pos ).getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder( final IBlockState state, final IBlockAccess world, final BlockPos pos, final EntityLivingBase entity )
|
||||
{
|
||||
return this.cb( world, pos ).isLadder( entity );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side )
|
||||
{
|
||||
return this.cb( w, pos ).isSolidOnSide( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable( final IBlockAccess w, final BlockPos pos )
|
||||
{
|
||||
return this.cb( w, pos ).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer( final IBlockState state, final World world, final BlockPos pos, final EntityPlayer player, final boolean willHarvest )
|
||||
{
|
||||
if( player.capabilities.isCreativeMode )
|
||||
{
|
||||
final AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
tile.disableDrops();
|
||||
}
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removedByPlayer( state, world, pos, player, willHarvest );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone( final IBlockState state, final IBlockAccess w, final BlockPos pos, EnumFacing side )
|
||||
{
|
||||
if( side == null )
|
||||
{
|
||||
side = EnumFacing.UP;
|
||||
}
|
||||
|
||||
return this.cb( w, pos ).canConnectRedstone( EnumSet.of( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock( final IBlockState state, final RayTraceResult target, final World world, final BlockPos pos, final EntityPlayer player )
|
||||
{
|
||||
final Vec3d v3 = target.hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() );
|
||||
final SelectedPart sp = this.cb( world, pos ).selectPart( v3 );
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
return sp.part.getItemStack( PartItemStack.PICK );
|
||||
}
|
||||
else if( sp.facade != null )
|
||||
{
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean addHitEffects( final IBlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer )
|
||||
{
|
||||
|
||||
// Half the particle rate. Since we're spawning concentrated on a specific spot,
|
||||
// our particle effect otherwise looks too strong
|
||||
if( Platform.getRandom().nextBoolean() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
ICableBusContainer cb = this.cb( world, target.getBlockPos() );
|
||||
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState( this.getDefaultState() );
|
||||
|
||||
// We cannot add the effect if we don't have the model
|
||||
if( !( model instanceof CableBusBakedModel ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
|
||||
// Spawn a particle for one of the particle textures
|
||||
TextureAtlasSprite texture = Platform.pickRandom( cableBusModel.getParticleTextures( renderState ) );
|
||||
if( texture != null )
|
||||
{
|
||||
double x = target.hitVec.x;
|
||||
double y = target.hitVec.y;
|
||||
double z = target.hitVec.z;
|
||||
|
||||
Particle fx = new DestroyFX( world, x, y, z, 0.0D, 0.0D, 0.0D, state ).setBlockPos( target.getBlockPos() ).multipleParticleScaleBy( 0.8F );
|
||||
fx.setParticleTexture( texture );
|
||||
effectRenderer.addEffect( fx );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean addDestroyEffects( final World world, final BlockPos pos, final ParticleManager effectRenderer )
|
||||
{
|
||||
ICableBusContainer cb = this.cb( world, pos );
|
||||
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState( this.getDefaultState() );
|
||||
|
||||
// We cannot add the effect if we dont have the model
|
||||
if( !( model instanceof CableBusBakedModel ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
|
||||
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures( renderState );
|
||||
|
||||
if( !textures.isEmpty() )
|
||||
{
|
||||
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
|
||||
for( int j = 0; j < 4; ++j )
|
||||
{
|
||||
for( int k = 0; k < 4; ++k )
|
||||
{
|
||||
for( int l = 0; l < 4; ++l )
|
||||
{
|
||||
// Randomly select one of the textures if the cable bus has more than just one possibility here
|
||||
final TextureAtlasSprite texture = Platform.pickRandom( textures );
|
||||
|
||||
final double d0 = pos.getX() + ( j + 0.5D ) / 4.0D;
|
||||
final double d1 = pos.getY() + ( k + 0.5D ) / 4.0D;
|
||||
final double d2 = pos.getZ() + ( l + 0.5D ) / 4.0D;
|
||||
final ParticleDigging particle = new DestroyFX( world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos
|
||||
.getY() - 0.5D, d2 - pos.getZ() - 0.5D, this.getDefaultState() ).setBlockPos( pos );
|
||||
|
||||
particle.setParticleTexture( texture );
|
||||
effectRenderer.addEffect( particle );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.cb( world, pos ).onNeighborChanged( world, pos, fromPos );
|
||||
}
|
||||
}
|
||||
|
||||
private ICableBusContainer cb( final IBlockAccess w, final BlockPos pos )
|
||||
{
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
ICableBusContainer out = null;
|
||||
|
||||
if( te instanceof TileCableBus )
|
||||
{
|
||||
out = ( (TileCableBus) te ).getCableBus();
|
||||
}
|
||||
|
||||
return out == null ? NULL_CABLE_BUS : out;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IFacadeContainer fc( final IBlockAccess w, final BlockPos pos )
|
||||
{
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
IFacadeContainer out = null;
|
||||
|
||||
if( te instanceof TileCableBus )
|
||||
{
|
||||
out = ( (TileCableBus) te ).getCableBus().getFacadeContainer();
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked( World worldIn, BlockPos pos, EntityPlayer playerIn )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
|
||||
if( rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals( rtr.getBlockPos() ) )
|
||||
{
|
||||
final Vec3d hitVec = rtr.hitVec.subtract( new Vec3d( pos ) );
|
||||
|
||||
if( this.cb( worldIn, pos ).clicked( playerIn, EnumHand.MAIN_HAND, hitVec ) )
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketClick( pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockClickPacket( World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec )
|
||||
{
|
||||
this.cb( worldIn, pos ).clicked( playerIn, hand, hitVec );
|
||||
}
|
||||
|
||||
@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 )
|
||||
{
|
||||
return this.cb( w, pos ).activate( player, hand, new Vec3d( hitX, hitY, hitZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolorBlock( final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color )
|
||||
{
|
||||
return this.recolorBlock( world, pos, side, color, null );
|
||||
}
|
||||
|
||||
public boolean recolorBlock( final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color, final EntityPlayer who )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.cb( world, pos ).recolourBlock( side, AEColor.values()[color.ordinal()], who );
|
||||
}
|
||||
catch( final Throwable ignored )
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks )
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void setupTile()
|
||||
{
|
||||
noTesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBus.class );
|
||||
this.setTileEntity( noTesrTile );
|
||||
|
||||
GameRegistry.registerTileEntity( noTesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "BlockCableBus" );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
setupTesr();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private static void setupTesr()
|
||||
{
|
||||
tesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBusTESR.class );
|
||||
GameRegistry.registerTileEntity( tesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "ClientOnly_TESR_CableBus" );
|
||||
ClientRegistry.bindTileEntitySpecialRenderer( BlockCableBus.getTesrTile(), new CableBusTESR() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer( IBlockState state, BlockRenderLayer layer )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getFacadeState( IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
if( side != null )
|
||||
{
|
||||
IFacadeContainer container = this.fc( world, pos );
|
||||
if( container != null )
|
||||
{
|
||||
IFacadePart facade = container.getFacade( AEPartLocation.fromFacing( side ) );
|
||||
if( facade != null )
|
||||
{
|
||||
return facade.getBlockState();
|
||||
}
|
||||
}
|
||||
}
|
||||
return world.getBlockState( pos );
|
||||
}
|
||||
|
||||
public static Class<? extends AEBaseTile> getNoTesrTile()
|
||||
{
|
||||
return noTesrTile;
|
||||
}
|
||||
|
||||
public static Class<? extends AEBaseTile> getTesrTile()
|
||||
{
|
||||
return tesrTile;
|
||||
}
|
||||
|
||||
// Helper to get access to the protected constructor
|
||||
@SideOnly( Side.CLIENT )
|
||||
private static class DestroyFX extends ParticleDigging
|
||||
{
|
||||
DestroyFX( World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, IBlockState state )
|
||||
{
|
||||
super( worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state );
|
||||
}
|
||||
}
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class BlockCableBus extends AEBaseTileBlock implements IAEFacade {
|
||||
|
||||
public static final UnlistedProperty<CableBusRenderState> RENDER_STATE_PROPERTY = new UnlistedProperty<>("cable_bus_render_state", CableBusRenderState.class);
|
||||
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
|
||||
private static Class<? extends AEBaseTile> noTesrTile;
|
||||
|
||||
private static Class<? extends AEBaseTile> tesrTile;
|
||||
|
||||
public BlockCableBus() {
|
||||
super(AEGlassMaterial.INSTANCE);
|
||||
this.setLightOpacity(0);
|
||||
this.setFullSize(false);
|
||||
this.setOpaque(false);
|
||||
|
||||
// this will actually be overwritten later through setupTile and the
|
||||
// combined layers
|
||||
this.setTileEntity(TileCableBus.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{RENDER_STATE_PROPERTY});
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
CableBusRenderState renderState = this.cb(world, pos).getRenderState();
|
||||
renderState.setWorld(world);
|
||||
renderState.setPos(pos);
|
||||
return ((IExtendedBlockState) state).withProperty(RENDER_STATE_PROPERTY, renderState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(final IBlockState state, final World worldIn, final BlockPos pos, final Random rand) {
|
||||
this.cb(worldIn, pos).randomDisplayTick(worldIn, pos, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(final IBlockAccess w, final BlockPos pos, final BlockPos neighbor) {
|
||||
this.cb(w, pos).onNeighborChanged(w, pos, neighbor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(final IBlockState state, final Random rand, final int fortune) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakPower(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
|
||||
return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower(final IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(final World w, final BlockPos pos, final IBlockState state, final Entity entityIn) {
|
||||
this.cb(w, pos).onEntityCollision(entityIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongPower(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
|
||||
return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(final IBlockState state, final IBlockAccess world, final BlockPos pos) {
|
||||
if (state.getBlock() != this) {
|
||||
return state.getBlock().getLightValue(state, world, pos);
|
||||
}
|
||||
return this.cb(world, pos).getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EntityLivingBase entity) {
|
||||
return this.cb(world, pos).isLadder(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
|
||||
return this.cb(w, pos).isSolidOnSide(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(final IBlockAccess w, final BlockPos pos) {
|
||||
return this.cb(w, pos).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(final IBlockState state, final World world, final BlockPos pos, final EntityPlayer player, final boolean willHarvest) {
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
final AEBaseTile tile = this.getTileEntity(world, pos);
|
||||
if (tile != null) {
|
||||
tile.disableDrops();
|
||||
}
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removedByPlayer(state, world, pos, player, willHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(final IBlockState state, final IBlockAccess w, final BlockPos pos, EnumFacing side) {
|
||||
if (side == null) {
|
||||
side = EnumFacing.UP;
|
||||
}
|
||||
|
||||
return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(final IBlockState state, final RayTraceResult target, final World world, final BlockPos pos, final EntityPlayer player) {
|
||||
final Vec3d v3 = target.hitVec.subtract(pos.getX(), pos.getY(), pos.getZ());
|
||||
final SelectedPart sp = this.cb(world, pos).selectPart(v3);
|
||||
|
||||
if (sp.part != null) {
|
||||
return sp.part.getItemStack(PartItemStack.PICK);
|
||||
} else if (sp.facade != null) {
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addHitEffects(final IBlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer) {
|
||||
|
||||
// Half the particle rate. Since we're spawning concentrated on a specific spot,
|
||||
// our particle effect otherwise looks too strong
|
||||
if (Platform.getRandom().nextBoolean()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ICableBusContainer cb = this.cb(world, target.getBlockPos());
|
||||
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
|
||||
|
||||
// We cannot add the effect if we don't have the model
|
||||
if (!(model instanceof CableBusBakedModel)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
|
||||
// Spawn a particle for one of the particle textures
|
||||
TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
|
||||
if (texture != null) {
|
||||
double x = target.hitVec.x;
|
||||
double y = target.hitVec.y;
|
||||
double z = target.hitVec.z;
|
||||
|
||||
Particle fx = new DestroyFX(world, x, y, z, 0.0D, 0.0D, 0.0D, state).setBlockPos(target.getBlockPos()).multipleParticleScaleBy(0.8F);
|
||||
fx.setParticleTexture(texture);
|
||||
effectRenderer.addEffect(fx);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addDestroyEffects(final World world, final BlockPos pos, final ParticleManager effectRenderer) {
|
||||
ICableBusContainer cb = this.cb(world, pos);
|
||||
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
|
||||
|
||||
// We cannot add the effect if we dont have the model
|
||||
if (!(model instanceof CableBusBakedModel)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
|
||||
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures(renderState);
|
||||
|
||||
if (!textures.isEmpty()) {
|
||||
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
// Randomly select one of the textures if the cable bus has more than just one possibility here
|
||||
final TextureAtlasSprite texture = Platform.pickRandom(textures);
|
||||
|
||||
final double d0 = pos.getX() + (j + 0.5D) / 4.0D;
|
||||
final double d1 = pos.getY() + (k + 0.5D) / 4.0D;
|
||||
final double d2 = pos.getZ() + (l + 0.5D) / 4.0D;
|
||||
final ParticleDigging particle = new DestroyFX(world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos
|
||||
.getY() - 0.5D, d2 - pos.getZ() - 0.5D, this.getDefaultState()).setBlockPos(pos);
|
||||
|
||||
particle.setParticleTexture(texture);
|
||||
effectRenderer.addEffect(particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
if (Platform.isServer()) {
|
||||
this.cb(world, pos).onNeighborChanged(world, pos, fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
private ICableBusContainer cb(final IBlockAccess w, final BlockPos pos) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
ICableBusContainer out = null;
|
||||
|
||||
if (te instanceof TileCableBus) {
|
||||
out = ((TileCableBus) te).getCableBus();
|
||||
}
|
||||
|
||||
return out == null ? NULL_CABLE_BUS : out;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IFacadeContainer fc(final IBlockAccess w, final BlockPos pos) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
IFacadeContainer out = null;
|
||||
|
||||
if (te instanceof TileCableBus) {
|
||||
out = ((TileCableBus) te).getCableBus().getFacadeContainer();
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
|
||||
if (Platform.isClient()) {
|
||||
final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
|
||||
if (rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals(rtr.getBlockPos())) {
|
||||
final Vec3d hitVec = rtr.hitVec.subtract(new Vec3d(pos));
|
||||
|
||||
if (this.cb(worldIn, pos).clicked(playerIn, EnumHand.MAIN_HAND, hitVec)) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketClick(pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockClickPacket(World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec) {
|
||||
this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
|
||||
}
|
||||
|
||||
@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) {
|
||||
return this.cb(w, pos).activate(player, hand, new Vec3d(hitX, hitY, hitZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolorBlock(final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color) {
|
||||
return this.recolorBlock(world, pos, side, color, null);
|
||||
}
|
||||
|
||||
public boolean recolorBlock(final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color, final EntityPlayer who) {
|
||||
try {
|
||||
return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who);
|
||||
} catch (final Throwable ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void setupTile() {
|
||||
noTesrTile = Api.INSTANCE.partHelper().getCombinedInstance(TileCableBus.class);
|
||||
this.setTileEntity(noTesrTile);
|
||||
|
||||
GameRegistry.registerTileEntity(noTesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "BlockCableBus");
|
||||
|
||||
if (Platform.isClient()) {
|
||||
setupTesr();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static void setupTesr() {
|
||||
tesrTile = Api.INSTANCE.partHelper().getCombinedInstance(TileCableBusTESR.class);
|
||||
GameRegistry.registerTileEntity(tesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "ClientOnly_TESR_CableBus");
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(BlockCableBus.getTesrTile(), new CableBusTESR());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getFacadeState(IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
if (side != null) {
|
||||
IFacadeContainer container = this.fc(world, pos);
|
||||
if (container != null) {
|
||||
IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(side));
|
||||
if (facade != null) {
|
||||
return facade.getBlockState();
|
||||
}
|
||||
}
|
||||
}
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
public static Class<? extends AEBaseTile> getNoTesrTile() {
|
||||
return noTesrTile;
|
||||
}
|
||||
|
||||
public static Class<? extends AEBaseTile> getTesrTile() {
|
||||
return tesrTile;
|
||||
}
|
||||
|
||||
// Helper to get access to the protected constructor
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class DestroyFX extends ParticleDigging {
|
||||
DestroyFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, IBlockState state) {
|
||||
super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.networking.TileController;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
@@ -31,154 +33,126 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.networking.TileController;
|
||||
|
||||
public class BlockController extends AEBaseTileBlock {
|
||||
|
||||
public class BlockController extends AEBaseTileBlock
|
||||
{
|
||||
public enum ControllerBlockState implements IStringSerializable {
|
||||
offline, online, conflicted;
|
||||
|
||||
public enum ControllerBlockState implements IStringSerializable
|
||||
{
|
||||
offline, online, conflicted;
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Controls the rendering of the controller block (connected texture style).
|
||||
* inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers,
|
||||
* and since they are always offline, they do not have the usual sub-states.
|
||||
*/
|
||||
public enum ControllerRenderType implements IStringSerializable {
|
||||
block, column_x, column_y, column_z, inside_a, inside_b;
|
||||
|
||||
/**
|
||||
* Controls the rendering of the controller block (connected texture style).
|
||||
* inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers,
|
||||
* and since they are always offline, they do not have the usual sub-states.
|
||||
*/
|
||||
public enum ControllerRenderType implements IStringSerializable
|
||||
{
|
||||
block, column_x, column_y, column_z, inside_a, inside_b;
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static final PropertyEnum<ControllerBlockState> CONTROLLER_STATE = PropertyEnum.create("state", ControllerBlockState.class);
|
||||
|
||||
public static final PropertyEnum<ControllerBlockState> CONTROLLER_STATE = PropertyEnum.create( "state", ControllerBlockState.class );
|
||||
public static final PropertyEnum<ControllerRenderType> CONTROLLER_TYPE = PropertyEnum.create("type", ControllerRenderType.class);
|
||||
|
||||
public static final PropertyEnum<ControllerRenderType> CONTROLLER_TYPE = PropertyEnum.create( "type", ControllerRenderType.class );
|
||||
public BlockController() {
|
||||
super(Material.IRON);
|
||||
this.setHardness(6);
|
||||
this.setDefaultState(this.getDefaultState()
|
||||
.withProperty(CONTROLLER_STATE, ControllerBlockState.offline)
|
||||
.withProperty(CONTROLLER_TYPE, ControllerRenderType.block));
|
||||
}
|
||||
|
||||
public BlockController()
|
||||
{
|
||||
super( Material.IRON );
|
||||
this.setHardness( 6 );
|
||||
this.setDefaultState( this.getDefaultState()
|
||||
.withProperty( CONTROLLER_STATE, ControllerBlockState.offline )
|
||||
.withProperty( CONTROLLER_TYPE, ControllerRenderType.block ) );
|
||||
}
|
||||
@Override
|
||||
protected IProperty[] getAEStates() {
|
||||
return new IProperty[]{CONTROLLER_STATE, CONTROLLER_TYPE};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { CONTROLLER_STATE, CONTROLLER_TYPE };
|
||||
}
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, this.getAEStates());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer( this, this.getAEStates() );
|
||||
}
|
||||
/**
|
||||
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent
|
||||
* controllers and the network state of this controller (offline, online, conflicted). This is used to
|
||||
* get a rudimentary connected texture feel for the controller based on how it is placed.
|
||||
*/
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
|
||||
/**
|
||||
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent
|
||||
* controllers and the network state of this controller (offline, online, conflicted). This is used to
|
||||
* get a rudimentary connected texture feel for the controller based on how it is placed.
|
||||
*/
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
// Only used for columns, really
|
||||
ControllerRenderType type = ControllerRenderType.block;
|
||||
|
||||
// Only used for columns, really
|
||||
ControllerRenderType type = ControllerRenderType.block;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
// Detect whether controllers are on both sides of the x, y, and z axes
|
||||
final boolean xx = this.getTileEntity(world, x - 1, y, z) instanceof TileController && this.getTileEntity(world, x + 1, y,
|
||||
z) instanceof TileController;
|
||||
final boolean yy = this.getTileEntity(world, x, y - 1, z) instanceof TileController && this.getTileEntity(world, x, y + 1,
|
||||
z) instanceof TileController;
|
||||
final boolean zz = this.getTileEntity(world, x, y, z - 1) instanceof TileController && this.getTileEntity(world, x, y,
|
||||
z + 1) instanceof TileController;
|
||||
|
||||
// Detect whether controllers are on both sides of the x, y, and z axes
|
||||
final boolean xx = this.getTileEntity( world, x - 1, y, z ) instanceof TileController && this.getTileEntity( world, x + 1, y,
|
||||
z ) instanceof TileController;
|
||||
final boolean yy = this.getTileEntity( world, x, y - 1, z ) instanceof TileController && this.getTileEntity( world, x, y + 1,
|
||||
z ) instanceof TileController;
|
||||
final boolean zz = this.getTileEntity( world, x, y, z - 1 ) instanceof TileController && this.getTileEntity( world, x, y,
|
||||
z + 1 ) instanceof TileController;
|
||||
if (xx && !yy && !zz) {
|
||||
type = ControllerRenderType.column_x;
|
||||
} else if (!xx && yy && !zz) {
|
||||
type = ControllerRenderType.column_y;
|
||||
} else if (!xx && !yy && zz) {
|
||||
type = ControllerRenderType.column_z;
|
||||
} else if ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2) {
|
||||
final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2;
|
||||
|
||||
if( xx && !yy && !zz )
|
||||
{
|
||||
type = ControllerRenderType.column_x;
|
||||
}
|
||||
else if( !xx && yy && !zz )
|
||||
{
|
||||
type = ControllerRenderType.column_y;
|
||||
}
|
||||
else if( !xx && !yy && zz )
|
||||
{
|
||||
type = ControllerRenderType.column_z;
|
||||
}
|
||||
else if( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) >= 2 )
|
||||
{
|
||||
final int v = ( Math.abs( x ) + Math.abs( y ) + Math.abs( z ) ) % 2;
|
||||
// While i'd like this to be based on the blockstate randomization feature, this generates
|
||||
// an alternating pattern based on world position, so this is not 100% doable with blockstates.
|
||||
if (v == 0) {
|
||||
type = ControllerRenderType.inside_a;
|
||||
} else {
|
||||
type = ControllerRenderType.inside_b;
|
||||
}
|
||||
}
|
||||
|
||||
// While i'd like this to be based on the blockstate randomization feature, this generates
|
||||
// an alternating pattern based on world position, so this is not 100% doable with blockstates.
|
||||
if( v == 0 )
|
||||
{
|
||||
type = ControllerRenderType.inside_a;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = ControllerRenderType.inside_b;
|
||||
}
|
||||
}
|
||||
return state.withProperty(CONTROLLER_TYPE, type);
|
||||
}
|
||||
|
||||
return state.withProperty( CONTROLLER_TYPE, type );
|
||||
}
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
return state;
|
||||
}
|
||||
@Override
|
||||
public int getMetaFromState(final IBlockState state) {
|
||||
return state.getValue(CONTROLLER_STATE).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState( final IBlockState state )
|
||||
{
|
||||
return state.getValue( CONTROLLER_STATE ).ordinal();
|
||||
}
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(final int meta) {
|
||||
ControllerBlockState state = ControllerBlockState.values()[meta];
|
||||
return this.getDefaultState().withProperty(CONTROLLER_STATE, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( final int meta )
|
||||
{
|
||||
ControllerBlockState state = ControllerBlockState.values()[meta];
|
||||
return this.getDefaultState().withProperty( CONTROLLER_STATE, state );
|
||||
}
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos )
|
||||
{
|
||||
final TileController tc = this.getTileEntity( world, pos );
|
||||
if( tc != null )
|
||||
{
|
||||
tc.onNeighborChange( false );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
final TileController tc = this.getTileEntity(world, pos);
|
||||
if (tc != null) {
|
||||
tc.onNeighborChange(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,9 @@ import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
|
||||
|
||||
public class BlockCreativeEnergyCell extends AEBaseTileBlock
|
||||
{
|
||||
public class BlockCreativeEnergyCell extends AEBaseTileBlock {
|
||||
|
||||
public BlockCreativeEnergyCell()
|
||||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
}
|
||||
public BlockCreativeEnergyCell() {
|
||||
super(AEGlassMaterial.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,14 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
{
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell {
|
||||
|
||||
public BlockDenseEnergyCell()
|
||||
{
|
||||
public BlockDenseEnergyCell() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,13 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class BlockEnergyAcceptor extends AEBaseTileBlock {
|
||||
|
||||
public class BlockEnergyAcceptor extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public BlockEnergyAcceptor()
|
||||
{
|
||||
super( Material.IRON );
|
||||
}
|
||||
public BlockEnergyAcceptor() {
|
||||
super(Material.IRON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -29,56 +32,45 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockEnergyCell extends AEBaseTileBlock {
|
||||
|
||||
public class BlockEnergyCell extends AEBaseTileBlock
|
||||
{
|
||||
public static final PropertyInteger ENERGY_STORAGE = PropertyInteger.create("fullness", 0, 7);
|
||||
|
||||
public static final PropertyInteger ENERGY_STORAGE = PropertyInteger.create( "fullness", 0, 7 );
|
||||
@Override
|
||||
public int getMetaFromState(final IBlockState state) {
|
||||
return state.getValue(ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState( final IBlockState state )
|
||||
{
|
||||
return state.getValue( ENERGY_STORAGE );
|
||||
}
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(final int meta) {
|
||||
return this.getDefaultState().withProperty(ENERGY_STORAGE, Math.min(7, Math.max(0, meta)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( final int meta )
|
||||
{
|
||||
return this.getDefaultState().withProperty( ENERGY_STORAGE, Math.min( 7, Math.max( 0, meta ) ) );
|
||||
}
|
||||
public BlockEnergyCell() {
|
||||
super(AEGlassMaterial.INSTANCE);
|
||||
}
|
||||
|
||||
public BlockEnergyCell()
|
||||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
|
||||
super.getSubBlocks(tabs, itemStacks);
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks )
|
||||
{
|
||||
super.getSubBlocks( tabs, itemStacks );
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final NBTTagCompound tag = Platform.openNbtData(charged);
|
||||
tag.setDouble("internalCurrentPower", this.getMaxPower());
|
||||
tag.setDouble("internalMaxPower", this.getMaxPower());
|
||||
|
||||
final ItemStack charged = new ItemStack( this, 1 );
|
||||
final NBTTagCompound tag = Platform.openNbtData( charged );
|
||||
tag.setDouble( "internalCurrentPower", this.getMaxPower() );
|
||||
tag.setDouble( "internalMaxPower", this.getMaxPower() );
|
||||
itemStacks.add(charged);
|
||||
}
|
||||
|
||||
itemStacks.add( charged );
|
||||
}
|
||||
public double getMaxPower() {
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { ENERGY_STORAGE };
|
||||
}
|
||||
@Override
|
||||
protected IProperty[] getAEStates() {
|
||||
return new IProperty[]{ENERGY_STORAGE};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,62 +19,55 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
public class BlockEnergyCellRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
public class BlockEnergyCellRendering extends BlockRenderingCustomizer {
|
||||
|
||||
private final ResourceLocation baseModel;
|
||||
private final ResourceLocation baseModel;
|
||||
|
||||
public BlockEnergyCellRendering( ResourceLocation baseModel )
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
}
|
||||
public BlockEnergyCellRendering(ResourceLocation baseModel) {
|
||||
this.baseModel = baseModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
itemRendering.meshDefinition( this::getItemModel );
|
||||
// Note: Since we use the block models, we dont need to register custom variants
|
||||
}
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
itemRendering.meshDefinition(this::getItemModel);
|
||||
// Note: Since we use the block models, we dont need to register custom variants
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which version of the energy cell model should be used depending on the fill factor
|
||||
* of the item stack.
|
||||
*/
|
||||
private ModelResourceLocation getItemModel( ItemStack is )
|
||||
{
|
||||
double fillFactor = getFillFactor( is );
|
||||
/**
|
||||
* Determines which version of the energy cell model should be used depending on the fill factor
|
||||
* of the item stack.
|
||||
*/
|
||||
private ModelResourceLocation getItemModel(ItemStack is) {
|
||||
double fillFactor = getFillFactor(is);
|
||||
|
||||
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor( fillFactor );
|
||||
return new ModelResourceLocation( this.baseModel, "fullness=" + storageLevel );
|
||||
}
|
||||
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor(fillFactor);
|
||||
return new ModelResourceLocation(this.baseModel, "fullness=" + storageLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
|
||||
* Returns 0 if the item stack has no fill factor.
|
||||
*/
|
||||
private static double getFillFactor( ItemStack is )
|
||||
{
|
||||
if( !( is.getItem() instanceof IAEItemPowerStorage ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
|
||||
* Returns 0 if the item stack has no fill factor.
|
||||
*/
|
||||
private static double getFillFactor(ItemStack is) {
|
||||
if (!(is.getItem() instanceof IAEItemPowerStorage)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem();
|
||||
double curPower = itemChargeable.getAECurrentPower( is );
|
||||
double maxPower = itemChargeable.getAEMaxPower( is );
|
||||
AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem();
|
||||
double curPower = itemChargeable.getAECurrentPower(is);
|
||||
double maxPower = itemChargeable.getAEMaxPower(is);
|
||||
|
||||
return curPower / maxPower;
|
||||
}
|
||||
return curPower / maxPower;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,13 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -36,224 +40,196 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision {
|
||||
|
||||
enum State implements IStringSerializable
|
||||
{
|
||||
OFF,
|
||||
ON,
|
||||
HAS_CHANNEL;
|
||||
enum State implements IStringSerializable {
|
||||
OFF,
|
||||
ON,
|
||||
HAS_CHANNEL;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static final PropertyEnum<State> STATE = PropertyEnum.create( "state", State.class );
|
||||
public static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
|
||||
|
||||
public BlockWireless()
|
||||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
this.setLightOpacity( 0 );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
this.setDefaultState( this.getDefaultState().withProperty( STATE, State.OFF ) );
|
||||
}
|
||||
public BlockWireless() {
|
||||
super(AEGlassMaterial.INSTANCE);
|
||||
this.setLightOpacity(0);
|
||||
this.setFullSize(false);
|
||||
this.setOpaque(false);
|
||||
this.setDefaultState(this.getDefaultState().withProperty(STATE, State.OFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos )
|
||||
{
|
||||
State teState = State.OFF;
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
State teState = State.OFF;
|
||||
|
||||
TileWireless te = this.getTileEntity( worldIn, pos );
|
||||
if( te != null )
|
||||
{
|
||||
if( te.isActive() )
|
||||
{
|
||||
teState = State.HAS_CHANNEL;
|
||||
}
|
||||
else if( te.isPowered() )
|
||||
{
|
||||
teState = State.ON;
|
||||
}
|
||||
}
|
||||
TileWireless te = this.getTileEntity(worldIn, pos);
|
||||
if (te != null) {
|
||||
if (te.isActive()) {
|
||||
teState = State.HAS_CHANNEL;
|
||||
} else if (te.isPowered()) {
|
||||
teState = State.ON;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getActualState( state, worldIn, pos )
|
||||
.withProperty( STATE, teState );
|
||||
}
|
||||
return super.getActualState(state, worldIn, pos)
|
||||
.withProperty(STATE, teState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { STATE };
|
||||
}
|
||||
@Override
|
||||
protected IProperty[] getAEStates() {
|
||||
return new IProperty[]{STATE};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
final TileWireless tg = this.getTileEntity( w, pos );
|
||||
@Override
|
||||
public boolean onBlockActivated(final World w, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
|
||||
final TileWireless tg = this.getTileEntity(w, pos);
|
||||
|
||||
if( tg != null && !player.isSneaking() )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (tg != null && !player.isSneaking()) {
|
||||
if (Platform.isServer()) {
|
||||
Platform.openGUI(player, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_WIRELESS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onBlockActivated( w, pos, state, player, hand, side, hitX, hitY, hitZ );
|
||||
}
|
||||
return super.onBlockActivated(w, pos, state, player, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b )
|
||||
{
|
||||
final TileWireless tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final EnumFacing forward = tile.getForward();
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
|
||||
final TileWireless tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final EnumFacing forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch( forward )
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Collections.singletonList( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
return Collections.singletonList( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
return Collections.singletonList(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
}
|
||||
return Collections.singletonList(new AxisAlignedBB(0.0, 0, 0.0, 1.0, 1.0, 1.0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
|
||||
{
|
||||
final TileWireless tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final EnumFacing forward = tile.getForward();
|
||||
@Override
|
||||
public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
|
||||
final TileWireless tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final EnumFacing forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch( forward )
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out.add( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
}
|
||||
out.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
} else {
|
||||
out.add(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -27,33 +29,26 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
|
||||
|
||||
/**
|
||||
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant).
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
public class CableBusColor implements IBlockColor
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CableBusColor implements IBlockColor {
|
||||
|
||||
@Override
|
||||
public int colorMultiplier( IBlockState state, IBlockAccess worldIn, BlockPos pos, int color )
|
||||
{
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int color) {
|
||||
|
||||
AEColor busColor = AEColor.TRANSPARENT;
|
||||
AEColor busColor = AEColor.TRANSPARENT;
|
||||
|
||||
if( state instanceof IExtendedBlockState )
|
||||
{
|
||||
CableBusRenderState renderState = ( (IExtendedBlockState) state ).getValue( BlockCableBus.RENDER_STATE_PROPERTY );
|
||||
if( renderState != null )
|
||||
{
|
||||
busColor = renderState.getCableColor();
|
||||
}
|
||||
}
|
||||
if (state instanceof IExtendedBlockState) {
|
||||
CableBusRenderState renderState = ((IExtendedBlockState) state).getValue(BlockCableBus.RENDER_STATE_PROPERTY);
|
||||
if (renderState != null) {
|
||||
busColor = renderState.getCableColor();
|
||||
}
|
||||
}
|
||||
|
||||
return busColor.getVariantByTintIndex( color );
|
||||
return busColor.getVariantByTintIndex(color);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,34 +19,30 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.cablebus.CableBusModel;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
/**
|
||||
* Customizes the rendering behavior for cable busses, which are the biggest multipart of AE2.
|
||||
*/
|
||||
public class CableBusRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
private final PartModels partModels;
|
||||
public class CableBusRendering extends BlockRenderingCustomizer {
|
||||
private final PartModels partModels;
|
||||
|
||||
public CableBusRendering( PartModels partModels )
|
||||
{
|
||||
this.partModels = partModels;
|
||||
}
|
||||
public CableBusRendering(PartModels partModels) {
|
||||
this.partModels = partModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.builtInModel( "models/block/builtin/cable_bus", new CableBusModel( this.partModels ) );
|
||||
rendering.blockColor( new CableBusColor() );
|
||||
rendering.modelCustomizer( ( loc, model ) -> model );
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.builtInModel("models/block/builtin/cable_bus", new CableBusModel(this.partModels));
|
||||
rendering.blockColor(new CableBusColor());
|
||||
rendering.modelCustomizer((loc, model) -> model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,10 @@ import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
|
||||
public class ControllerRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
// Disables the default model rotator
|
||||
rendering.modelCustomizer( ( loc, model ) -> model );
|
||||
}
|
||||
public class ControllerRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
// Disables the default model rotator
|
||||
rendering.modelCustomizer((loc, model) -> model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.StaticBlockColor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
public class WirelessRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.blockColor( new StaticBlockColor( AEColor.TRANSPARENT ) );
|
||||
}
|
||||
public class WirelessRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user