Skip to content

Commit

Permalink
Merge pull request #501 from Wmaxlees/master
Browse files Browse the repository at this point in the history
Allow Deepslate Hardness to be configured in the blocks config.
  • Loading branch information
Roadhog360 authored Aug 9, 2024
2 parents 8169c89 + 85575b9 commit 6a85865
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
18 changes: 9 additions & 9 deletions src/main/java/ganymedes01/etfuturum/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ public enum ModBlocks {
LIGHTNING_ROD(ConfigExperiments.enableLightningRod, new BlockLightningRod()),
DEEPSLATE(ConfigBlocksItems.enableDeepslate, new BlockDeepslate()),
COBBLED_DEEPSLATE(ConfigBlocksItems.enableDeepslate, new BaseBlock(Material.rock).setNames("cobbled_deepslate")
.setBlockSound(ModSounds.soundDeepslate).setHardness(3.5F).setResistance(6).setCreativeTab(EtFuturum.creativeTabBlocks)),
.setBlockSound(ModSounds.soundDeepslate).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6).setCreativeTab(EtFuturum.creativeTabBlocks)),
POLISHED_DEEPSLATE(ConfigBlocksItems.enableDeepslate, new BaseBlock(Material.rock).setNames("polished_deepslate")
.setBlockSound(ModSounds.soundDeepslate).setHardness(3.5F).setResistance(6).setCreativeTab(EtFuturum.creativeTabBlocks)),
.setBlockSound(ModSounds.soundDeepslate).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6).setCreativeTab(EtFuturum.creativeTabBlocks)),
DEEPSLATE_BRICKS(ConfigBlocksItems.enableDeepslate, new BaseSubtypesBlock(Material.rock,
"deepslate_bricks", "cracked_deepslate_bricks", "deepslate_tiles", "cracked_deepslate_tiles", "chiseled_deepslate").setNames("deepslate_bricks")
.setBlockSound(ModSounds.soundDeepslateBricks).setHardness(3.5F).setResistance(6)),
.setBlockSound(ModSounds.soundDeepslateBricks).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 3.0f : 3.5f).setResistance(6)),
TUFF(ConfigBlocksItems.enableTuff, new BlockTuff()),
RAW_ORE_BLOCK(ConfigBlocksItems.enableRawOres, new BlockRawOre()),
BASALT(ConfigBlocksItems.enableBasalt, new BlockBasalt()),
Expand Down Expand Up @@ -176,13 +176,13 @@ public enum ModBlocks {
.setResistance(9).setHardness(3.0F),
BaseSlabItemBlock.class),
DEEPSLATE_SLAB(ConfigBlocksItems.enableDeepslate, new BaseSlab(false, Material.rock, "cobbled_deepslate", "polished_deepslate").setNames("deepslate_slab")
.setBlockSound(ModSounds.soundDeepslate).setHardness(3.5F).setResistance(6)),
.setBlockSound(ModSounds.soundDeepslate).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6)),
DOUBLE_DEEPSLATE_SLAB(ConfigBlocksItems.enableDeepslate, new BaseSlab(true, Material.rock, "cobbled_deepslate", "polished_deepslate").setNames("deepslate_slab")
.setBlockSound(ModSounds.soundDeepslate).setHardness(3.5F).setResistance(6)),
.setBlockSound(ModSounds.soundDeepslate).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6)),
DEEPSLATE_BRICK_SLAB(ConfigBlocksItems.enableDeepslate, new BaseSlab(false, Material.rock, "deepslate_bricks", "deepslate_tiles")
.setBlockSound(ModSounds.soundDeepslateBricks).setHardness(3.5F).setResistance(6)),
.setBlockSound(ModSounds.soundDeepslateBricks).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6)),
DOUBLE_DEEPSLATE_BRICK_SLAB(ConfigBlocksItems.enableDeepslate, new BaseSlab(true, Material.rock, "deepslate_bricks", "deepslate_tiles")
.setBlockSound(ModSounds.soundDeepslateBricks).setHardness(3.5F).setResistance(6)),
.setBlockSound(ModSounds.soundDeepslateBricks).setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6)),
TUFF_SLAB(ConfigBlocksItems.enableDeepslate, new BaseSlab(false, Material.rock, "tuff", "polished_tuff", "tuff_bricks")
.setBlockSound(ModSounds.soundTuff).setHardness(1.5F).setResistance(6)),
DOUBLE_TUFF_SLAB(ConfigBlocksItems.enableDeepslate, new BaseSlab(true, Material.rock, "tuff", "polished_tuff", "tuff_bricks")
Expand Down Expand Up @@ -249,9 +249,9 @@ public enum ModBlocks {
END_BRICK_WALL(ConfigBlocksItems.enableChorusFruit, new BaseWall(Material.rock, "end_bricks")
.setHardness(3.0F).setResistance(9.0F)),
DEEPSLATE_WALL(ConfigBlocksItems.enableDeepslate, new BaseWall(Material.rock, "cobbled_deepslate", "polished_deepslate")
.setHardness(3.5F).setResistance(6.0F)),
.setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 2.0f : 3.5f).setResistance(6.0F)),
DEEPSLATE_BRICK_WALL(ConfigBlocksItems.enableDeepslate, new BaseWall(Material.rock, "deepslate_bricks", "deepslate_tiles")
.setHardness(3.5F).setResistance(6.0F)),
.setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 1.5f : 3.5f).setResistance(6.0F)),
TUFF_WALL(ConfigBlocksItems.enableTuff, new BaseWall(Material.rock, "tuff", "polished_tuff", "tuff_bricks")
.setBlockSound(ModSounds.soundTuff).setHardness(1.5F).setResistance(6.0F)),
MUD_BRICK_WALL(ConfigBlocksItems.enableMud, new BaseWall(Material.rock, "mud_bricks").setBlockSound(ModSounds.soundMudBricks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.ModBlocks;
import ganymedes01.etfuturum.client.sound.ModSounds;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.world.EtFuturumLateWorldGenerator;
import net.minecraft.block.Block;
Expand All @@ -27,7 +28,7 @@ public class BlockDeepslate extends BlockRotatedPillar {

public BlockDeepslate() {
super(Material.rock);
this.setHardness(3);
this.setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 1.5f : 3.0f);
this.setResistance(6);
this.setBlockName(Utils.getUnlocalisedName("deepslate"));
this.setBlockTextureName("deepslate");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ganymedes01.etfuturum.api.mappings.RegistryMapping;
import ganymedes01.etfuturum.blocks.BaseBlock;
import ganymedes01.etfuturum.client.sound.ModSounds;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.core.utils.DummyWorld;
import ganymedes01.etfuturum.core.utils.IInitAction;
import ganymedes01.etfuturum.lib.Reference;
Expand Down Expand Up @@ -261,11 +262,11 @@ public void onLoadAction() {
if (block.getHarvestTool(getBaseMeta()) != null) {
setHarvestLevel("pickaxe", block.getHarvestLevel(getBaseMeta()));
}
blockHardness = block.getBlockHardness(world, 0, 0, 0) * 1.5F;
blockHardness = ConfigFunctions.useStoneHardnessForDeepslate ? block.getBlockHardness(world, 0, 0, 0) : block.getBlockHardness(world, 0, 0, 0) * 1.5F;
blockResistance = block.getExplosionResistance(null, world, 0, 0, 0, 0, 0, 0) * 5; //Because the game divides it by 5 for some reason
} catch (Exception e) {
setHarvestLevel("pickaxe", 1);
blockHardness = Blocks.iron_ore.blockHardness * 1.5F;
blockHardness = ConfigFunctions.useStoneHardnessForDeepslate ? Blocks.iron_ore.blockHardness : Blocks.iron_ore.blockHardness * 1.5F;
blockResistance = Blocks.iron_ore.blockResistance;
}
world.clearBlocksCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ganymedes01.etfuturum.api.mappings.RegistryMapping;
import ganymedes01.etfuturum.blocks.BaseSubtypesBlock;
import ganymedes01.etfuturum.client.sound.ModSounds;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.core.utils.DummyWorld;
import ganymedes01.etfuturum.core.utils.IInitAction;
import ganymedes01.etfuturum.lib.Reference;
Expand Down Expand Up @@ -257,11 +258,11 @@ public void onLoadAction() {
if (block.getHarvestTool(getBaseMeta(i)) != null) {
setHarvestLevel("pickaxe", block.getHarvestLevel(getBaseMeta(i)), i);
}
setHardnessValues(block.getBlockHardness(world, 0, 0, 0) * 1.5F, i);
setHardnessValues(ConfigFunctions.useStoneHardnessForDeepslate ? block.getBlockHardness(world, 0, 0, 0) : block.getBlockHardness(world, 0, 0, 0) * 1.5F, i);
setResistanceValues(block.getExplosionResistance(null, world, 0, 0, 0, 0, 0, 0), i);
} catch (Exception e) {
setHarvestLevel("pickaxe", 1, i);
setHardnessValues(Blocks.iron_ore.blockHardness * 1.5F, i);
setHardnessValues(ConfigFunctions.useStoneHardnessForDeepslate ? Blocks.iron_ore.blockHardness : Blocks.iron_ore.blockHardness * 1.5F, i);
setResistanceValues(Blocks.iron_ore.blockResistance, i);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ganymedes01.etfuturum.blocks.ores;

import ganymedes01.etfuturum.ModBlocks;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.core.utils.DummyWorld;
import ganymedes01.etfuturum.core.utils.IInitAction;
import ganymedes01.etfuturum.core.utils.Utils;
Expand Down Expand Up @@ -28,11 +29,12 @@ public void onLoadAction() {
if (block.getHarvestTool(stack.getItemDamage()) != null) {
setHarvestLevel("pickaxe", block.getHarvestLevel(stack.getItemDamage()));
}
blockHardness = block.getBlockHardness(world, 0, 0, 0) * 1.5F;
blockHardness = ConfigFunctions.useStoneHardnessForDeepslate ? block.getBlockHardness(world, 0, 0, 0) : block.getBlockHardness(world, 0, 0, 0) * 1.5F;
blockResistance = block.getExplosionResistance(null, world, 0, 0, 0, 0, 0, 0); //Because the game divides it by 5 for some reason
} catch (Exception ignored) {
setHarvestLevel("pickaxe", 1);
blockHardness = ModBlocks.COPPER_ORE.get().blockHardness * 1.5F;

blockHardness = ConfigFunctions.useStoneHardnessForDeepslate ? ModBlocks.COPPER_ORE.get().blockHardness : ModBlocks.COPPER_ORE.get().blockHardness * 1.5F;
blockResistance = ModBlocks.COPPER_ORE.get().blockResistance;
}
world.clearBlocksCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ganymedes01.etfuturum.api.DeepslateOreRegistry;
import ganymedes01.etfuturum.client.sound.ModSounds;
import ganymedes01.etfuturum.configuration.configs.ConfigBlocksItems;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.core.utils.Utils;
import net.minecraft.block.Block;

Expand Down Expand Up @@ -45,13 +46,13 @@ public BlockDeepslateOre(Block block) {
@Deprecated
public static void setAttribs(Block to, Block from) {
Utils.copyAttribs(to, from);
to.setHardness(from.blockHardness * 1.5F);
to.setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? from.blockHardness : from.blockHardness * 1.5F);
Utils.setBlockSound(to, ModSounds.soundDeepslate);
}

protected void copyAttribs(Block from) {
Utils.copyAttribs(this, from);
setHardness(from.blockHardness * 1.5F);
setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? from.blockHardness : from.blockHardness * 1.5F);
}

protected void addDeepslateMappings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cpw.mods.fml.relauncher.SideOnly;
import ganymedes01.etfuturum.blocks.BaseSubtypesBlock;
import ganymedes01.etfuturum.client.sound.ModSounds;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.core.utils.DummyWorld;
import ganymedes01.etfuturum.core.utils.IInitAction;
import ganymedes01.etfuturum.core.utils.Utils;
Expand Down Expand Up @@ -37,7 +38,7 @@ public BlockGeneralModdedDeepslateOre(String... names) {
resistances = new float[ores.length];
setBlockName(Utils.getUnlocalisedName("modded_deepslate_ore"));
setBlockSound(ModSounds.soundDeepslate);
setHardness(4.5F);
setHardness(ConfigFunctions.useStoneHardnessForDeepslate ? 3.0F : 4.5F);
setResistance(3);
setHarvestLevel("pickaxe", 1);
}
Expand Down Expand Up @@ -89,11 +90,11 @@ public void onLoadAction() {
if (block.getHarvestTool(stack.getItemDamage()) != null) {
setHarvestLevel("pickaxe", block.getHarvestLevel(stack.getItemDamage()), i);
}
hardnesses[i] = block.getBlockHardness(world, 0, 0, 0) * 1.5F;
hardnesses[i] = ConfigFunctions.useStoneHardnessForDeepslate ? block.getBlockHardness(world, 0, 0, 0) : block.getBlockHardness(world, 0, 0, 0) * 1.5F;
resistances[i] = block.getExplosionResistance(null, world, 0, 0, 0, 0, 0, 0); //We don't need to divide because the base method we overrode won't be dividing
} catch (Exception e) {
setHarvestLevel("pickaxe", 1, i);
hardnesses[i] = Blocks.iron_ore.blockHardness * 1.5F;
hardnesses[i] = ConfigFunctions.useStoneHardnessForDeepslate ? Blocks.iron_ore.blockHardness : Blocks.iron_ore.blockHardness * 1.5F;
resistances[i] = Blocks.iron_ore.blockResistance;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public class ConfigFunctions extends ConfigBase {
public static boolean enableAttackedAtYawFix = true; //Servers should always send the packet, it's up to the client to disable handling of this feature
public static boolean enableSubtitles;
public static byte elytraDataWatcherFlag;
public static boolean useStoneHardnessForDeepslate;
public static boolean enableDoorRecipeBuffs;
public static boolean inventoryBedModels;
public static boolean mobSpawnerEgging;
Expand Down Expand Up @@ -226,6 +227,7 @@ protected void syncConfigOptions() {
registerRawItemAsOre = getBoolean("registerRawItemAsOre", catSettings, true, "Register the raw ore items in the OreDictionary as if they were the actual ore block. Such as raw iron being registered as an iron ore, etc...\nTurn this off if you have an ore dictionary converter mod or experience other issues.");
extraDropRawOres = getStringList("extraDropRawOres", catSettings, new String[]{"oreCopper", "oreTin"}, "OreDictionary values for ore blocks that should drop extra items (2-3) instead of the usual one, before fortune.");
elytraDataWatcherFlag = (byte) getInt("elytraDataWatcherFlag", catSettings, 7, 0, 31, "The data watcher flag for the Elytra, used to sync the elytra animation with other players. In vanilla the max value is 7, players use 0-4, so you can set this to 6 or 7 by default. ASJCore increases the max value to 31.\nDo not change this value if you don't need to, or do not know what you're doing.");
useStoneHardnessForDeepslate = getBoolean("useStoneHardnessForDeepslate", catSettings, false, "Whether deepslate blocks should have the same hardness as their stone counterparts. This allows the asthetics of deepslate without the added hardness.");

//client
enableTransparentAmour = getBoolean("enableTransparentAmour", catClient, true, "Allow non-opaque armour");
Expand Down

0 comments on commit 6a85865

Please sign in to comment.