Dynamic Ore Sample Textures #166

Closed
opened 2018-11-02 16:23:10 +00:00 by import_user_oitsjustjose_95mQ · 4 comments
import_user_oitsjustjose_95mQ commented 2018-11-02 16:23:10 +00:00 (Migrated from git.oitsjustjose.com)

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())
}
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()) }
import_user_oitsjustjose_95mQ commented 2018-11-02 16:31:34 +00:00 (Migrated from git.oitsjustjose.com)

mentioned in issue #146

mentioned in issue #146
import_user_oitsjustjose_95mQ commented 2019-01-22 20:37:35 +00:00 (Migrated from git.oitsjustjose.com)

Any updates / ETA? Would love to see this!

Any updates / ETA? Would love to see this!
import_user_oitsjustjose_95mQ commented 2019-01-26 05:21:38 +00:00 (Migrated from git.oitsjustjose.com)

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

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
import_user_oitsjustjose_95mQ commented 2019-02-14 01:17:14 +00:00 (Migrated from git.oitsjustjose.com)

So CnB was ridiculously complicated compared to someone just using Content Tweaker, so I think this is closed for now. May reopen when I can sit down for days and look at this.

So CnB was ridiculously complicated compared to someone just using Content Tweaker, so I think this is closed for now. May reopen when I can sit down for *days* and look at this.
import_user_oitsjustjose_95mQ (Migrated from git.oitsjustjose.com) closed this issue 2019-02-14 01:17:16 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
oitsjustjose/Geolosys#166
No description provided.