diff --git a/src/api/java/appeng/api/definitions/IBlocks.java b/src/api/java/appeng/api/definitions/IBlocks.java index 0cb1c6d2..f9b27723 100644 --- a/src/api/java/appeng/api/definitions/IBlocks.java +++ b/src/api/java/appeng/api/definitions/IBlocks.java @@ -77,6 +77,22 @@ public interface IBlocks IBlockDefinition quartzPillarStair(); + IBlockDefinition skyStoneSlab(); + + IBlockDefinition skyStoneBlockSlab(); + + IBlockDefinition skyStoneBrickSlab(); + + IBlockDefinition skyStoneSmallBrickSlab(); + + IBlockDefinition fluixSlab(); + + IBlockDefinition quartzSlab(); + + IBlockDefinition chiseledQuartzSlab(); + + IBlockDefinition quartzPillarSlab(); + /* * misc */ diff --git a/src/main/java/appeng/block/AEBaseItemBlockSlab.java b/src/main/java/appeng/block/AEBaseItemBlockSlab.java new file mode 100644 index 00000000..20bb1a4d --- /dev/null +++ b/src/main/java/appeng/block/AEBaseItemBlockSlab.java @@ -0,0 +1,12 @@ +package appeng.block; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemSlab; + +public class AEBaseItemBlockSlab extends ItemSlab { + + public AEBaseItemBlockSlab(Block block, AEBaseSlabBlock singleSlab, AEBaseSlabBlock doubleSlab, Boolean isDoubleSlab) + { + super( block, singleSlab, doubleSlab, isDoubleSlab ); + } +} diff --git a/src/main/java/appeng/block/AEBaseSlabBlock.java b/src/main/java/appeng/block/AEBaseSlabBlock.java new file mode 100644 index 00000000..6da93f6e --- /dev/null +++ b/src/main/java/appeng/block/AEBaseSlabBlock.java @@ -0,0 +1,129 @@ +/* + * 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 . + */ + +package appeng.block; + + +import java.util.EnumSet; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockSlab; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import appeng.core.features.AEFeature; +import appeng.core.features.IAEFeature; +import appeng.core.features.IFeatureHandler; +import appeng.core.features.SlabBlockFeatureHandler; + + +public class AEBaseSlabBlock extends BlockSlab implements IAEFeature +{ + private final IFeatureHandler features; + private final AEBaseBlock block; + private final int meta; + private AEBaseSlabBlock slabs; + private AEBaseSlabBlock doubleSlabs; + private final String name; + + public AEBaseSlabBlock( AEBaseBlock block, int meta, EnumSet features, boolean isDoubleSlab, String name ) + { + super( isDoubleSlab, block.getMaterial() ); + this.block = block; + this.meta = meta; + this.name = name; + this.setBlockName( "appliedenergistics2." + name ); + this.setHardness( block.getBlockHardness( null, 0, 0, 0 ) ); + this.setResistance( block.getExplosionResistance( null ) * 5.0F / 3.0F ); + this.setStepSound( block.stepSound ); + this.useNeighborBrightness = true; + if (!field_150004_a) this.doubleSlabs = new AEBaseSlabBlock( block, meta, features, true, name + ".double" ).setSlabs(this); + this.features = !field_150004_a ? new SlabBlockFeatureHandler( features, this ) : null; + } + + public AEBaseSlabBlock setSlabs(AEBaseSlabBlock slabs) + { + this.slabs = slabs; + return this; + } + + public AEBaseSlabBlock slabs() + { + return slabs; + } + + public AEBaseSlabBlock doubleSlabs() + { + return doubleSlabs; + } + + @Override + public IFeatureHandler handler() + { + return this.features; + } + + @Override + public void postInit() + { + // Override to do stuff + } + + @Override + public IIcon getIcon(int dir, int meta) + { + return block.getIcon( dir, this.meta ); + } + + @Override + public String func_150002_b(int p_150002_1_) + { + return this.getUnlocalizedName(); + } + + @Override + public void registerBlockIcons(IIconRegister reg) { } + + @Override + public Item getItemDropped(int meta, Random rand, int fortune) + { + return this.field_150004_a ? Item.getItemFromBlock(this.slabs) : Item.getItemFromBlock(this); + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) + { + AEBaseSlabBlock block = (AEBaseSlabBlock) world.getBlock(x, y, z); + + if (block == null) return null; + if (block.field_150004_a) block = this.slabs; + + int meta = world.getBlockMetadata(x, y, z) & 7; + return new ItemStack(block, 1, meta); + } + + public String name() + { + return name; + } +} diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index 651f3b7d..a6ce827b 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -19,6 +19,7 @@ package appeng.core.api.definitions; +import java.util.EnumSet; import java.util.Set; import com.google.common.collect.ImmutableSet; @@ -27,6 +28,7 @@ import appeng.api.definitions.IBlockDefinition; import appeng.api.definitions.IBlocks; import appeng.api.definitions.ITileDefinition; import appeng.api.util.IOrientableBlock; +import appeng.block.AEBaseSlabBlock; import appeng.block.crafting.BlockCraftingMonitor; import appeng.block.crafting.BlockCraftingStorage; import appeng.block.crafting.BlockCraftingUnit; @@ -79,6 +81,7 @@ import appeng.block.storage.BlockChest; import appeng.block.storage.BlockDrive; import appeng.block.storage.BlockIOPort; import appeng.block.storage.BlockSkyChest; +import appeng.core.features.AEFeature; import appeng.core.features.WrappedDamageItemDefinition; import appeng.debug.BlockChunkloader; import appeng.debug.BlockCubeGenerator; @@ -147,6 +150,14 @@ public final class ApiBlocks implements IBlocks private final IBlockDefinition quartzStair; private final IBlockDefinition chiseledQuartzStair; private final IBlockDefinition quartzPillarStair; + private final IBlockDefinition skyStoneSlab; + private final IBlockDefinition skyStoneBlockSlab; + private final IBlockDefinition skyStoneBrickSlab; + private final IBlockDefinition skyStoneSmallBrickSlab; + private final IBlockDefinition fluixSlab; + private final IBlockDefinition quartzSlab; + private final IBlockDefinition chiseledQuartzSlab; + private final IBlockDefinition quartzPillarSlab; private final IBlockDefinition itemGen; private final IBlockDefinition chunkLoader; @@ -230,6 +241,15 @@ public final class ApiBlocks implements IBlocks this.quartzPillarStair = constructor.registerBlockDefinition( new QuartzPillarStairBlock( quartzPillar ) ); + this.skyStoneSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( skyStone, 0, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "SkyStoneSlabBlock" ) ); + this.skyStoneBlockSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( skyStone, 1, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "SkyStoneBlockSlabBlock" ) ); + this.skyStoneBrickSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( skyStone, 2, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "SkyStoneBrickSlabBlock" ) ); + this.skyStoneSmallBrickSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( skyStone, 3, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "SkyStoneSmallBrickSlabBlock" ) ); + this.fluixSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( fluixBlock, 0, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "FluixSlabBlock" ) ); + this.quartzSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( quartzBlock, 0, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "QuartzSlabBlock" ) ); + this.chiseledQuartzSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( chiseledQuartz, 0, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "ChiseledQuartzSlabBlock" ) );; + this.quartzPillarSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( quartzPillar, 0, EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "QuartzPillarSlabBlock" ) ); + this.itemGen = constructor.registerBlockDefinition( new BlockItemGen() ); this.chunkLoader = constructor.registerBlockDefinition( new BlockChunkloader() ); this.phantomNode = constructor.registerBlockDefinition( new BlockPhantomNode() ); @@ -362,6 +382,54 @@ public final class ApiBlocks implements IBlocks return this.quartzPillarStair; } + @Override + public IBlockDefinition skyStoneSlab() + { + return this.skyStoneSlab; + } + + @Override + public IBlockDefinition skyStoneBlockSlab() + { + return this.skyStoneBlockSlab; + } + + @Override + public IBlockDefinition skyStoneBrickSlab() + { + return this.skyStoneBrickSlab; + } + + @Override + public IBlockDefinition skyStoneSmallBrickSlab() + { + return this.skyStoneSmallBrickSlab; + } + + @Override + public IBlockDefinition fluixSlab() + { + return this.fluixSlab; + } + + @Override + public IBlockDefinition quartzSlab() + { + return this.quartzSlab; + } + + @Override + public IBlockDefinition chiseledQuartzSlab() + { + return this.chiseledQuartzSlab; + } + + @Override + public IBlockDefinition quartzPillarSlab() + { + return this.quartzPillarSlab; + } + @Override public ITileDefinition grindStone() { diff --git a/src/main/java/appeng/core/features/SlabBlockFeatureHandler.java b/src/main/java/appeng/core/features/SlabBlockFeatureHandler.java new file mode 100644 index 00000000..e394e7d7 --- /dev/null +++ b/src/main/java/appeng/core/features/SlabBlockFeatureHandler.java @@ -0,0 +1,74 @@ +/* + * 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 . + */ + +package appeng.core.features; + + +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockSlab; +import appeng.api.definitions.IBlockDefinition; +import appeng.block.AEBaseItemBlockSlab; +import appeng.block.AEBaseSlabBlock; +import appeng.core.CreativeTab; + +import com.google.common.base.Optional; + +import cpw.mods.fml.common.registry.GameRegistry; + + +public class SlabBlockFeatureHandler implements IFeatureHandler +{ + private final AEBaseSlabBlock slabs; + private final FeatureNameExtractor extractor; + private final boolean enabled; + private final BlockDefinition definition; + + public SlabBlockFeatureHandler( EnumSet features, AEBaseSlabBlock slabs ) + { + final ActivityState state = new FeaturedActiveChecker( features ).getActivityState(); + this.slabs = slabs; + this.extractor = new FeatureNameExtractor( slabs.getClass(), Optional.absent()); + this.enabled = state == ActivityState.Enabled; + this.definition = new BlockDefinition( slabs, state ); + } + + @Override + public final boolean isFeatureAvailable() + { + return this.enabled; + } + + @Override + public final IBlockDefinition getDefinition() + { + return this.definition; + } + + @Override + public final void register() + { + if( this.enabled ) + { + this.slabs.setCreativeTab( CreativeTab.instance ); + GameRegistry.registerBlock( slabs, AEBaseItemBlockSlab.class, "tile." + slabs.name(), slabs, slabs.doubleSlabs(), false); + GameRegistry.registerBlock( slabs.doubleSlabs(), AEBaseItemBlockSlab.class, "tile." + slabs.name() + ".double", slabs, slabs.doubleSlabs(), true); + } + } +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang index e3e6f7fc..243abd9f 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang @@ -61,6 +61,16 @@ tile.appliedenergistics2.SkyStoneBrickStairBlock.name=Sky Stone Brick Stairs tile.appliedenergistics2.SkyStoneSmallBrickStairBlock.name=Sky Stone Small Brick Stairs tile.appliedenergistics2.SkyStoneStairBlock.name=Sky Stone Stairs +// Slabs +tile.appliedenergistics2.ChiseledQuartzSlabBlock.name=Chiseled Certus Quartz Slabs +tile.appliedenergistics2.FluixSlabBlock.name=Fluix Slabs +tile.appliedenergistics2.QuartzPillarSlabBlock.name=Certus Quartz Pillar Slabs +tile.appliedenergistics2.QuartzSlabBlock.name=Certus Quartz Slabs +tile.appliedenergistics2.SkyStoneBlockSlabBlock.name=Sky Stone Block Slabs +tile.appliedenergistics2.SkyStoneBrickSlabBlock.name=Sky Stone Brick Slabs +tile.appliedenergistics2.SkyStoneSmallBrickSlabBlock.name=Sky Stone Small Brick Slabs +tile.appliedenergistics2.SkyStoneSlabBlock.name=Sky Stone Slabs + // Chat Messages chat.appliedenergistics2.ChestCannotReadStorageCell=ME Chest cannot read storage cell. chat.appliedenergistics2.SettingCleared=Setting Cleared. diff --git a/src/main/resources/assets/appliedenergistics2/recipes/index.recipe b/src/main/resources/assets/appliedenergistics2/recipes/index.recipe index f277fe3b..6a04bd64 100644 --- a/src/main/resources/assets/appliedenergistics2/recipes/index.recipe +++ b/src/main/resources/assets/appliedenergistics2/recipes/index.recipe @@ -67,3 +67,4 @@ import=paint_balls.recipe import=crafting.recipe import=vanilla_enhance.recipe import=stairs.recipe +import=slabs.recipe diff --git a/src/main/resources/assets/appliedenergistics2/recipes/slabs.recipe b/src/main/resources/assets/appliedenergistics2/recipes/slabs.recipe new file mode 100644 index 00000000..eda9bfd9 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/recipes/slabs.recipe @@ -0,0 +1,31 @@ +shaped= + ae2:BlockQuartzChiseled ae2:BlockQuartzChiseled ae2:BlockQuartzChiseled + -> 6 ae2:ChiseledQuartzSlabBlock + +shaped= + ae2:BlockFluix ae2:BlockFluix ae2:BlockFluix + -> 6 ae2:FluixSlabBlock + +shaped= + ae2:BlockQuartzPillar ae2:BlockQuartzPillar ae2:BlockQuartzPillar + -> 6 ae2:QuartzPillarSlabBlock + +shaped= + ae2:BlockQuartz ae2:BlockQuartz ae2:BlockQuartz + -> 6 ae2:QuartzSlabBlock + +shaped= + ae2:BlockSkyStone ae2:BlockSkyStone ae2:BlockSkyStone + -> 6 ae2:SkyStoneSlabBlock + +shaped= + ae2:BlockSkyStone:1 ae2:BlockSkyStone:1 ae2:BlockSkyStone:1 + -> 6 ae2:SkyStoneBlockSlabBlock + +shaped= + ae2:BlockSkyStone:2 ae2:BlockSkyStone:2 ae2:BlockSkyStone:2 + -> 6 ae2:SkyStoneBrickSlabBlock + +shaped= + ae2:BlockSkyStone:3 ae2:BlockSkyStone:3 ae2:BlockSkyStone:3 + -> 6 ae2:SkyStoneSmallBrickSlabBlock