Skip to content

Commit

Permalink
Add more blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Jun 10, 2024
1 parent 7ce1f1a commit cee728d
Show file tree
Hide file tree
Showing 20 changed files with 218 additions and 307 deletions.
115 changes: 115 additions & 0 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBlockCreep.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

// TODO: Creep blocks are tillable with glaives and can be filled with blood
// Using creepballs on soul sand will also create creep blocks
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.setHarvestLevel("shovel", 0);
this.setSoundType(SoundType.PLANT);
this.setTickRandomly(true);
}

// 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)
{
if (!worldIn.isRemote)
{
if (!worldIn.isAreaLoaded(pos, 3)) return;
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
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);

if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}

IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);

if (iblockstate1.getBlock() == Blocks.SOUL_SAND && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
{
worldIn.setBlockState(blockpos, HSBlocks.creep_block.getDefaultState());
}
}
}
}
}
}

@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)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
super.randomDisplayTick(stateIn, worldIn, pos, rand);

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);
}
}

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


@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
return true;
}
}
31 changes: 31 additions & 0 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBlockMaterial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 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);
}

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

return false;
}
}
16 changes: 16 additions & 0 deletions src/main/java/mod/emt/harkenscythe/init/HSBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import javax.annotation.Nonnull;
import mod.emt.harkenscythe.HarkenScythe;
import mod.emt.harkenscythe.blocks.HSBlockCreep;
import mod.emt.harkenscythe.blocks.HSBlockMaterial;
import mod.emt.harkenscythe.blocks.HSBloodCrucible;
import mod.emt.harkenscythe.blocks.HSSoulAltar;
import mod.emt.harkenscythe.blocks.HSSoulCake;
import mod.emt.harkenscythe.blocks.HSSoulCrucible;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -18,6 +23,14 @@
@GameRegistry.ObjectHolder(HarkenScythe.MOD_ID)
public class HSBlocks
{
@GameRegistry.ObjectHolder("biomass_block")
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("blood_crucible")
public static HSBloodCrucible blood_crucible;
@GameRegistry.ObjectHolder("soul_crucible")
Expand All @@ -36,6 +49,9 @@ public static void onRegisterBlocksEvent(@Nonnull final RegistryEvent.Register<B
// BLOCKS
registry.registerAll
(
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 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"forge_marker": 1,
"defaults": {
"model": "cube_all",
"textures": {
"all": "harkenscythe:blocks/block_biomass"
}
},
"variants": {
"normal": [
{}
],
"inventory": [
{}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"forge_marker": 1,
"defaults": {
"model": "cube_bottom_top",
"textures": {
"bottom": "blocks/soul_sand",
"top": "harkenscythe:blocks/block_creep_top",
"side": "harkenscythe:blocks/block_creep_side"
}
},
"variants": {
"normal": [
{}
],
"inventory": [
{}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"forge_marker": 1,
"defaults": {
"model": "cube_all",
"textures": {
"all": "harkenscythe:blocks/block_livingmetal"
}
},
"variants": {
"normal": [
{}
],
"inventory": [
{}
]
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/harkenscythe/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ itemGroup.harkenscythe.tab=Harken Scythe

# BLOCKS
tile.harkenscythe.blood_crucible.name=Blood Crucible
tile.harkenscythe.biomass_block.name=Biomass Block
tile.harkenscythe.creep_block.name=Creep Block
tile.harkenscythe.livingmetal_block.name=Block of Livingmetal
tile.harkenscythe.soul_cake.name=Cake of Souls
tile.harkenscythe.soul_crucible.name=Soul Crucible
tile.harkenscythe.soul_altar.name=Altar of Souls
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit cee728d

Please sign in to comment.