Fixed stairs

This commit is contained in:
thatsIch
2015-09-29 15:47:55 +02:00
parent 8b921a7b79
commit 59dbfb1452
169 changed files with 1470 additions and 1095 deletions
@@ -22,6 +22,7 @@ package appeng.block;
import java.util.EnumSet;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
@@ -36,13 +37,17 @@ public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature
{
private final IFeatureHandler features;
protected AEBaseStairBlock( Block block, EnumSet<AEFeature> features, String type )
protected AEBaseStairBlock( Block block, EnumSet<AEFeature> features, String type )
{
super( block.getDefaultState() );
super( block.getStateFromMeta( 0 ) );
this.features = new StairBlockFeatureHandler( features, this, Optional.<String>of(type) );
setUnlocalizedName( block.getUnlocalizedName() );
Preconditions.checkNotNull( block );
Preconditions.checkNotNull( block.getUnlocalizedName() );
Preconditions.checkArgument( block.getUnlocalizedName().length() > 0 );
this.features = new StairBlockFeatureHandler( features, this, Optional.of( type ) );
this.setUnlocalizedName( "stair." + type );
this.setLightOpacity( 0 );
}
@@ -22,6 +22,8 @@ package appeng.block.crafting;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
@@ -37,6 +39,7 @@ import net.minecraft.util.EnumWorldBlockLayer;
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.BaseBlockRender;
@@ -47,22 +50,49 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import com.google.common.base.Optional;
/**
*
*/
public class BlockCraftingUnit extends AEBaseTileBlock
{
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool FORMED = PropertyBool.create("formed");
public static final int FLAG_FORMED = 8;
public static final PropertyBool POWERED = PropertyBool.create( "powered" );
public static final PropertyBool FORMED = PropertyBool.create( "formed" );
final public CraftingUnitType type;
public static enum CraftingUnitType
public BlockCraftingUnit( CraftingUnitType type )
{
UNIT, ACCELERATOR, STORAGE_1K,STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
};
super( Material.iron, Optional.of( type.name() ) );
this.type = type;
this.setTileEntity( TileCraftingTile.class );
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
}
@Override
public IBlockState getStateFromMeta( int meta )
{
return getDefaultState().withProperty( POWERED, ( meta & 1 ) == 1 ).withProperty( FORMED, ( meta & 2 ) == 2 );
}
@Override
public int getMetaFromState( IBlockState state )
{
boolean p = (boolean) state.getValue( POWERED );
boolean f = (boolean) state.getValue( FORMED );
return ( p ? 1 : 0 ) | ( f ? 2 : 0 );
}
@Override
public void onNeighborBlockChange( World worldIn, BlockPos pos, IBlockState state, Block neighborBlock )
{
TileCraftingTile cp = this.getTileEntity( worldIn, pos );
if( cp != null )
{
cp.updateMultiBlock();
}
}
@Override
public EnumWorldBlockLayer getBlockLayer()
@@ -71,63 +101,20 @@ public class BlockCraftingUnit extends AEBaseTileBlock
}
@Override
public int getMetaFromState(
IBlockState state )
public void breakBlock( World w, BlockPos pos, IBlockState state )
{
boolean p = (boolean)state.getValue( POWERED );
boolean f = (boolean)state.getValue( FORMED );
return (p ? 1 : 0) | (f?2 : 0);
}
@Override
public IBlockState getStateFromMeta( int meta )
{
return getDefaultState().withProperty( POWERED, ( meta & 1 ) == 1 ? true : false ).withProperty( FORMED, ( meta & 2 ) == 2 ? true : false );
}
public BlockCraftingUnit( CraftingUnitType type )
{
super( Material.iron, Optional.of(type.name()) );
this.type = type;
this.setTileEntity( TileCraftingTile.class );
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCraftingCPU.class;
}
@Override
public appeng.client.texture.IAESprite getIcon(EnumFacing side, IBlockState state)
{
if ( type == CraftingUnitType.ACCELERATOR )
TileCraftingTile cp = this.getTileEntity( w, pos );
if( cp != null )
{
if ( (boolean)state.getValue( FORMED ) )
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
cp.breakCluster();
}
if ( (boolean)state.getValue( FORMED ) )
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
return super.getIcon( side,state );
super.breakBlock( w, pos, state );
}
@Override
public boolean onBlockActivated(
World w,
BlockPos pos,
IBlockState state,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
@Override
public boolean onBlockActivated( World w, BlockPos pos, IBlockState state, EntityPlayer p, EnumFacing side, float hitX, float hitY, float hitZ )
{
TileCraftingTile tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
{
@@ -143,6 +130,47 @@ public boolean onBlockActivated(
return false;
}
protected String getItemUnlocalizedName( ItemStack is )
{
return super.getUnlocalizedName( is );
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] {
POWERED,
FORMED
};
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCraftingCPU.class;
}
@Override
public appeng.client.texture.IAESprite getIcon( EnumFacing side, IBlockState state )
{
if( type == CraftingUnitType.ACCELERATOR )
{
if( (boolean) state.getValue( FORMED ) )
{
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
}
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
}
if( (boolean) state.getValue( FORMED ) )
{
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
}
return super.getIcon( side, state );
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
@@ -151,21 +179,6 @@ public boolean onBlockActivated(
itemStacks.add( new ItemStack( this, 1, 1 ) );
}
@Override
public void breakBlock(
World w,
BlockPos pos,
IBlockState state )
{
TileCraftingTile cp = this.getTileEntity( w, pos );
if( cp != null )
{
cp.breakCluster();
}
super.breakBlock( w, pos, state );
}
@Override
public String getUnlocalizedName( ItemStack is )
{
@@ -177,29 +190,8 @@ public boolean onBlockActivated(
return this.getItemUnlocalizedName( is );
}
protected String getItemUnlocalizedName( ItemStack is )
public enum CraftingUnitType
{
return super.getUnlocalizedName( is );
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[]{POWERED, FORMED };
}
@Override
public void onNeighborBlockChange(
World worldIn,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
TileCraftingTile cp = this.getTileEntity( worldIn, pos );
if( cp != null )
{
cp.updateMultiBlock();
}
}
}
@@ -23,6 +23,7 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -81,4 +82,10 @@ public class BlockInscriber extends AEBaseTileBlock
}
return false;
}
@Override
public String getUnlocalizedName( ItemStack is )
{
return super.getUnlocalizedName( is );
}
}
@@ -39,9 +39,9 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderTinyTNT;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityIds;
@@ -80,14 +80,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
public boolean onActivated( World w, BlockPos pos, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ )
{
if( player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel )
{
@@ -111,12 +104,19 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
w.playSoundAtEntity( primedTinyTNTEntity, "game.tnt.primed", 1.0F, 1.0F );
}
}
@Override
public void onBlockAdded(
World w,
BlockPos pos,
IBlockState state )
public void onNeighborBlockChange( World w, BlockPos pos, IBlockState state, Block neighborBlock )
{
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
{
this.startFuse( w, pos, null );
w.setBlockToAir( pos );
}
}
@Override
public void onBlockAdded( World w, BlockPos pos, IBlockState state )
{
super.onBlockAdded( w, pos, state );
@@ -128,38 +128,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
{
this.startFuse( w, pos, null );
w.setBlockToAir( pos );
}
}
@Override
public void onBlockExploded(
World w,
BlockPos pos,
Explosion exp )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy() );
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
w.spawnEntityInWorld( primedTinyTNTEntity );
}
}
@Override
public void onEntityCollidedWithBlock(
World w,
BlockPos pos,
Entity entity )
public void onEntityCollidedWithBlock( World w, BlockPos pos, Entity entity )
{
if( entity instanceof EntityArrow && !w.isRemote )
{
@@ -180,22 +149,24 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
public void onBlockExploded( World w, BlockPos pos, Explosion exp )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy() );
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
w.spawnEntityInWorld( primedTinyTNTEntity );
}
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, BlockPos pos, Entity thePlayer, boolean b )
{
return Collections.singletonList( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
@Override
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
public void addCollidingBlockToList( World w, BlockPos pos, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
out.add( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
@@ -1,38 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public final class BlockFluix extends AEDecorativeBlock
{
public BlockFluix()
{
super( Material.rock );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -1,38 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public final class BlockQuartz extends AEDecorativeBlock
{
public BlockQuartz()
{
super( Material.rock );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -1,38 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public final class BlockQuartzChiseled extends AEDecorativeBlock
{
public BlockQuartzChiseled()
{
super( Material.rock );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -1,77 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzGlass;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
public class BlockQuartzGlass extends AEBaseBlock
{
public BlockQuartzGlass()
{
super( Material.glass );
this.setLightOpacity( 0 );
this.isOpaque = false;
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
@SideOnly( Side.CLIENT )
public Class<? extends BaseBlockRender> getRenderer()
{
return RenderQuartzGlass.class;
}
@Override
public boolean shouldSideBeRendered(
IBlockAccess w,
BlockPos pos,
EnumFacing side )
{
Material mat = w.getBlockState( pos ).getBlock().getMaterial();
if( mat == Material.glass || mat == AEGlassMaterial.INSTANCE )
{
if( w.getBlockState( pos ).getBlock().getRenderType() == this.getRenderType() )
{
return false;
}
}
return super.shouldSideBeRendered( w, pos, side );
}
}
@@ -1,68 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import appeng.client.render.effects.VibrantFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
public class BlockQuartzLamp extends BlockQuartzGlass
{
public BlockQuartzLamp()
{
this.setLightLevel( 1.0f );
this.setBlockTextureName( "BlockQuartzGlass" );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks, AEFeature.DecorativeLights ) );
}
@Override
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
return;
}
if( CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = ( r.nextFloat() - 0.5F ) * 0.96D;
double d1 = ( r.nextFloat() - 0.5F ) * 0.96D;
double d2 = ( r.nextFloat() - 0.5F ) * 0.96D;
VibrantFX fx = new VibrantFX( w, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
}
@@ -1,78 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.helpers.MetaRotation;
// TODO Quartz Rotation.
public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
{
public BlockQuartzPillar()
{
super( Material.rock );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
@Override
public int getMetaFromState(
IBlockState state )
{
return 0;
}
@Override
public IBlockState getStateFromMeta(
int meta )
{
return getDefaultState();
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[]{ AXIS_ORIENTATION };
}
@Override
public boolean usesMetadata()
{
return true;
}
@Override
public IOrientable getOrientable( final IBlockAccess w,BlockPos pos )
{
return new MetaRotation( w, pos,false );
}
}
@@ -1,125 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, 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.block.solids;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.core.worlddata.WorldData;
import appeng.util.Platform;
public class BlockSkyStone extends AEBaseBlock
{
private static final float BLOCK_RESISTANCE = 150.0f;
private static final double BREAK_SPEAK_SCALAR = 0.1;
private static final double BREAK_SPEAK_THRESHOLD = 7.0;
public static enum SkystoneType {
stone,block,brick,smallbrick
};
SkystoneType type;
public BlockSkyStone( SkystoneType type )
{
super( Material.rock, Optional.of( type.name()) );
this.setHardness( 50 );
this.hasSubtypes = true;
this.blockResistance = BLOCK_RESISTANCE;
if ( type == SkystoneType.stone )
this.setHarvestLevel( "pickaxe", 3 );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.type = type;
MinecraftForge.EVENT_BUS.register( this );
}
@SubscribeEvent
public void breakFaster( PlayerEvent.BreakSpeed event )
{
if( event.state.getBlock() == this && event.entityPlayer != null )
{
ItemStack is = event.entityPlayer.inventory.getCurrentItem();
int level = -1;
if( is != null && is.getItem() != null )
{
level = is.getItem().getHarvestLevel( is, "pickaxe" );
}
if( type != SkystoneType.stone || level >= 3 || event.originalSpeed > BREAK_SPEAK_THRESHOLD )
{
event.newSpeed /= BREAK_SPEAK_SCALAR;
}
}
}
@Override
public void onBlockAdded(
World w,
BlockPos pos,
IBlockState state )
{
super.onBlockAdded( w, pos, state );
if( Platform.isServer() )
{
WorldData.instance().compassData().service().updateArea( w, pos.getX(), pos.getY(), pos.getZ() );
}
}
@Override
public String getUnlocalizedName( ItemStack is )
{
switch(type)
{
case block: return this.getUnlocalizedName() + ".Block";
case brick: return this.getUnlocalizedName() + ".Brick";
case smallbrick: return this.getUnlocalizedName() + ".SmallBrick";
default: return this.getUnlocalizedName();
}
}
@Override
public void breakBlock(
World w,
BlockPos pos,
IBlockState state )
{
super.breakBlock( w, pos, state );
if( Platform.isServer() )
{
WorldData.instance().compassData().service().updateArea( w, pos.getX(), pos.getY(), pos.getZ() );
}
}
}
@@ -1,190 +0,0 @@
/*
* 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.block.solids;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzOre;
import appeng.core.features.AEFeature;
public class OreQuartz extends AEBaseBlock
{
private int boostBrightnessLow;
private int boostBrightnessHigh;
private boolean enhanceBrightness;
public OreQuartz()
{
super( Material.rock );
this.setHardness( 3.0F );
this.setResistance( 5.0F );
this.boostBrightnessLow = 0;
this.boostBrightnessHigh = 1;
this.enhanceBrightness = false;
this.setFeature( EnumSet.of( AEFeature.Core ) );
}
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQuartzOre.class;
}
@Override
public void postInit()
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( this ) );
}
@Override
public int getMixedBrightnessForBlock(
IBlockAccess worldIn,
BlockPos pos )
{
int j1 = super.getMixedBrightnessForBlock( worldIn, pos );
if( this.enhanceBrightness )
{
j1 = Math.max( j1 >> 20, j1 >> 4 );
if( j1 > 4 )
{
j1 += this.boostBrightnessHigh;
}
else
{
j1 += this.boostBrightnessLow;
}
if( j1 > 15 )
{
j1 = 15;
}
return j1 << 20 | j1 << 4;
}
return j1;
}
@Override
public int quantityDropped( Random rand )
{
return 1 + rand.nextInt( 2 );
}
@Override
public Item getItemDropped(
IBlockState state, /* is null */
Random rand,
int fortune )
{
for( Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
{
return crystalItem;
}
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
}
@Override
public void dropBlockAsItemWithChance(
World w,
BlockPos pos,
IBlockState state,
float chance,
int fortune )
{
super.dropBlockAsItemWithChance( w, pos, state, chance, fortune );
if( this.getItemDropped( state, w.rand, fortune ) != Item.getItemFromBlock( this ) )
{
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, pos, xp );
}
}
@Override
public int damageDropped(
IBlockState state )
{
for( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
{
return crystalStack.getItemDamage();
}
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
}
@Override
public int quantityDroppedWithBonus( int fortune, Random rand )
{
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( null, rand, fortune ) )
{
int j = rand.nextInt( fortune + 2 ) - 1;
if( j < 0 )
{
j = 0;
}
return this.quantityDropped( rand ) * ( j + 1 );
}
else
{
return this.quantityDropped( rand );
}
}
public void setBoostBrightnessLow( int boostBrightnessLow )
{
this.boostBrightnessLow = boostBrightnessLow;
}
public void setBoostBrightnessHigh( int boostBrightnessHigh )
{
this.boostBrightnessHigh = boostBrightnessHigh;
}
public void setEnhanceBrightness( boolean enhanceBrightness )
{
this.enhanceBrightness = enhanceBrightness;
}
}
@@ -1,119 +0,0 @@
/*
* 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.block.solids;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition;
import appeng.client.render.effects.ChargedOreFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
public class OreQuartzCharged extends OreQuartz
{
public OreQuartzCharged()
{
this.setBoostBrightnessLow( 2 );
this.setBoostBrightnessHigh( 5 );
}
@Override
public Item getItemDropped(
IBlockState state,
Random rand,
int fortune )
{
for( Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() )
{
return charged;
}
throw new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" );
}
@Override
public int damageDropped(
IBlockState state )
{
for ( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeStack( 1 ).asSet() )
{
return crystalStack.getItemDamage();
}
throw new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" );
}
@Override
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if ( !AEConfig.instance.enableEffects )
{
return;
}
double xOff = ( r.nextFloat() );
double yOff = ( r.nextFloat() );
double zOff = ( r.nextFloat() );
switch( r.nextInt( 6 ) )
{
case 0:
xOff = -0.01;
break;
case 1:
yOff = -0.01;
break;
case 2:
xOff = -0.01;
break;
case 3:
zOff = -0.01;
break;
case 4:
xOff = 1.01;
break;
case 5:
yOff = 1.01;
break;
case 6:
zOff = 1.01;
break;
}
if( CommonHelper.proxy.shouldAddParticles( r ) )
{
ChargedOreFX fx = new ChargedOreFX( w, pos.getX() + xOff, pos.getY() + yOff, pos.getZ() + zOff, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
}
@@ -1,36 +0,0 @@
/*
* 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.block.stair;
import java.util.EnumSet;
import net.minecraft.block.Block;
import appeng.block.AEBaseStairBlock;
import appeng.core.features.AEFeature;
public final class BlockStairCommon extends AEBaseStairBlock
{
public BlockStairCommon( Block material, String type )
{
super( material,EnumSet.of( AEFeature.DecorativeQuartzBlocks ), type );
}
}