#Truly Modular: Modular Item API

39 messages · Page 1 of 1 (latest)

radiant lintel
radiant lintel
merry solar
#

this is amazing

sudden tapir
#

This is absolutely insane

merry solar
#

tinkers construct is like ... nothing compared to this

sudden tapir
#

This is like if Tinkers and Silent Gear and also Tetra had a child and that child went on to become president

radiant lintel
#

Stack modular crafting also works btw

#

Also im actually using the item render itself for the ender pearl so funny stuff is possible

radiant lintel
radiant lintel
sudden tapir
#

Dude this is going to become huge

#

If it's for 1.20, I guarentee it'll be added to the new ATM pack

radiant lintel
#

its for 1.20.1

sudden tapir
#

although most things are so that might not say a whole lot

sudden tapir
#

This mod is incredible

radiant lintel
#

it has some outdated testjars as github releases already

sudden tapir
#

Like, even the GUI looks really clean so far

radiant lintel
#

welp, we are already planning the next gui rework

#

guis are pure pain not gonna lie

sudden tapir
#

Yes, yes they are. GUIs suck. You guys are awesome for taking the time to make an actually good one

#

I'm actually really excited for this mod

radiant lintel
radiant lintel
elfin plinth
#

the effects (ie explosions) are done in code then referenced through hooks in the data file?

#

like "on_block_hit": "miapi:medium_explosion"

#

oh yea itd be good if you can reference mcfunction files

radiant lintel
#

Not quite

#

Truly modular uses a property system

#

So the json in question is

#
            "explosion_projectile": {
                "destroyBlocks": false,
                "strength": 2
            },
#

the full json in question is sth called a synergy, where under certain condition a item receives different properties

#

and the java code for the explosions looks like this

public class ExplosionProperty extends CodecBasedProperty<ExplosionProperty.ExplosionInfo> {
    public static final String KEY = "explosion_projectile";
    public static final Codec<ExplosionInfo> codec = AutoCodec.of(ExplosionInfo.class).codec();

    public ExplosionProperty() {
        super(KEY, codec);
        MiapiProjectileEvents.MODULAR_PROJECTILE_ENTITY_HIT.register(event -> {
            ExplosionInfo info = this.get(event.projectile.asItemStack());
            if (info != null) {
                explode(info, event.projectile, event.entityHitResult);
                if (!event.projectile.getWorld().isClient()) {
                    event.projectile.discard();
                    return EventResult.interruptTrue();
                }
            }
            return EventResult.pass();
        });
        MiapiProjectileEvents.MODULAR_PROJECTILE_BLOCK_HIT.register(event -> {
            ExplosionInfo info = this.get(event.projectile.asItemStack());
            if (info != null) {
                explode(info, event.projectile, event.blockHitResult);
                if (!event.projectile.getWorld().isClient()) {
                    event.projectile.discard();
                    return EventResult.interruptTrue();
                }
            }
            return EventResult.pass();
        });
    }

    private void explode(ExplosionInfo info, ItemProjectileEntity projectile, HitResult result) {
        World.ExplosionSourceType explosionSourceType = World.ExplosionSourceType.TNT;
        if(!info.destroyBlocks){
            explosionSourceType = World.ExplosionSourceType.NONE;
        }
        projectile.getWorld().createExplosion(projectile, result.getPos().getX(), result.getPos().getY(), result.getPos().getZ(), info.strength, explosionSourceType);
    }

    public static class ExplosionInfo {
        public boolean destroyBlocks = false;
        public float strength = 1.0f;
    }
}
radiant lintel
radiant lintel