Jump to content

kyazuki

Members
  • Posts

    113
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

kyazuki's Achievements

Creeper Killer

Creeper Killer (4/8)

5

Reputation

  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. Is this correct? Entity player = Minecraft.getInstance().world.getEntityByID(playerEntityID); if (player == null || !(player instanceof PlayerEntity)) return;
  11. 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); } }; } }
  12. Yes, but it causes server crash... https://github.com/kyazuki/DietMod/blob/37d228d98922fb2d498414dcd2db04f744a2b8f1/src/main/java/com/github/kyazuki/dietmod/network/CapabilityPacket.java#L29
×
×
  • Create New...

Important Information

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