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.

kyazuki

Members
  • Joined

  • Last visited

Everything posted by kyazuki

  1. No, I can compile this... Do you mean to not create instance in initializers? Or remove static?
  2. I can't fix... Is it correct? @Mod(TestMod.MODID) @Mod.EventBusSubscriber(modid = TestMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class TestMod { public static final String MODID = "testmod"; public static final Biome TEST_BIOME; public static final TestWorldType TEST_WORLD; public TestWorld() { } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final String name) { return setup(entry, new ResourceLocation(MODID, name)); } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final ResourceLocation registryName) { entry.setRegistryName(registryName); return entry; } @SubscribeEvent public static void registerBiome(RegistryEvent.Register<Biome> event) { TEST_BIOME = TestWorldBiomeMaker.makeTestBiome(); setup(TEST_BIOME, "test_biome"); ForgeRegistries.BIOMES.register(TEST_BIOME); } @SubscribeEvent public static void registerWorldType(RegistryEvent.Register<ForgeWorldType> event) { TEST_WORLD = new TestWorldType(); setup(TEST_WORLD, "test_world"); ForgeRegistries.WORLD_TYPES.register(TEST_WORLD); } }
  3. I added a custom biome and a custom world type which generates only the said biome. Upon generating a new world, (and entering/walking around) the landscapes are generated as expected, but the message "Received invalid biome id: -1" shows up repeatedlly on the console, and the game is laggy. The F3 debug screen shows the biome as Ocean, instead of my custom biome. Saving the world and re-entering causes the newly generated chunks to be generated from the seed with vanilla biomes. How do I fix this? @Mod(TestMod.MODID) @Mod.EventBusSubscriber(modid = TestMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class TestMod { public static final String MODID = "testmod"; public static final Biome TEST_BIOME = TestWorldBiomeMaker.makeTestBiome(); public static final TestWorldType TEST_WORLD = new TestWorldType(); public TestWorld() { registerWorldType(); } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final String name) { return setup(entry, new ResourceLocation(MODID, name)); } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final ResourceLocation registryName) { entry.setRegistryName(registryName); return entry; } @SubscribeEvent public static void registerBiome(RegistryEvent.Register<Biome> event) { setup(TEST_BIOME, "test_biome"); ForgeRegistries.BIOMES.register(TEST_BIOME); } public static void registerWorldType() { setup(TEST_WORLD, "test_world"); ForgeRegistries.WORLD_TYPES.register(TEST_WORLD); } }
  4. Thanks! @SubscribeEvent public static void time(TickEvent.PlayerTickEvent event) { if (event.side == LogicalSide.SERVER && event.phase == TickEvent.Phase.END) { if (event.player.getEntityWorld().getGameTime() % 200 == 0){ MinecraftForge.EVENT_BUS.post(new MyModEvents.CustomPlayerEvent(player)); } } }
  5. I want to fire CustomPlayerEvents of all players every 10 seconds. I count 10 sec in ServerTickEvent, but I can't get playerlist in the event. So I use WorldTickEvent. However I guess this code causes bug when players are in different dimensions. How do I fix this? My code: private static int time = 200; @SubscribeEvent public static void calc(TickEvent.ServerTickEvent event) { time--; } @SubscribeEvent public static void time(TickEvent.WorldTickEvent event) { if (event.side == LogicalSide.SERVER) { if (time <= 0) { time = 200; // I guess this is called each dimension. for (PlayerEntity player : event.world.getServer().getPlayerList().getPlayers()) { MinecraftForge.EVENT_BUS.post(new MyModEvents.CustomPlayerEvent(player)); } } } }
  6. I'm sorry, I'm bad at English. So I think my explanation was a little confusing. I want clients to hold capabilities related to each of the players in the server, but this data is reset upon moving dimensions. I want to solve this. Now, I'm sending capabilities of all players to any player moving dimensions. However I need to send capabilities only of the players in render range. This is why I want to have a client fetch data from the server about players in render range. Is TRACKING_ENTITY still the solution? If so, how can I use it to achieve this?
  7. I know TRACKING_CHUNK/ENTITY, but it's opposite. I want to send tracked players data to a tracking client.
  8. Can I get players in render range? I want to send packets of players in render range to client.
  9. Server shows these error when players login, change dimension or respawn. Singleplay doesn't show them. I think they are caused by my capablitiy or packet. Code: https://github.com/kyazuki/DietMod/tree/1.16.x-forge/src/main/java/com/github/kyazuki/dietmod Error:
  10. I see. Thank you for pointing it out!
  11. Is this correct? Entity player = Minecraft.getInstance().world.getEntityByID(playerEntityID); if (player == null || !(player instanceof PlayerEntity)) return;
  12. It works! Thanks for the help! public static void handle(CapabilityPacket pkt, Supplier<NetworkEvent.Context> contextSupplier) { NetworkEvent.Context context = contextSupplier.get(); context.enqueueWork(() -> DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> Handle.handleClient(pkt.playerEntityID, pkt.scale))); context.setPacketHandled(true); } public static class Handle { public static DistExecutor.SafeRunnable handleClient(int playerEntityID, float scale) { return new DistExecutor.SafeRunnable() { @Override public void run() { PlayerEntity player = (PlayerEntity) Minecraft.getInstance().world.getEntityByID(playerEntityID); if (player == null) return; player.getCapability(ScaleProvider.SCALE_CAP).orElseThrow(IllegalArgumentException::new).setScale(scale); } }; } }
  13. Yes, but it causes server crash... https://github.com/kyazuki/DietMod/blob/37d228d98922fb2d498414dcd2db04f744a2b8f1/src/main/java/com/github/kyazuki/dietmod/network/CapabilityPacket.java#L29
  14. I can't translate on console? Vanilla commands are translated on console, so I assumed I can.
  15. Context#getSender()? I want to change ClientPlayer capability. getSender() returns ServerPlayerEntity...
  16. I add a custom command. Its feedback is translated correctly on chat. However, console shows only translationKey. How do I fix? @SubscribeEvent public static void onCommandsRegister(RegisterCommandsEvent event) { SetDistanceCommand.register(event.getDispatcher()); } public class SetDistanceCommand { public static void register(CommandDispatcher<CommandSource> dispatcher) { dispatcher.register(Commands.literal("setdistance") .requires(source -> source.hasPermissionLevel(2)) .then(Commands.argument("blocks", IntegerArgumentType.integer(10, 100000)) .executes(context -> { int value = IntegerArgumentType.getInteger(context, "blocks"); TestModConfig.distanceToNormal = value; context.getSource().sendFeedback(new TranslationTextComponent("commands.testmod.setdistance", value), true); return 0; }))); } }
  17. What should I do here? I know there’s the “OnlyIn” annotation, but I hear it’s not ideal.
  18. I don't understand the packet system fully... This packet is always sent to client from server. Can I solve this problem with changing PacketHandler? Or should I change CapabilityPacket#handle?
  19. runClient worked, but runServer crashed. How do I fix? Code: https://github.com/kyazuki/DietMod/tree/37d228d98922fb2d498414dcd2db04f744a2b8f1 Error:
  20. I noticed PlayerEntity.distanceWalkModified reset when login. How do I get statics correctly on 1.16.1?
  21. I fixed! https://github.com/kyazuki/DietMod/blob/3f17baad31d4b91edaf56e75dd90c168f5194aad/src/main/java/com/github/kyazuki/dietmod/EventSubscriber.java#L84
  22. "scale" is the value. The players max health is set to "scale" multiplied by 20. https://github.com/kyazuki/DietMod/blob/e82c049c1cb76167f99ec54318fbaf1b85e8be64/src/main/java/com/github/kyazuki/dietmod/EventSubscriber.java#L87
  23. My cap value is synced player max health. It's reset every time player join the world.

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.