2014-11-18 16:47:30 +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>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package appeng.core.features;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
2015-06-26 01:06:35 +02:00
|
|
|
import com.google.common.base.Optional;
|
|
|
|
|
2014-11-18 16:47:30 +01:00
|
|
|
import net.minecraft.block.BlockStairs;
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
2015-06-26 01:06:35 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IBlockDefinition;
|
2014-11-18 16:47:30 +01:00
|
|
|
import appeng.core.CreativeTab;
|
|
|
|
|
|
|
|
|
|
|
|
public class StairBlockFeatureHandler implements IFeatureHandler
|
|
|
|
{
|
|
|
|
private final BlockStairs stairs;
|
|
|
|
private final FeatureNameExtractor extractor;
|
|
|
|
private final boolean enabled;
|
|
|
|
private final BlockDefinition definition;
|
|
|
|
|
|
|
|
public StairBlockFeatureHandler( EnumSet<AEFeature> features, BlockStairs stairs, Optional<String> subName )
|
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
|
|
|
|
2014-11-18 16:47:30 +01:00
|
|
|
this.stairs = stairs;
|
|
|
|
this.extractor = new FeatureNameExtractor( stairs.getClass(), subName );
|
2015-01-03 02:53:14 +01:00
|
|
|
this.enabled = state == ActivityState.Enabled;
|
|
|
|
this.definition = new BlockDefinition( stairs, state );
|
2014-11-18 16:47:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public final boolean isFeatureAvailable()
|
2014-11-18 16:47:30 +01:00
|
|
|
{
|
|
|
|
return this.enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public final IBlockDefinition getDefinition()
|
2014-11-18 16:47:30 +01:00
|
|
|
{
|
|
|
|
return this.definition;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-06-26 01:06:35 +02:00
|
|
|
public final void register( Side side )
|
2014-11-18 16:47:30 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.enabled )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
String name = this.extractor.get();
|
|
|
|
this.stairs.setCreativeTab( CreativeTab.instance );
|
2015-06-16 02:44:59 +02:00
|
|
|
this.stairs.setUnlocalizedName( "appliedenergistics2." + name );
|
2014-11-18 16:47:30 +01:00
|
|
|
|
2015-06-26 01:06:35 +02:00
|
|
|
// "tile." +
|
|
|
|
GameRegistry.registerBlock( this.stairs, name );
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2014-11-18 16:47:30 +01:00
|
|
|
}
|
|
|
|
}
|