Dynamic Ore Sample Textures
oitsjustjose opened this issue · 3 comments
I should be able to add a custom ore and make a custom ore sample for it dynamically using the texture of the main ore block. Logic:
Config Parser:
SampleManager.addSample(ResourceLocation, meta);
SampleManager.java:
public ArrayList<Sample> samples = new ArrayList<>();
public void addSample(ResourceLocation resLoc, int meta){
Sample toMake = null;
for (Sample sample : samples){
if (sample.subTypeCount < 15) {
toMake = sample;
}
}
if (sample == null){
sample = new Sample(samples.size());
samples.add(sample);
}
Block parent = ForgeRegistries.BLOCKS.getValue(resLoc);
sample.addSubType(parent, meta);
}
Sample.java
public ArrayList<IBlockState> parents = new ArrayList<>();
public Sample(int id) {
super(Material.GROUND);
this.setRegistryName(new ResourceLocation(Geolosys.MODID, "ore_sample_" + id));
this.setHardness(0.125F);
this.setResistance(2F);
this.setSoundType(SoundType.GROUND);
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
this.setDefaultState(this.blockState.getBlock().getStateFromMeta(0));
this.setUnlocalizedName(this.getRegistryName().toString().replaceAll(":", "."));
ForgeRegistries.BLOCKS.register(this);
ForgeRegistries.ITEMS.register(new ItemBlockOre(this));
MinecraftForge.EVENT_BUS.register(this);
}
public void add(ResourceLocation resLoc, Block parent, int parentMeta) {
// Needs logic for getting the model from Geolosys but the texture from the parent
this.parents.add(parent.getStateFromMeta(parentMeta));
ClientRegistry.register(new ItemStack(parent, 1, parentMeta), resLoc, ""+this.parents.size())
}
No ETA, my only update is that I’ve had no luck finding out how to get a block model...
Crap, as I’m typing this I remember that Chisels n Bits does it so it has to be possible and that mod is open source.
TODO (for me): look into CnB