Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello! 
I recently approached modding and Java programming in general. But I'm very used to programming in Minecraft "code", so .json files and commands.
In fact, for example, with Terrabalnder it was quite simple and intuitive to convert biome, surface rules and positioning files to run whit forge. Instead what I'm having difficulty with is switching Minecraft things I used to do whit commands to java format.
Things like execute a condition or position checks on a specific type of entity, even simple things like "if block ~ ~-1 ~ dirt" or "run particle...". There aren't many tutorials, so I would like to know if there are any tools, documentation or a list of procedures, methods and classes, or useful IntelliJ tooltips. 
Let me know leterally how from zero I can get the location of methods and informations I need to use. Thanks

  • Author

updates...

Between documentation and online research I was able to write sensible code that in theory works the way I want.
I would like to test it, but how? For the commands there were the tick and load functions, or in any case they could be called in game. I found something about EventBus, I also followed this tutorial, but I don't understand how to make them work or implement them in any way. This is the code, please reply me

package marshal.init;

import marshal.wgen.MarshalBiomes;
import net.minecraft.core.particles.DustParticleOptions;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Vex;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biomes;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.joml.Vector3f;

@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = "marshal", bus = Mod.EventBusSubscriber.Bus.FORGE)
public class ModVex {
    ParticleOptions yellowDust = new DustParticleOptions(new Vector3f(1, 1, 1), 1.0f);
    DustParticleOptions blackDust = new DustParticleOptions(new Vector3f(255, 255, 85), 1.0f);


    @SubscribeEvent
    public void onEntityJoinWorld(EntityJoinLevelEvent event) {
        Entity entity = event.getEntity();
        Level world = event.getLevel();
        if (entity instanceof Vex && world.dimension() == Level.OVERWORLD) {
            if (world.getBiome(entity.getOnPos()) == MarshalBiomes.MARSHLAND) {
                entity.setInvisible(true);
            } else if (world.isNight()) {
                if (!entity.isInvisible()) { entity.setInvisible(true); };
                world.addParticle(yellowDust, entity.getX(), entity.getY(), entity.getZ(), 0, 0, 0);
            } else if (world.isDay()) {
                if (!entity.isInvisible()) { entity.setInvisible(true); };
                world.addParticle(blackDust, entity.getX(), entity.getY(), entity.getZ(), 0, 0, 0);
            }
        }
    }
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.