kyazuki
Members-
Posts
113 -
Joined
-
Last visited
Everything posted by kyazuki
-
No, I can compile this... Do you mean to not create instance in initializers? Or remove static?
-
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); } }
-
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); } }
-
[Solved][1.16.1]Fire CustomPlayerEvent every 10 sec.
kyazuki replied to kyazuki's topic in Modder Support
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)); } } } -
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)); } } } }
-
It works! Thank you!
-
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?
-
I know TRACKING_CHUNK/ENTITY, but it's opposite. I want to send tracked players data to a tracking client.
-
Can I get players in render range? I want to send packets of players in render range to client.
-
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:
-
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
I see. Thank you for pointing it out! -
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
Is this correct? Entity player = Minecraft.getInstance().world.getEntityByID(playerEntityID); if (player == null || !(player instanceof PlayerEntity)) return; -
[1.16.1]Not translate TranslationTextComponent on console
kyazuki replied to kyazuki's topic in Modder Support
I see. Thank you! -
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
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); } }; } } -
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
Yes, but it causes server crash... https://github.com/kyazuki/DietMod/blob/37d228d98922fb2d498414dcd2db04f744a2b8f1/src/main/java/com/github/kyazuki/dietmod/network/CapabilityPacket.java#L29 -
[1.16.1]Not translate TranslationTextComponent on console
kyazuki replied to kyazuki's topic in Modder Support
I can't translate on console? Vanilla commands are translated on console, so I assumed I can. -
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
Context#getSender()? I want to change ClientPlayer capability. getSender() returns ServerPlayerEntity... -
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; }))); } }
-
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
What should I do here? I know there’s the “OnlyIn” annotation, but I hear it’s not ideal. -
[Solved][1.16.1]Client works, but server crashes at packet handler.
kyazuki replied to kyazuki's topic in Modder Support
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? -
[1.16.1]Player Capability values reset when login.
kyazuki replied to kyazuki's topic in Modder Support
I noticed PlayerEntity.distanceWalkModified reset when login. How do I get statics correctly on 1.16.1? -
[1.16.1]Player Capability values reset when login.
kyazuki replied to kyazuki's topic in Modder Support
I fixed! https://github.com/kyazuki/DietMod/blob/3f17baad31d4b91edaf56e75dd90c168f5194aad/src/main/java/com/github/kyazuki/dietmod/EventSubscriber.java#L84 -
[1.16.1]Player Capability values reset when login.
kyazuki replied to kyazuki's topic in Modder Support
"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 -
[1.16.1]Player Capability values reset when login.
kyazuki replied to kyazuki's topic in Modder Support
My cap value is synced player max health. It's reset every time player join the world.