-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from micdoodle8/master
Update
- Loading branch information
Showing
29 changed files
with
1,477 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockEmergencyBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package micdoodle8.mods.galacticraft.core.blocks; | ||
|
||
import java.util.List; | ||
|
||
import micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock; | ||
import micdoodle8.mods.galacticraft.core.GalacticraftCore; | ||
import micdoodle8.mods.galacticraft.core.items.IShiftDescription; | ||
import micdoodle8.mods.galacticraft.core.tile.TileEntityEmergencyBox; | ||
import micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock; | ||
import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.properties.PropertyBool; | ||
import net.minecraft.block.state.BlockState; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.creativetab.CreativeTabs; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.BlockPos; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.EnumWorldBlockLayer; | ||
import net.minecraft.util.MovingObjectPosition; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
public class BlockEmergencyBox extends BlockAdvancedTile implements IShiftDescription, ISortableBlock, IPartialSealableBlock | ||
{ | ||
public static final PropertyBool KIT = PropertyBool.create("kit"); | ||
|
||
public BlockEmergencyBox(String assetName) | ||
{ | ||
super(Material.iron); | ||
this.setHardness(4.0F); | ||
this.setResistance(70F); | ||
this.setStepSound(Block.soundTypeMetal); | ||
this.setLightLevel(1.0F); | ||
this.setUnlocalizedName(assetName); | ||
this.setDefaultState(this.blockState.getBaseState().withProperty(KIT, false)); | ||
} | ||
|
||
@Override | ||
protected BlockState createBlockState() | ||
{ | ||
return new BlockState(this, KIT); | ||
} | ||
|
||
@Override | ||
public IBlockState getStateFromMeta(int meta) | ||
{ | ||
return this.getDefaultState().withProperty(KIT, meta % 2 == 1); | ||
} | ||
|
||
@Override | ||
public int getMetaFromState(IBlockState state) | ||
{ | ||
return (state.getValue(KIT) ? 1 : 0); | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
@Override | ||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack> par3List) | ||
{ | ||
par3List.add(new ItemStack(par1, 1, 0)); | ||
par3List.add(new ItemStack(par1, 1, 1)); | ||
} | ||
|
||
@Override | ||
public int damageDropped(IBlockState state) | ||
{ | ||
return getMetaFromState(state); | ||
} | ||
|
||
@Override | ||
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) | ||
{ | ||
return new ItemStack(this, 1, this.getDamageValue(world, pos)); | ||
} | ||
|
||
@Override | ||
@SideOnly(Side.CLIENT) | ||
public EnumWorldBlockLayer getBlockLayer() | ||
{ | ||
return EnumWorldBlockLayer.CUTOUT; | ||
} | ||
|
||
@Override | ||
public boolean isOpaqueCube() | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isFullCube() | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
public TileEntity createNewTileEntity(World world, int meta) | ||
{ | ||
return new TileEntityEmergencyBox(); | ||
} | ||
|
||
@Override | ||
public CreativeTabs getCreativeTabToDisplayOn() | ||
{ | ||
return GalacticraftCore.galacticraftBlocksTab; | ||
} | ||
|
||
@Override | ||
public boolean onMachineActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityPlayer, EnumFacing side, float hitX, float hitY, float hitZ) | ||
{ | ||
TileEntity tile = world.getTileEntity(pos); | ||
if (tile instanceof TileEntityEmergencyBox) | ||
{ | ||
if (!world.isRemote) | ||
{ | ||
((TileEntityEmergencyBox)tile).click(entityPlayer, side, state.getValue(KIT)); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getShiftDescription(int meta) | ||
{ | ||
return GCCoreUtil.translate(this.getUnlocalizedName() + ".description"); | ||
} | ||
|
||
@Override | ||
public boolean showDescription(int meta) | ||
{ | ||
return true; | ||
} | ||
|
||
@Override | ||
public EnumSortCategoryBlock getCategory(int meta) | ||
{ | ||
return EnumSortCategoryBlock.GENERAL; | ||
} | ||
|
||
@Override | ||
public boolean isSealed(World world, BlockPos pos, EnumFacing direction) | ||
{ | ||
return direction.ordinal() < 2; | ||
} | ||
|
||
@Override | ||
public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing direction) | ||
{ | ||
return direction.ordinal() < 2; | ||
} | ||
} |
Oops, something went wrong.