diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java index 1c644c1e5..87501deaa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java @@ -18,7 +18,9 @@ import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; @@ -27,6 +29,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -35,6 +38,8 @@ import java.util.Random; public class BlockCoalGenerator extends BlockContainerBase{ + private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3); + public BlockCoalGenerator(String name){ super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); @@ -75,6 +80,26 @@ public class BlockCoalGenerator extends BlockContainerBase{ return true; } + @Override + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; + + if(rotation == 0){ + world.setBlockState(pos, this.getStateFromMeta(0), 2); + } + if(rotation == 1){ + world.setBlockState(pos, this.getStateFromMeta(3), 2); + } + if(rotation == 2){ + world.setBlockState(pos, this.getStateFromMeta(1), 2); + } + if(rotation == 3){ + world.setBlockState(pos, this.getStateFromMeta(2), 2); + } + + super.onBlockPlacedBy(world, pos, state, player, stack); + } + @Override public EnumRarity getRarity(ItemStack stack){ return EnumRarity.RARE; @@ -85,4 +110,9 @@ public class BlockCoalGenerator extends BlockContainerBase{ this.dropInventory(world, pos); super.breakBlock(world, pos, state); } + + @Override + protected PropertyInteger getMetaProperty(){ + return META; + } } diff --git a/src/main/resources/assets/actuallyadditions/blockstates/blockCoalGenerator.json b/src/main/resources/assets/actuallyadditions/blockstates/blockCoalGenerator.json index d2c0683a5..506064340 100644 --- a/src/main/resources/assets/actuallyadditions/blockstates/blockCoalGenerator.json +++ b/src/main/resources/assets/actuallyadditions/blockstates/blockCoalGenerator.json @@ -3,14 +3,21 @@ "defaults": { "model": "minecraft:cube_bottom_top", "textures": { - "side": "actuallyadditions:blocks/blockCoalGenerator", + "side": "actuallyadditions:blocks/blockCoalGeneratorSide", "bottom": "actuallyadditions:blocks/blockCoalGeneratorBottom", - "top": "actuallyadditions:blocks/blockCoalGeneratorTop" + "top": "actuallyadditions:blocks/blockCoalGeneratorTop", + "north": "actuallyadditions:blocks/blockCoalGenerator" }, "transform": "forge:default-block" }, "variants": { "normal": [{}], - "inventory": [{}] + "inventory": [{}], + "meta": { + "0": { "y" : 0 }, + "1": { "y" : 180 }, + "2": { "y" : 270 }, + "3": { "y" : 90 } + } } } \ No newline at end of file