From a89a78b679315dfbfdab24ecda7caba4c30f3916 Mon Sep 17 00:00:00 2001 From: Corosauce Date: Sun, 22 Oct 2023 04:12:10 +0100 Subject: [PATCH] quick fix dedicated server crash --- .../particle/ParticleRegistry.java | 2 -- src/main/java/weather2/BlockProvider.java | 3 --- src/main/java/weather2/Weather.java | 16 ++++++++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/extendedrenderer/particle/ParticleRegistry.java b/src/main/java/extendedrenderer/particle/ParticleRegistry.java index 349b6ee8..06055c51 100644 --- a/src/main/java/extendedrenderer/particle/ParticleRegistry.java +++ b/src/main/java/extendedrenderer/particle/ParticleRegistry.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Optional; -@Mod.EventBusSubscriber(modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ParticleRegistry extends SpriteSourceProvider { public static TextureAtlasSprite squareGrey; @@ -133,7 +132,6 @@ public void addSprite(ResourceLocation res) { } @SubscribeEvent - @OnlyIn(Dist.CLIENT) public static void getRegisteredParticles(TextureStitchEvent.Post event) { if (!event.getAtlas().location().equals(TextureAtlas.LOCATION_PARTICLES)) { diff --git a/src/main/java/weather2/BlockProvider.java b/src/main/java/weather2/BlockProvider.java index bf68affa..c7462fd0 100644 --- a/src/main/java/weather2/BlockProvider.java +++ b/src/main/java/weather2/BlockProvider.java @@ -18,11 +18,8 @@ import java.util.List; import java.util.Optional; -@Mod.EventBusSubscriber(modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class BlockProvider extends SpriteSourceProvider { - public static TextureAtlasSprite squareGrey; - public BlockProvider(PackOutput output, ExistingFileHelper fileHelper) { super(output, fileHelper, Weather.MODID); diff --git a/src/main/java/weather2/Weather.java b/src/main/java/weather2/Weather.java index d5383dda..9760968b 100644 --- a/src/main/java/weather2/Weather.java +++ b/src/main/java/weather2/Weather.java @@ -10,6 +10,8 @@ import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; import net.minecraft.world.item.CreativeModeTab; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ForgeSpriteSourceProvider; @@ -25,6 +27,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.loading.FMLEnvironment; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import weather2.command.WeatherCommand; @@ -93,6 +96,10 @@ public Weather() { //WeatherUtilConfig.nbtLoadDataAll(); SoundRegistry.init(); + + if (FMLEnvironment.dist.isClient()) { + modBus.addListener(ParticleRegistry::getRegisteredParticles); + } } public static IConfigCategory addConfig(IConfigCategory config) { @@ -148,15 +155,20 @@ private void registerCommands(RegisterCommandsEvent event) { } private void gatherData(GatherDataEvent event) { - DataGenerator gen = event.getGenerator(); if (event.includeServer()) { //TODO: 1.20 //gen.addProvider(new WeatherRecipeProvider(gen)); } + if (event.includeClient()) { + gatherClientData(event); + } + } + @OnlyIn(Dist.CLIENT) + private void gatherClientData(GatherDataEvent event) { + DataGenerator gen = event.getGenerator(); PackOutput packOutput = gen.getPackOutput(); ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); - gen.addProvider(event.includeClient(), new ParticleRegistry(packOutput, existingFileHelper)); gen.addProvider(event.includeClient(), new BlockProvider(packOutput, existingFileHelper)); }