mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Cleanup flywheel event listeners, fix crash on server startup
This commit is contained in:
parent
c887d326c6
commit
0bb85e4437
6 changed files with 24 additions and 19 deletions
|
@ -3,6 +3,11 @@ package com.jozufozu.flywheel;
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.core.AtlasStitcher;
|
||||
|
||||
import com.jozufozu.flywheel.core.Contexts;
|
||||
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
public class Client {
|
||||
|
@ -10,6 +15,11 @@ public class Client {
|
|||
public static void clientInit() {
|
||||
|
||||
Backend.init();
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(AtlasStitcher.getInstance()::onTextureStitch);
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
modEventBus.addListener(AtlasStitcher.getInstance()::onTextureStitch);
|
||||
|
||||
modEventBus.addListener(Contexts::flwInit);
|
||||
modEventBus.addListener(Materials::flwInit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,13 @@ import net.minecraft.util.math.vector.Matrix4f;
|
|||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mod.EventBusSubscriber(Dist.CLIENT)
|
||||
public class InstancedRenderDispatcher {
|
||||
|
||||
private static final WorldAttached<EntityInstanceManager> entityInstanceManager = new WorldAttached<>(world -> new EntityInstanceManager(Contexts.WORLD.getMaterialManager(world)));
|
||||
|
|
|
@ -12,16 +12,16 @@ import com.jozufozu.flywheel.event.GatherContextEvent;
|
|||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Contexts {
|
||||
|
||||
public static WorldContext<WorldProgram> WORLD;
|
||||
public static WorldContext<CrumblingProgram> CRUMBLING;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void flwInit(GatherContextEvent event) {
|
||||
Backend backend = event.getBackend();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
|
@ -9,22 +8,16 @@ import com.jozufozu.flywheel.event.GatherContextEvent;
|
|||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Materials {
|
||||
public static final MaterialSpec<OrientedData> ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, Programs.ORIENTED, Formats.UNLIT_MODEL, Formats.ORIENTED, OrientedData::new));
|
||||
public static final MaterialSpec<ModelData> TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, Programs.TRANSFORMED, Formats.UNLIT_MODEL, Formats.TRANSFORMED, ModelData::new));
|
||||
public static final MaterialSpec<OrientedData> ORIENTED = new MaterialSpec<>(Locations.ORIENTED, Programs.ORIENTED, Formats.UNLIT_MODEL, Formats.ORIENTED, OrientedData::new);
|
||||
public static final MaterialSpec<ModelData> TRANSFORMED = new MaterialSpec<>(Locations.MODEL, Programs.TRANSFORMED, Formats.UNLIT_MODEL, Formats.TRANSFORMED, ModelData::new);
|
||||
|
||||
public static <D extends InstanceData> MaterialSpec<D> register(MaterialSpec<D> spec) {
|
||||
return Backend.getInstance().register(spec);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void flwInit(GatherContextEvent event) {
|
||||
register(ORIENTED);
|
||||
register(TRANSFORMED);
|
||||
event.getBackend().register(ORIENTED);
|
||||
event.getBackend().register(TRANSFORMED);
|
||||
}
|
||||
|
||||
public static class Locations {
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.Mod;
|
|||
/**
|
||||
* A class to manage EBOs that index quads as triangles.
|
||||
*/
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
@Mod.EventBusSubscriber(Dist.CLIENT)
|
||||
public class QuadConverter {
|
||||
|
||||
public static final int STARTING_CAPACITY = 42;
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
@Mod.EventBusSubscriber(Dist.CLIENT)
|
||||
public class ForgeEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
Loading…
Reference in a new issue