Skip to content
Permalink
Browse files

Rock variants have different hardness and resistance based on it's ca…

…tegory, Closes #396.
  • Loading branch information
DisasterMoo committed Sep 11, 2019
1 parent c13a1d6 commit 469f80ef99eec332c7a416682e365b7982557bfa
@@ -25,6 +25,8 @@
private final boolean layer2;
private final boolean layer3;
private final boolean hasAnvil;
private final float hardness;
private final float resistance;

/**
* A rock category.
@@ -33,9 +35,11 @@
* @param toolMaterial The tool material used for stone tools made of this rock
* @param caveGenMod a modifier for cave generation. Default 0, range -0.5 <> 0.5
* @param caveFreqMod another modifier for cave generation. Default 0, sedimentary uses +5
* @param hardness How hard this type is (how slower is to break blocks)
* @param resistance How resistant to explosion this type is
* @param hasAnvil if this rock should be able to create a stone anvil
*/
public RockCategory(@Nonnull ResourceLocation name, @Nonnull Item.ToolMaterial toolMaterial, boolean layer1, boolean layer2, boolean layer3, float caveGenMod, float caveFreqMod, boolean hasAnvil)
public RockCategory(@Nonnull ResourceLocation name, @Nonnull Item.ToolMaterial toolMaterial, boolean layer1, boolean layer2, boolean layer3, float caveGenMod, float caveFreqMod, float hardness, float resistance, boolean hasAnvil)
{
setRegistryName(name);
this.toolMaterial = toolMaterial;
@@ -45,6 +49,8 @@ public RockCategory(@Nonnull ResourceLocation name, @Nonnull Item.ToolMaterial t
this.layer2 = layer2;
this.layer3 = layer3;
this.hasAnvil = hasAnvil;
this.hardness = hardness;
this.resistance = resistance;
}

@Nonnull
@@ -63,6 +69,16 @@ public float getCaveFreqMod()
return caveFreqMod;
}

public float getHardness()
{
return hardness;
}

public float getResistance()
{
return resistance;
}

public boolean hasAnvil()
{
return hasAnvil;
@@ -109,38 +109,38 @@ public BlockRockVariant(Rock.Type type, Rock rock)
case RAW:
case SPIKE:
setSoundType(SoundType.STONE);
setHardness(2.0F).setResistance(10.0F);
setHardness(rock.getRockCategory().getHardness()).setResistance(rock.getRockCategory().getResistance());
setHarvestLevel("pickaxe", 0);
break;
case COBBLE:
case SMOOTH:
setSoundType(SoundType.STONE);
setHardness(1.5F).setResistance(10.0F);
setHardness(rock.getRockCategory().getHardness() * 0.75F).setResistance(rock.getRockCategory().getResistance());
setHarvestLevel("pickaxe", 0);
break;
case SAND:
setSoundType(SoundType.SAND);
setHardness(0.7F);
setHardness(rock.getRockCategory().getHardness() * 0.05F);
setHarvestLevel("shovel", 0);
break;
case DIRT:
case PATH:
case FARMLAND:
setSoundType(SoundType.GROUND);
setHardness(1.0F);
setHardness(rock.getRockCategory().getHardness() * 0.15F);
setHarvestLevel("shovel", 0);
break;
case GRAVEL:
case CLAY:
setSoundType(SoundType.GROUND);
setHardness(0.8F);
setHardness(rock.getRockCategory().getHardness() * 0.2F);
setHarvestLevel("shovel", 0);
break;
case CLAY_GRASS:
case GRASS:
case DRY_GRASS:
setSoundType(SoundType.PLANT);
setHardness(1.1F);
setHardness(rock.getRockCategory().getHardness() * 0.2F);
setHarvestLevel("shovel", 0);
break;
}
@@ -52,10 +52,10 @@
public static void onPreRegisterRockCategory(TFCRegistryEvent.RegisterPreBlock<RockCategory> event)
{
event.getRegistry().registerAll(
new RockCategory(IGNEOUS_INTRUSIVE, ToolMaterialsTFC.IGNEOUS_INTRUSIVE, true, true, true, -0.4f, 0f, true),
new RockCategory(IGNEOUS_EXTRUSIVE, ToolMaterialsTFC.IGNEOUS_EXTRUSIVE, true, true, true, -0.5f, 0f, true),
new RockCategory(SEDIMENTARY, ToolMaterialsTFC.SEDIMENTARY, true, false, false, 0.3f, 5f, false),
new RockCategory(METAMORPHIC, ToolMaterialsTFC.METAMORPHIC, true, true, false, 0.2f, 0f, false)
new RockCategory(IGNEOUS_INTRUSIVE, ToolMaterialsTFC.IGNEOUS_INTRUSIVE, true, true, true, -0.4f, 0f, 16F, 10F, true),
new RockCategory(IGNEOUS_EXTRUSIVE, ToolMaterialsTFC.IGNEOUS_EXTRUSIVE, true, true, true, -0.5f, 0f, 16F, 10F, true),
new RockCategory(SEDIMENTARY, ToolMaterialsTFC.SEDIMENTARY, true, false, false, 0.3f, 5f, 14F, 10F, false),
new RockCategory(METAMORPHIC, ToolMaterialsTFC.METAMORPHIC, true, true, false, 0.2f, 0f, 15F, 10F, false)
);
}

0 comments on commit 469f80e

Please sign in to comment.
You can’t perform that action at this time.