Skip to content

Commit

Permalink
Added Stalactites and Stalagmites
Browse files Browse the repository at this point in the history
  • Loading branch information
DisasterMoo committed Aug 23, 2019
1 parent 13f918f commit c1c054d
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 2 deletions.
10 changes: 9 additions & 1 deletion generateResources.py
Expand Up @@ -722,6 +722,15 @@ def item(filename_parts, *layers, parent='item/generated'):
'west': {'true': {'submodel': 'wall_side', 'y': 270}, 'false': {}},
'up': {'true': {'submodel': 'wall_post', 'y': 270}, 'false': {}}
})

# SPIKES (stalactite and stalagmite)
blockstate(('spike', rock_type), 'tfc:spike/top', textures={
('texture', 'particle'): 'tfc:blocks/stonetypes/raw/%s' % rock_type,
}, variants={
'normal': None,
'ceiling': {'true': {'x': 180}, 'false': {}},
'base': {'true': {'model': 'tfc:spike/base'}, 'false': {}}
})

# (ROCK) STAIRS & SLABS
for block_type in ['smooth', 'cobble', 'bricks']:
Expand Down Expand Up @@ -1087,7 +1096,6 @@ def item(filename_parts, *layers, parent='item/generated'):
item(('ceramics', 'unfired', 'fire_brick'), 'tfc:items/ceramics/unfired/fire_brick')
item(('ceramics', 'fired', 'fire_brick'), 'tfc:items/ceramics/fired/fire_brick')
item(('ceramics', 'unfired', 'jug'), 'tfc:items/ceramics/unfired/jug')
item(('ceramics', 'fired', 'jug'), 'tfc:items/ceramics/fired/jug')

item(('ceramics', 'fire_clay'), 'tfc:items/ceramics/fire_clay')

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/dries007/tfc/api/types/Rock.java
Expand Up @@ -114,6 +114,7 @@ public String[] getPattern()
public enum Type
{
RAW(Material.ROCK, FALL_VERTICAL, false, BlockRockRaw::new),
SPIKE(Material.ROCK, NO_FALL, false, BlockRockSpike::new),
SMOOTH(Material.ROCK, NO_FALL, false),
COBBLE(Material.ROCK, FALL_HORIZONTAL, false),
BRICKS(Material.ROCK, NO_FALL, false),
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java
Expand Up @@ -333,9 +333,13 @@ public static void registerBlocks(RegistryEvent.Register<Block> event)
allBlockRockVariants.forEach(x ->
{
if (x.getType() == Rock.Type.SAND)
{
normalItemBlocks.add(new ItemBlockHeat(x, 1, 600));
else
}
else if (x.getType() != Rock.Type.SPIKE)
{
normalItemBlocks.add(new ItemBlockTFC(x));
}
});
}

Expand Down
@@ -0,0 +1,98 @@
/*
* Work under Copyright. Licensed under the EUPL.
* See the project README.md and LICENSE.txt for more information.
*/

package net.dries007.tfc.objects.blocks.stone;

import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.block.Block;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import mcp.MethodsReturnNonnullByDefault;
import net.dries007.tfc.api.types.Rock;

