Skip to content

Commit

Permalink
Add cloth block base
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jun 10, 2024
1 parent cee728d commit 84e39ac
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 43 deletions.
26 changes: 26 additions & 0 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBlockCloth.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package mod.emt.harkenscythe.blocks;

import mod.emt.harkenscythe.init.HSBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class HSBlockCloth extends Block
{
public HSBlockCloth(MapColor mapColor)
{
super(Material.CLOTH, mapColor);
this.setHardness(0.8F);
this.setSoundType(SoundType.CLOTH);
}

@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
return this == HSBlocks.bloodweave_cloth || this == HSBlocks.soulweave_cloth;
}
}
58 changes: 28 additions & 30 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBlockCreep.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package mod.emt.harkenscythe.blocks;

import java.util.Random;

import javax.annotation.Nullable;

import mod.emt.harkenscythe.init.HSBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
Expand All @@ -27,16 +25,23 @@
public class HSBlockCreep extends Block
{
protected static final AxisAlignedBB CREEP_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D);

public HSBlockCreep()
{
super(Material.GRASS, MapColor.RED);
this.setHardness(0.6F);
this.setHardness(0.6F);
this.setHarvestLevel("shovel", 0);
this.setSoundType(SoundType.PLANT);
this.setSoundType(SoundType.PLANT);
this.setTickRandomly(true);
}


@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess world, BlockPos pos)
{
return CREEP_AABB;
}

// TODO: Creep blocks should only spread in the Nether, also see whether or not this properly works in that dimension
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
Expand All @@ -47,7 +52,8 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
if (this == HSBlocks.creep_block) worldIn.setBlockState(pos, Blocks.SOUL_SAND.getDefaultState());
} else
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
Expand All @@ -72,21 +78,7 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra
}
}
}

@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess world, BlockPos pos)
{
return CREEP_AABB;
}

@Override
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entity)
{
entity.motionX *= 0.4D;
entity.motionZ *= 0.4D;
}


// TODO: Fancier particles? Maybe little red particles?
@Override
@SideOnly(Side.CLIENT)
Expand All @@ -96,20 +88,26 @@ public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos,

if (rand.nextInt(10) == 0)
{
worldIn.spawnParticle(EnumParticleTypes.TOWN_AURA, (double)((float)pos.getX() + rand.nextFloat()), (double)((float)pos.getY() + 1.1F), (double)((float)pos.getZ() + rand.nextFloat()), 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.TOWN_AURA, (float) pos.getX() + rand.nextFloat(), (float) pos.getY() + 1.1F, (float) pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Blocks.SOUL_SAND.getItemDropped(Blocks.SOUL_SAND.getDefaultState(), rand, fortune);
return Blocks.SOUL_SAND.getItemDropped(Blocks.SOUL_SAND.getDefaultState(), rand, fortune);
}


@Override
@Override
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entity)
{
entity.motionX *= 0.4D;
entity.motionZ *= 0.4D;
}

@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
return true;
}
{
return true;
}
}
25 changes: 14 additions & 11 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBlockMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ public class HSBlockMaterial extends Block
public HSBlockMaterial(Material material, MapColor mapColor, float hardness, float resistance, SoundType soundType)
{
super(material, mapColor);
this.setHardness(hardness);
this.setResistance(resistance);
this.setSoundType(soundType);
this.setHardness(hardness);
this.setResistance(resistance);
this.setSoundType(soundType);
}

@Override

public HSBlockMaterial(Material material, MapColor mapColor, float hardness, SoundType soundType)
{
super(material, mapColor);
this.setHardness(hardness);
this.setSoundType(soundType);
}

@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
if (this == HSBlocks.biomass_block) {
return true;
}

return false;
{
return this == HSBlocks.biomass_block;
}
}
12 changes: 10 additions & 2 deletions src/main/java/mod/emt/harkenscythe/init/HSBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.annotation.Nonnull;
import mod.emt.harkenscythe.HarkenScythe;
import mod.emt.harkenscythe.blocks.HSBlockCloth;
import mod.emt.harkenscythe.blocks.HSBlockCreep;
import mod.emt.harkenscythe.blocks.HSBlockMaterial;
import mod.emt.harkenscythe.blocks.HSBloodCrucible;
Expand All @@ -27,10 +28,15 @@ public class HSBlocks
public static HSBlockMaterial biomass_block;
@GameRegistry.ObjectHolder("livingmetal_block")
public static HSBlockMaterial livingmetal_block;

@GameRegistry.ObjectHolder("creep_block")
public static HSBlockCreep creep_block;


@GameRegistry.ObjectHolder("bloodweave_cloth")
public static HSBlockCloth bloodweave_cloth;
@GameRegistry.ObjectHolder("soulweave_cloth")
public static HSBlockCloth soulweave_cloth;

@GameRegistry.ObjectHolder("blood_crucible")
public static HSBloodCrucible blood_crucible;
@GameRegistry.ObjectHolder("soul_crucible")
Expand All @@ -52,6 +58,8 @@ public static void onRegisterBlocksEvent(@Nonnull final RegistryEvent.Register<B
HSRegistry.setup(new HSBlockMaterial(Material.ROCK, MapColor.NETHERRACK, 5.0F, 5.0F, SoundType.STONE), "biomass_block").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSBlockMaterial(Material.IRON, MapColor.DIAMOND, 5.0F, 10.0F, SoundType.METAL), "livingmetal_block").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSBlockCreep(), "creep_block").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSBlockCloth(MapColor.DIAMOND), "bloodweave_cloth").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSBlockCloth(MapColor.DIAMOND), "soulweave_cloth").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSBloodCrucible(), "blood_crucible").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSSoulCrucible(), "soul_crucible").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSSoulAltar(), "soul_altar").setCreativeTab(HarkenScythe.TAB),
Expand Down

0 comments on commit 84e39ac

Please sign in to comment.