Applied-Energistics-2-tiler.../src/main/java/appeng/fmp/QuartzTorchPart.java

109 lines
2.8 KiB
Java
Raw Normal View History

2014-11-14 12:02:52 +01:00
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
2014-09-24 02:26:27 +02:00
package appeng.fmp;
2014-09-24 02:26:27 +02:00
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Cuboid6;
import codechicken.multipart.IRandomDisplayTick;
import codechicken.multipart.minecraft.McBlockPart;
import codechicken.multipart.minecraft.McSidedMetaPart;
2014-12-29 21:59:05 +01:00
import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition;
2015-06-16 02:44:59 +02:00
import appeng.api.util.ForgeDirection;
2014-12-29 21:59:05 +01:00
2014-09-24 02:26:27 +02:00
public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTick
{
public QuartzTorchPart()
{
2014-09-24 02:26:27 +02:00
this( ForgeDirection.DOWN.ordinal() );
}
public QuartzTorchPart( int meta )
{
2014-09-24 02:26:27 +02:00
super( meta );
}
public static McBlockPart placement( World world, BlockCoord pos, int side )
2014-09-24 02:26:27 +02:00
{
pos = pos.copy().offset( side );
if( !world.isSideSolid( pos.x, pos.y, pos.z, ForgeDirection.getOrientation( side ) ) )
{
return null;
}
return new QuartzTorchPart( side );
2014-09-24 02:26:27 +02:00
}
@Override
public boolean doesTick()
2014-09-24 02:26:27 +02:00
{
return false;
2014-09-24 02:26:27 +02:00
}
@Override
public String getType()
{
return PartRegistry.QuartzTorchPart.getName();
}
@Override
public Cuboid6 getBounds()
{
2014-12-29 15:13:47 +01:00
return this.getBounds( this.meta );
2014-09-24 02:26:27 +02:00
}
public Cuboid6 getBounds( int meta )
2014-09-24 02:26:27 +02:00
{
ForgeDirection up = ForgeDirection.getOrientation( meta );
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
return new Cuboid6( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 );
}
@Override
public int sideForMeta( int meta )
2014-09-24 02:26:27 +02:00
{
return ForgeDirection.getOrientation( meta ).getOpposite().ordinal();
}
@Override
public void randomDisplayTick( Random r )
2014-09-24 02:26:27 +02:00
{
this.getBlock().randomDisplayTick( this.world(), this.x(), this.y(), this.z(), r );
2014-09-24 02:26:27 +02:00
}
@Override
public Block getBlock()
2014-09-24 02:26:27 +02:00
{
for( Block torchBlock : AEApi.instance().definitions().blocks().quartzTorch().maybeBlock().asSet() )
{
return torchBlock;
}
throw new MissingDefinition( "Tried to retrieve a quartz torch, even though it is disabled." );
2014-09-24 02:26:27 +02:00
}
}