Posted July 7, 20241 yr 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
July 9, 20241 yr 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.