Add a config option to change the textures of the end ores to use the stone background.

I still need to add the other ores, but this is the main one that needs doing.
This commit is contained in:
modmuss50 2018-03-09 19:57:20 +00:00
parent 23b3b7335c
commit d7ce35428c
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
4 changed files with 57 additions and 18 deletions

View file

@ -58,6 +58,7 @@ import techreborn.world.config.IOreNameProvider;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
@RebornRegistry(modID = ModInfo.MOD_ID) @RebornRegistry(modID = ModInfo.MOD_ID)
public class BlockOre extends Block implements IOreNameProvider { public class BlockOre extends Block implements IOreNameProvider {
@ -66,8 +67,8 @@ public class BlockOre extends Block implements IOreNameProvider {
"galena", "iridium", "ruby", "sapphire", "bauxite", "pyrite", "galena", "iridium", "ruby", "sapphire", "bauxite", "pyrite",
"cinnabar", "sphalerite", "tungsten", "sheldonite", "peridot", "sodalite", "cinnabar", "sphalerite", "tungsten", "sheldonite", "peridot", "sodalite",
"lead", "silver" }; "lead", "silver" };
private static final List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores)); public static List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
public static final PropertyString VARIANTS = new PropertyString("type", oreNamesList); public static final PropertyString VARIANTS = getVarients();
@ConfigRegistry(config = "misc", category = "blocks", key = "rubyMinQuatity", comment = "Minimum quantity of Ruby gems per Ruby ore") @ConfigRegistry(config = "misc", category = "blocks", key = "rubyMinQuatity", comment = "Minimum quantity of Ruby gems per Ruby ore")
public static int rubyMinQuatity = 1; public static int rubyMinQuatity = 1;
@ConfigRegistry(config = "misc", category = "blocks", key = "rubyMaxQuantity", comment = "Maximum quantity of Ruby gems per Ruby ore") @ConfigRegistry(config = "misc", category = "blocks", key = "rubyMaxQuantity", comment = "Maximum quantity of Ruby gems per Ruby ore")
@ -100,12 +101,13 @@ public class BlockOre extends Block implements IOreNameProvider {
setHarvestLevel("pickaxe", 2); setHarvestLevel("pickaxe", 2);
this.setDefaultState(this.getStateFromMeta(0)); this.setDefaultState(this.getStateFromMeta(0));
for (int i = 0; i < ores.length; i++) { for (int i = 0; i < ores.length; i++) {
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i).setInvVariant("type=" + ores[i]).setFileName("ores")); ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i).setInvVariant("type=" + OreBlockStateManager.convert(ores[i])).setFileName("ores"));
} }
TRRecipeHandler.hideEntry(this); TRRecipeHandler.hideEntry(this);
} }
public static ItemStack getOreByName(String name, int count) { public static ItemStack getOreByName(String name, int count) {
name = OreBlockStateManager.invert(name);
for (int i = 0; i < ores.length; i++) { for (int i = 0; i < ores.length; i++) {
if (ores[i].equalsIgnoreCase(name)) { if (ores[i].equalsIgnoreCase(name)) {
return new ItemStack(ModBlocks.ORE, count, i); return new ItemStack(ModBlocks.ORE, count, i);
@ -119,6 +121,7 @@ public class BlockOre extends Block implements IOreNameProvider {
} }
public IBlockState getBlockStateFromName(String name) { public IBlockState getBlockStateFromName(String name) {
name = OreBlockStateManager.invert(name);
int index = -1; int index = -1;
for (int i = 0; i < ores.length; i++) { for (int i = 0; i < ores.length; i++) {
if (ores[i].equalsIgnoreCase(name)) { if (ores[i].equalsIgnoreCase(name)) {
@ -137,36 +140,30 @@ public class BlockOre extends Block implements IOreNameProvider {
String variant = state.getValue(VARIANTS); String variant = state.getValue(VARIANTS);
int meta = getMetaFromState(state); int meta = getMetaFromState(state);
Random random = new Random(); Random random = new Random();
// Secondary drop, like peridot from sapphire ore added via event handler. // Secondary drop, like peridot from sapphire ore added via event handler.
if (variant.equalsIgnoreCase("Ruby")) { if (variant.equalsIgnoreCase("Ruby")) {
OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby", rubyMinQuatity), rubyMaxQuantity); OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby", rubyMinQuatity), rubyMaxQuantity);
drops.add(ruby.getDrops(fortune, random)); drops.add(ruby.getDrops(fortune, random));
} } else if (variant.equalsIgnoreCase("Sapphire")) {
else if (variant.equalsIgnoreCase("Sapphire")) {
OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire", sapphireMinQuantity), sapphireMaxQuantity); OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire", sapphireMinQuantity), sapphireMaxQuantity);
drops.add(sapphire.getDrops(fortune, random)); drops.add(sapphire.getDrops(fortune, random));
} } else if (variant.equalsIgnoreCase("Pyrite")) {
else if (variant.equalsIgnoreCase("Pyrite")) {
OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite", pyriteMinQuatity), pyriteMaxQuantity); OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite", pyriteMinQuatity), pyriteMaxQuantity);
drops.add(pyriteDust.getDrops(fortune, random)); drops.add(pyriteDust.getDrops(fortune, random));
} } else if (variant.equalsIgnoreCase("Sodalite")) {
else if (variant.equalsIgnoreCase("Sodalite")) {
OreDrop sodalite = new OreDrop(ItemDusts.getDustByName("sodalite", sodaliteMinQuatity), sodaliteMaxQuantity); OreDrop sodalite = new OreDrop(ItemDusts.getDustByName("sodalite", sodaliteMinQuatity), sodaliteMaxQuantity);
drops.add(sodalite.getDrops(fortune, random)); drops.add(sodalite.getDrops(fortune, random));
} } else if (variant.equalsIgnoreCase("Cinnabar")) {
else if (variant.equalsIgnoreCase("Cinnabar")) {
OreDrop cinnabar = new OreDrop(ItemDusts.getDustByName("cinnabar", cinnabarMinQuatity), cinnabarMaxQuantity); OreDrop cinnabar = new OreDrop(ItemDusts.getDustByName("cinnabar", cinnabarMinQuatity), cinnabarMaxQuantity);
drops.add(cinnabar.getDrops(fortune, random)); drops.add(cinnabar.getDrops(fortune, random));
} } else if (variant.equalsIgnoreCase("Sphalerite")) {
else if (variant.equalsIgnoreCase("Sphalerite")) {
OreDrop sphalerite = new OreDrop(ItemDusts.getDustByName("sphalerite", sphaleriteMinQuatity), sphaleriteMaxQuantity); OreDrop sphalerite = new OreDrop(ItemDusts.getDustByName("sphalerite", sphaleriteMinQuatity), sphaleriteMaxQuantity);
drops.add(sphalerite.getDrops(fortune, random)); drops.add(sphalerite.getDrops(fortune, random));
} } else {
else {
drops.add(new ItemStack(Item.getItemFromBlock(this), 1, meta)); drops.add(new ItemStack(Item.getItemFromBlock(this), 1, meta));
} }
return; return;
} }
@ -216,4 +213,13 @@ public class BlockOre extends Block implements IOreNameProvider {
return StringUtils.toFirstCapital(oreNamesList.get(getMetaFromState(state))); return StringUtils.toFirstCapital(oreNamesList.get(getMetaFromState(state)));
} }
public static PropertyString getVarients() {
if (OreBlockStateManager.endOreStone) {
oreNamesList = BlockOre.oreNamesList.stream().map(OreBlockStateManager::convert).collect(Collectors.toList());
return new PropertyString("type", oreNamesList);
} else {
return new PropertyString("type", BlockOre.oreNamesList);
}
}
} }

View file

@ -0,0 +1,28 @@
package techreborn.blocks;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import techreborn.lib.ModInfo;
//This is in its own class as not to load the block class before
@RebornRegistry(modID = ModInfo.MOD_ID, priority = 1, earlyReg = true)
public class OreBlockStateManager {
//This is a one off config, dont worry about it
@ConfigRegistry(config = "misc", category = "misc", key = "endOreStone", comment = "Set to true to render the end ores with a stone background")
public static boolean endOreStone = false;
public static String convert(String name){
if (OreBlockStateManager.endOreStone && name.equals("tungsten")) {
name = "tungsten_stone";
}
return name;
}
public static String invert(String name){
if (name.equals("tungsten_stone")) {
name = "tungsten";
}
return name;
}
}

View file

@ -55,6 +55,11 @@
"all": "techreborn:blocks/ore/tungsten_ore" "all": "techreborn:blocks/ore/tungsten_ore"
} }
}, },
"tungsten_stone": {
"textures": {
"all": "techreborn:blocks/ore/tungsten_ore_stone"
}
},
"sheldonite": { "sheldonite": {
"textures": { "textures": {
"all": "techreborn:blocks/ore/sheldonite_ore" "all": "techreborn:blocks/ore/sheldonite_ore"

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B