Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/22/20 in all areas

  1. From what I understand, classes in Java are only loaded by the JVM on the first called reference to that class. Referencing FMLClientSetupEvent is safe, because that class exists in the net.minecraftforge.fml.event.lifecycle package, which is common to both client and server distributions. Futhermore, calling event.getMinecraftSupplier() is safe, even though it calls net.minecraft.client.Minecraft (of which the whole package only exists in the physical client), because if that line is called and run by the JVM, it is because FMLClientSetupEvent was called, which is only called on the physical client. And referencing Minecraft is safe, because the Minecraft class will only be loaded if and only when something about that Minecraft class is queried (such as Minecraft.getInstance()). And, as said above, the only time the Minecraft class is called in the mod class is when FMLClientSetupEvent is called, which is only done on the physical client. Same principles apply to DedicatedServer: as long as your physical client code never reaches any statement referring to anything in net.minecraft.server.dedicated, your code should be safe. FYI: Checking FMLEnvironment.dist or using DistExecutor are two other ways to check what physical side you are running and to run code on a specific physical side, respectively. Source: https://stackoverflow.com/questions/16330355/when-are-imported-classes-loaded-in-java https://stackoverflow.com/questions/7560721/when-does-the-jvm-load-classes
    1 point
  2. Yep, PR: https://github.com/MinecraftForge/MinecraftForge/pull/6421 I’m currently working on the Forge docs for the config system, here’s my tutorial on them in the meantime.
    1 point
  3. No. Item Registry Event: - Create EntityType - Create and register Spawn Egg EntityType Registry Event: - Register EntityType In External/Referenced Libraries in your IDE. I assume spawning entities would be in ServerWorld.
    1 point
  4. Some examples of code that do raytracing: - debug overlay’s targeted block - throwable entity’s update code (before it calls onImpact) - Minecraft’s code that’s sets objectMouseOver
    1 point
  5. By doing a little bit more digging, now that I'm not really tired today haha, I found that the PlayerRespawn event (when the player dies) actually also calls the PlayerClone event, helping me discover there was an option in PlayerEvent.Clone called "isWasDeath." By using this event, I was able to determine if the player died, and re-apply my health modifier appropriately, which allowed me to set the playerNew's health to the same as the playerOld's health, thereby keeping their health across dimension change. Here's my fixed code: @SubscribeEvent public static void onPlayerClone(PlayerEvent.Clone event) { debug("PlayerClone{Event}"); // Fetch & Copy Capability PlayerEntity playerOld = event.getOriginal(); PlayerEntity playerNew = event.getPlayer(); IMoreHealth capOld = MoreHealth.getFromPlayer(playerOld); IMoreHealth capNew = MoreHealth.getFromPlayer(playerNew); capNew.copy(capOld); // Copy Health on Dimension Change if (!event.isWasDeath()) { debug("PlayerClone{Event}: Cloning from dimension change, re-applying health modifier."); LevelHearts.applyHealthModifier(playerNew, capNew.getTrueModifier()); playerNew.setHealth(playerOld.getHealth()); } } @SubscribeEvent public static void onPlayerRespawn(PlayerRespawnEvent event) { // Ensure server-side only if (event.getPlayer().getEntityWorld().isRemote) { return; } debug("PlayerRespawn{Event}"); // Fetch Capability PlayerEntity player = event.getPlayer(); IMoreHealth cap = MoreHealth.getFromPlayer(player); // Handle "The End" if (event.isEndConquered()) { debug("PlayerRespawn{Event}: Coming from end, syncing!"); MoreHealth.updateClient((ServerPlayerEntity) player, cap); return; } // ... other stuff }
    1 point
  6. I found out why it was on top of everything else. There is 2 different RenderTypeBuffer.Impl available in client, one is for displaying stuff as part of GUI (in top of world rendering), the other is for world rendering. Thanks to everyone working with me on this ! Here is a working snippet for anyone struggling with same issue as me (needless to say, it's physical client-side code only) public void render(RenderWorldLastEvent event) { Vec3d location; // some location in world BlockState state; // some BlockState (does not have to be part of world) renderBlock(event.getMatrixStack(), location, state); } public static void renderBlock(MatrixStack matrixStack, Vec3d pos, BlockState state) { BlockRendererDispatcher renderer = Minecraft.getInstance().getBlockRendererDispatcher(); ClientWorld world = Minecraft.getInstance().world; IModelData model = renderer.getModelForState(state).getModelData(world, new BlockPos(pos), state, ModelDataManager.getModelData(world, new BlockPos(pos))); ActiveRenderInfo renderInfo = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); matrixStack.func_227860_a_(); // push matrixStack.func_227861_a_(-renderInfo.getProjectedView().getX() + pos.x, -renderInfo.getProjectedView().getY() + pos.y, -renderInfo.getProjectedView().getZ() + pos.z); // translate back to camera // Overlay texture = custom RGBA on top of texture, 0 -> red //func_228487_b_ -> display over everything else //func_228489_c_ -> display as part of chunk rendering Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(state, matrixStack, Minecraft.getInstance().func_228019_au_().func_228489_c_(), 15728880, OverlayTexture.field_229196_a_, model); matrixStack.func_227865_b_(); // pop }
    1 point
  7. The same limits that are in vanilla as they are the ones who specify the binary formats for these things.
    1 point
×
×
  • Create New...

Important Information

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