From 0f263f84f81405ebed36caa9e3dbb4c85dc691db Mon Sep 17 00:00:00 2001 From: TheCricket Date: Sun, 30 Nov 2014 18:10:51 -0500 Subject: [PATCH] Fixes #30 --- .../minecraft/chisel/block/BlockCarvable.java | 111 ++++++------------ .../chisel/block/BlockCarvablePowered.java | 14 +-- .../minecraft/chisel/block/BlockCloud.java | 38 ++---- .../chisel/block/BlockHolystone.java | 16 +-- .../minecraft/chisel/block/BlockLeaf.java | 15 +++ .../chisel/block/BlockLightstoneCarvable.java | 17 +-- .../chisel/block/BlockMarbleLamp.java | 40 +++---- .../chisel/block/BlockMarblePillar.java | 24 ++-- .../jbcs/minecraft/chisel/init/ModBlocks.java | 8 +- 9 files changed, 110 insertions(+), 173 deletions(-) create mode 100644 src/main/java/info/jbcs/minecraft/chisel/block/BlockLeaf.java diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvable.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvable.java index 414b848a..a865fff0 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvable.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvable.java @@ -17,87 +17,68 @@ import net.minecraft.world.IBlockAccess; import java.util.List; -public class BlockCarvable extends Block implements ICarvable -{ +public class BlockCarvable extends Block implements ICarvable { public CarvableHelper carverHelper; - private boolean isAlpha, isOpaque; + private boolean isAlpha; - public BlockCarvable() - { - this(Material.rock, true); + public BlockCarvable() { + this(Material.rock); } - public BlockCarvable(Material m, boolean isOpaque) - { + public BlockCarvable(Material m) { super(m); - this.isOpaque = isOpaque; carverHelper = new CarvableHelper(); setCreativeTab(ModTabs.tabChiselBlocks); } - public BlockCarvable setStained(boolean a) - { + public BlockCarvable setStained(boolean a) { this.isAlpha = a; return this; } @Override @SideOnly(Side.CLIENT) - public int getRenderBlockPass() - { + public int getRenderBlockPass() { return isAlpha ? 1 : 0; } @Override - public IIcon getIcon(int side, int metadata) - { + public IIcon getIcon(int side, int metadata) { return carverHelper.getIcon(side, metadata); } @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { return carverHelper.getIcon(world, x, y, z, side); } @Override - public int damageDropped(int i) - { + public int damageDropped(int i) { return i; } @Override - public void registerBlockIcons(IIconRegister register) - { + public void registerBlockIcons(IIconRegister register) { carverHelper.registerBlockIcons("Chisel", this, register); } @Override - public boolean isOpaqueCube(){ - return this.isOpaque; - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tabs, List list) - { + public void getSubBlocks(Item item, CreativeTabs tabs, List list) { carverHelper.registerSubBlocks(this, tabs, list); } @Override - public int getRenderType() - { + public int getRenderType() { return Chisel.RenderCTMId; } @Override - public CarvableVariation getVariation(int metadata) - { + public CarvableVariation getVariation(int metadata) { return carverHelper.getVariation(metadata); } - public static class SoundType extends Block.SoundType - { + public static class SoundType extends Block.SoundType { public final String soundNameStep; public final String soundNameBreak; public final String soundNamePlace; @@ -107,16 +88,12 @@ public class BlockCarvable extends Block implements ICarvable * Sound names dig.soundName and step.soundName must be specified in the * sounds.json * - * @param soundName - * block of the sound. Will automatically be expanded to - * "mod:dig.soundName" and "mod:step.soundName" respectively) - * @param volume - * default 1.0f - * @param frequency - * default 1.0f + * @param soundName block of the sound. Will automatically be expanded to + * "mod:dig.soundName" and "mod:step.soundName" respectively) + * @param volume default 1.0f + * @param frequency default 1.0f */ - public SoundType(String soundName, float volume, float frequency) - { + public SoundType(String soundName, float volume, float frequency) { super(soundName, volume, frequency); this.soundNameStep = null; this.soundNameBreak = null; @@ -127,17 +104,12 @@ public class BlockCarvable extends Block implements ICarvable * Creates a SoundType with manual names for step and break sounds. * Sound names must be specified in the sounds.json * - * @param soundNameBreak - * block break sound - * @param soundNameStep - * block step sound - * @param volume - * default 1.0f - * @param frequency - * default 1.0f + * @param soundNameBreak block break sound + * @param soundNameStep block step sound + * @param volume default 1.0f + * @param frequency default 1.0f */ - public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) - { + public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) { super(soundNameStep, volume, frequency); this.soundNameStep = soundNameStep; this.soundNameBreak = soundNameBreak; @@ -148,19 +120,13 @@ public class BlockCarvable extends Block implements ICarvable * Creates a SoundType with manual names for step, break and place * sounds. Sound names must be specified in the sounds.json * - * @param soundNameBreak - * block break sound - * @param soundNameStep - * block step sound - * @param soundNamePlace - * block place sound - * @param volume - * default 1.0f - * @param frequency - * default 1.0f + * @param soundNameBreak block break sound + * @param soundNameStep block step sound + * @param soundNamePlace block place sound + * @param volume default 1.0f + * @param frequency default 1.0f */ - public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) - { + public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) { super(soundNameStep, volume, frequency); this.soundNameStep = soundNameStep; this.soundNameBreak = soundNameBreak; @@ -168,27 +134,24 @@ public class BlockCarvable extends Block implements ICarvable } @Override - public String getBreakSound() - { - if(soundNameBreak == null) + public String getBreakSound() { + if (soundNameBreak == null) return Chisel.MOD_ID + ":dig." + this.soundName; else return this.soundNameBreak; } @Override - public String getStepResourcePath() - { - if(soundNameStep == null) + public String getStepResourcePath() { + if (soundNameStep == null) return Chisel.MOD_ID + ":step." + this.soundName; else return this.soundNameStep; } @Override - public String func_150496_b() - { - if(soundNamePlace == null) + public String func_150496_b() { + if (soundNamePlace == null) return getBreakSound(); else return this.soundNamePlace; diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvablePowered.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvablePowered.java index 7c91a75e..97864ce2 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvablePowered.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvablePowered.java @@ -3,11 +3,9 @@ package info.jbcs.minecraft.chisel.block; import net.minecraft.block.material.Material; import net.minecraft.world.IBlockAccess; -public class BlockCarvablePowered extends BlockCarvable -{ - public BlockCarvablePowered(Material m) - { - super(m, false); +public class BlockCarvablePowered extends BlockCarvable { + public BlockCarvablePowered(Material m) { + super(m); } /** @@ -15,8 +13,7 @@ public class BlockCarvablePowered extends BlockCarvable * change based on its state. */ @Override - public boolean canProvidePower() - { + public boolean canProvidePower() { return true; } @@ -28,8 +25,7 @@ public class BlockCarvablePowered extends BlockCarvable * when checking the bottom of the block. */ @Override - public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) - { + public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return 15; } diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockCloud.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockCloud.java index d99e56b8..131ce946 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockCloud.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockCloud.java @@ -11,70 +11,58 @@ import net.minecraft.world.World; import java.util.Random; -public class BlockCloud extends BlockCarvable -{ +public class BlockCloud extends BlockCarvable { - public BlockCloud() - { - super(Material.ice, false); + public BlockCloud() { + super(Material.ice); useNeighborBrightness = true; } @Override - public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) - { + public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { entity.fallDistance = 0.0F; - if(entity.motionY < 0.0D) - { + if (entity.motionY < 0.0D) { entity.motionY *= 0.0050000000000000001D; - } else if(entity.motionY > 0) - { + } else if (entity.motionY > 0) { entity.motionY += 0.0285; } } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public int getRenderBlockPass() - { + public int getRenderBlockPass() { return Configurations.ghostCloud ? 1 : 0; } @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) - { + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { return super.shouldSideBeRendered(iblockaccess, i, j, k, 1 - l); } @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) - { + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { return AxisAlignedBB.getBoundingBox(i + 0.2, j, k + 0.2, i + 0.8, j + 0.2, k + 0.8); } @Override - public Item getItemDropped(int par1, Random rand, int par3) - { + public Item getItemDropped(int par1, Random rand, int par3) { return Item.getItemFromBlock(this); } @Override - public int quantityDropped(Random rand) - { + public int quantityDropped(Random rand) { return 0; } @Override - public int damageDropped(int meta) - { + public int damageDropped(int meta) { return 0; } } diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockHolystone.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockHolystone.java index 2307bf73..03c78376 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockHolystone.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockHolystone.java @@ -9,27 +9,23 @@ import net.minecraft.world.World; import java.util.Random; -public class BlockHolystone extends BlockCarvable -{ +public class BlockHolystone extends BlockCarvable { public IIcon iconStar; - public BlockHolystone(Material m) - { - super(m, false); + public BlockHolystone(Material m) { + super(m); this.setLightLevel(0.25F); } @Override - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - if(General.rand.nextInt(4) == 0 && world.isRemote) + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + if (General.rand.nextInt(4) == 0 && world.isRemote) GeneralChiselClient.spawnHolystoneFX(world, this, x, y, z); } @Override - public void registerBlockIcons(IIconRegister register) - { + public void registerBlockIcons(IIconRegister register) { super.registerBlockIcons(register); iconStar = register.registerIcon("Chisel:holystone/particles/star"); diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockLeaf.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockLeaf.java new file mode 100644 index 00000000..d32db7ec --- /dev/null +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockLeaf.java @@ -0,0 +1,15 @@ +package info.jbcs.minecraft.chisel.block; + +import net.minecraft.block.material.Material; + +public class BlockLeaf extends BlockCarvable { + + public BlockLeaf(Material material) { + super(material); + } + + @Override + public boolean isOpaqueCube() { + return false; + } +} diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockLightstoneCarvable.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockLightstoneCarvable.java index 929039ec..a20afd1f 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockLightstoneCarvable.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockLightstoneCarvable.java @@ -7,28 +7,23 @@ import net.minecraft.item.Item; import java.util.Random; -public class BlockLightstoneCarvable extends BlockCarvable -{ - public BlockLightstoneCarvable() - { - super(Material.glass, false); +public class BlockLightstoneCarvable extends BlockCarvable { + public BlockLightstoneCarvable() { + super(Material.glass); } @Override - public int quantityDropped(Random random) - { + public int quantityDropped(Random random) { return Blocks.glowstone.quantityDropped(random); } @Override - public Item getItemDropped(int i, Random random, int a) - { + public Item getItemDropped(int i, Random random, int a) { return Items.glowstone_dust; } @Override - public int damageDropped(int i) - { + public int damageDropped(int i) { return 0; } } diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarbleLamp.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarbleLamp.java index 8d6ead98..ec01dca4 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarbleLamp.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarbleLamp.java @@ -1,7 +1,5 @@ package info.jbcs.minecraft.chisel.block; -import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; @@ -9,15 +7,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -public class BlockMarbleLamp extends BlockCarvable -{ +import java.util.Random; + +public class BlockMarbleLamp extends BlockCarvable { BlockMarbleLamp blockUnpowered; BlockMarbleLamp blockPowered; boolean powered; - public BlockMarbleLamp() - { - super(Material.redstoneLight, false); + public BlockMarbleLamp() { + super(Material.redstoneLight); powered = false; blockUnpowered = this; @@ -26,9 +24,8 @@ public class BlockMarbleLamp extends BlockCarvable setHardness(0.3F); } - public BlockMarbleLamp(BlockMarbleLamp unpoweredVersion) - { - super(Material.redstoneLight, false); + public BlockMarbleLamp(BlockMarbleLamp unpoweredVersion) { + super(Material.redstoneLight); carverHelper = unpoweredVersion.carverHelper; @@ -41,31 +38,26 @@ public class BlockMarbleLamp extends BlockCarvable } - public void checkPower(World world, int x, int y, int z) - { - if(world.isRemote) return; + public void checkPower(World world, int x, int y, int z) { + if (world.isRemote) return; boolean isGettingPower = world.isBlockIndirectlyGettingPowered(x, y, z); int meta = world.getBlockMetadata(x, y, z); - if(powered && !isGettingPower) - { + if (powered && !isGettingPower) { world.setBlock(x, y, z, blockUnpowered, meta, 2); - } else if(!powered && isGettingPower) - { + } else if (!powered && isGettingPower) { world.setBlock(x, y, z, blockPowered, meta, 2); } } @Override - public void onBlockAdded(World world, int x, int y, int z) - { + public void onBlockAdded(World world, int x, int y, int z) { checkPower(world, x, y, z); } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { checkPower(world, x, y, z); } @@ -81,14 +73,12 @@ public class BlockMarbleLamp extends BlockCarvable }*/ @Override - public Item getItemDropped(int par1, Random par2Random, int par3) - { + public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(blockUnpowered); } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) - { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z)); } diff --git a/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarblePillar.java b/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarblePillar.java index 4d991473..029fa4d5 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarblePillar.java +++ b/src/main/java/info/jbcs/minecraft/chisel/block/BlockMarblePillar.java @@ -6,39 +6,33 @@ import net.minecraft.block.material.Material; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class BlockMarblePillar extends BlockCarvable -{ +public class BlockMarblePillar extends BlockCarvable { public IIcon sides[] = new IIcon[6]; - public BlockMarblePillar(Material m) - { - super(m, false); + public BlockMarblePillar(Material m) { + super(m); } @Override - public int getRenderType() - { + public int getRenderType() { return BlockMarblePillarRenderer.id; } @Override - public IIcon getIcon(int side, int metadata) - { + public IIcon getIcon(int side, int metadata) { return sides[side]; } @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { return sides[side]; } - public IIcon getCtmIcon(int index, int metadata) - { + public IIcon getCtmIcon(int index, int metadata) { CarvableVariation var = carverHelper.variations.get(metadata); - if(index >= 4) return var.iconTop; - if(var.seamsCtmVert == null) return var.icon; + if (index >= 4) return var.iconTop; + if (var.seamsCtmVert == null) return var.icon; return var.seamsCtmVert.icons[index]; } diff --git a/src/main/java/info/jbcs/minecraft/chisel/init/ModBlocks.java b/src/main/java/info/jbcs/minecraft/chisel/init/ModBlocks.java index 02d332ce..934fe194 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/init/ModBlocks.java +++ b/src/main/java/info/jbcs/minecraft/chisel/init/ModBlocks.java @@ -675,7 +675,7 @@ public class ModBlocks { if(Configurations.featureEnabled("dirt")) { - dirt = (BlockCarvable) new BlockCarvable(Material.ground, false).setHardness(0.5F).setStepSound(Block.soundTypeGravel).setBlockName("dirt.default"); + dirt = (BlockCarvable) new BlockCarvable(Material.ground).setHardness(0.5F).setStepSound(Block.soundTypeGravel).setBlockName("dirt.default"); Carving.chisel.addVariation("dirt", Blocks.dirt, 0, 0); dirt.carverHelper.setChiselBlockName("Dirt"); //dirt.carverHelper.addVariation("Dirt", 0, Blocks.dirt); @@ -967,7 +967,7 @@ public class ModBlocks { if(Configurations.featureEnabled("carpet")) { - carpet = (BlockCarvable) new BlockCarvable(Material.cloth, false).setHardness(2.0F).setResistance(10F).setStepSound(Block.soundTypeCloth); + carpet = (BlockCarvable) new BlockCarvable(Material.cloth).setHardness(2.0F).setResistance(10F).setStepSound(Block.soundTypeCloth); carpet.carverHelper.setChiselBlockName("Carpet Block"); carpet.carverHelper.addVariation(StatCollector.translateToLocal("tile.carpet_block.0.desc"), 0, "carpet/white"); carpet.carverHelper.addVariation(StatCollector.translateToLocal("tile.carpet_block.1.desc"), 1, "carpet/orange"); @@ -1045,7 +1045,7 @@ public class ModBlocks { if(Configurations.featureEnabled("futuristicArmorPlating")) { - tyrian = (BlockCarvable) new BlockCarvable(Material.iron, false).setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal); + tyrian = (BlockCarvable) new BlockCarvable(Material.iron).setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal); tyrian.carverHelper.setChiselBlockName("Futuristic Armor Plating Block"); tyrian.carverHelper.addVariation(StatCollector.translateToLocal("tile.tyrian.0.desc"), 0, "tyrian/shining"); tyrian.carverHelper.addVariation(StatCollector.translateToLocal("tile.tyrian.1.desc"), 1, "tyrian/tyrian"); @@ -1280,7 +1280,7 @@ public class ModBlocks { } if(Configurations.featureEnabled("leaves")){ - leaf = (BlockCarvable) new BlockCarvable(Material.leaves, false).setHardness(0.2F).setStepSound(Block.soundTypeGrass); + leaf = (BlockLeaf) new BlockLeaf(Material.leaves).setHardness(0.2F).setStepSound(Block.soundTypeGrass); Carving.chisel.addVariation("leaves", Blocks.leaves, 0, 0); Carving.chisel.addVariation("leaves", Blocks.leaves, 1, 0); Carving.chisel.addVariation("leaves", Blocks.leaves, 2, 0);