/**
* Stalactites and stalagmites in one block!
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class BlockRockSpike extends BlockRockVariant
{
public static final PropertyBool CEILING = PropertyBool.create("ceiling"); //If this comes from ceiling
public static final PropertyBool BASE = PropertyBool.create("base"); //If this block is the base

public BlockRockSpike(Rock.Type type, Rock rock)
{
super(type, rock);
}

@SuppressWarnings("deprecation")
@Override
public IBlockState getStateFromMeta(int meta)
{
return getDefaultState().withProperty(CEILING, meta % 2 == 1).withProperty(BASE, meta >= 2);
}

@Override
public int getMetaFromState(IBlockState state)
{
return (state.getValue(CEILING) ? 1 : 0) + (state.getValue(BASE) ? 2 : 0);
}

@Override
@SuppressWarnings("deprecation")
public boolean isFullCube(IBlockState state)
{
return false;
}

@Override
@SuppressWarnings("deprecation")
public boolean isOpaqueCube(IBlockState state)
{
return false;
}

@SuppressWarnings("deprecation")
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
boolean toUp = true;
if (state.getValue(CEILING))
{
toUp = false;
}
if (!state.getValue(BASE))
{
toUp = !toUp;
}
BlockPos otherPart = toUp ? pos.up() : pos.down();
if (otherPart.equals(fromPos))
{
worldIn.destroyBlock(pos, false);
}
else if (state.getValue(BASE) && worldIn.isAirBlock(toUp ? pos.down() : pos.up()))
{
worldIn.destroyBlock(pos, false);
worldIn.destroyBlock(otherPart, false);
}
}

@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, CEILING, BASE);
}

@Override
public int damageDropped(IBlockState state)
{
return 0;
}
}
Expand Up @@ -62,6 +62,8 @@ public static BlockRockVariant create(Rock rock, Rock.Type type)
{
case RAW:
return new BlockRockRaw(type, rock);
case SPIKE:
return new BlockRockSpike(type, rock);
case FARMLAND:
return new BlockFarmlandTFC(type, rock);
case PATH:
Expand Down Expand Up @@ -101,6 +103,7 @@ public BlockRockVariant(Rock.Type type, Rock rock)
{
case BRICKS:
case RAW:
case SPIKE:
setSoundType(SoundType.STONE);
setHardness(2.0F).setResistance(10.0F);
setHarvestLevel("pickaxe", 0);
Expand Down Expand Up @@ -200,6 +203,7 @@ public Item getItemDropped(IBlockState state, Random rand, int fortune)
switch (type)
{
case RAW:
case SPIKE:
return ItemRock.get(rock);
case CLAY:
case CLAY_GRASS:
Expand Down Expand Up @@ -235,6 +239,7 @@ public int quantityDropped(IBlockState state, int fortune, Random random)
case CLAY_GRASS:
return 4;
case RAW:
case SPIKE:
return 1 + random.nextInt(3);
default:
return super.quantityDropped(state, fortune, random);
Expand Down
Expand Up @@ -17,6 +17,9 @@
import net.dries007.tfc.api.registries.TFCRegistries;
import net.dries007.tfc.api.types.Rock;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.stone.BlockRockRaw;
import net.dries007.tfc.objects.blocks.stone.BlockRockSpike;
import net.dries007.tfc.objects.blocks.stone.BlockRockVariant;
import net.dries007.tfc.world.classic.DataLayer;

import static net.dries007.tfc.world.classic.ChunkGenTFC.AIR;
Expand Down Expand Up @@ -225,6 +228,35 @@ protected void generateCaveNode(long seed, int chunkX, int chunkZ, ChunkPrimer p
{
primer.setBlockState(xCoord, y - 1, zCoord, grass);
}
//================ Cave Decoration ===============
//Stalactites & Stalagmites
//Check for previously placed spikes and remove them. (as sometimes a cave nodes can cross one another)
if (primer.getBlockState(xCoord, y + 1, zCoord).getBlock() instanceof BlockRockSpike)
{
primer.setBlockState(xCoord, y + 1, zCoord, AIR);
primer.setBlockState(xCoord, y + 2, zCoord, AIR);
}
if (primer.getBlockState(xCoord, y - 1, zCoord).getBlock() instanceof BlockRockSpike)
{
primer.setBlockState(xCoord, y - 1, zCoord, AIR);
primer.setBlockState(xCoord, y - 2, zCoord, AIR);
}
//Place the spikes
if (primer.getBlockState(xCoord, y + 1, zCoord) == AIR && primer.getBlockState(xCoord, y + 2, zCoord) == AIR)
{
if (primer.getBlockState(xCoord, y + 3, zCoord).getBlock() instanceof BlockRockRaw && rng.nextDouble() < 0.5D)
{
BlockRockRaw rockBlock = (BlockRockRaw) primer.getBlockState(xCoord, y + 3, zCoord).getBlock();
primer.setBlockState(xCoord, y + 2, zCoord, BlockRockVariant.get(rockBlock.getRock(), Rock.Type.SPIKE).getDefaultState().withProperty(BlockRockSpike.BASE, true).withProperty(BlockRockSpike.CEILING, true));
primer.setBlockState(xCoord, y + 1, zCoord, BlockRockVariant.get(rockBlock.getRock(), Rock.Type.SPIKE).getDefaultState().withProperty(BlockRockSpike.BASE, false).withProperty(BlockRockSpike.CEILING, true));
}
else if (primer.getBlockState(xCoord, y - 1, zCoord).getBlock() instanceof BlockRockRaw && rng.nextDouble() < 0.5D)
{
BlockRockRaw rockBlock = (BlockRockRaw) primer.getBlockState(xCoord, y - 1, zCoord).getBlock();
primer.setBlockState(xCoord, y, zCoord, BlockRockVariant.get(rockBlock.getRock(), Rock.Type.SPIKE).getDefaultState().withProperty(BlockRockSpike.BASE, true).withProperty(BlockRockSpike.CEILING, false));
primer.setBlockState(xCoord, y + 1, zCoord, BlockRockVariant.get(rockBlock.getRock(), Rock.Type.SPIKE).getDefaultState().withProperty(BlockRockSpike.BASE, false).withProperty(BlockRockSpike.CEILING, false));
}
}
}
}
}
Expand Down

0 comments on commit c1c054d

Please sign in to comment.