Skip to content

Commit

Permalink
provide public stubs for private interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Feb 27, 2024
1 parent 3aacd40 commit 4a81999
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface RegisterMenuScreensEvent {

<MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> void register(Supplier<MenuType<? extends MENU>> menuType, MenuScreens.ScreenConstructor<MENU, SCREEN> screenFactory);
<MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> void register(Supplier<MenuType<? extends MENU>> menuType, ScreenConstructor<MENU, SCREEN> screenFactory);

Event<Callback> EVENT = Event.create(Callback.class, callbacks -> event -> {
for (Callback callback : callbacks) {
Expand All @@ -23,4 +23,6 @@ public interface RegisterMenuScreensEvent {
interface Callback {
void registerMenuScreens(RegisterMenuScreensEvent event);
}

interface ScreenConstructor<MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> extends MenuScreens.ScreenConstructor<MENU, SCREEN> { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ public interface RegisterParticleFactoriesEvent {
default <T extends ParticleOptions> void registerSprite(Supplier<ParticleType<T>> type, ParticleProvider.Sprite<T> sprite) {
registerSpriteSet(type, spriteSet -> (t, level, x, y, z, velocityX, velocityY, velocityZ) -> {
var particle = sprite.createParticle(t, level, x, y, z, velocityX, velocityY, velocityZ);
if(particle != null) {
if (particle != null) {
particle.pickSprite(spriteSet);
}

return particle;
});
}

<T extends ParticleOptions> void registerSpriteSet(Supplier<ParticleType<T>> type, ParticleEngine.SpriteParticleRegistration<T> registration);
<T extends ParticleOptions> void registerSpriteSet(Supplier<ParticleType<T>> type, SpriteParticleRegistration<T> registration);

@FunctionalInterface
interface Callback {
void registerParticleFactories(RegisterParticleFactoriesEvent event);
}

interface SpriteParticleRegistration<T extends ParticleOptions> extends ParticleEngine.SpriteParticleRegistration<T> {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void onClientSetup(FMLClientSetupEvent event) {
});
}

private static <MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> void registerMenuScreen(Supplier<MenuType<? extends MENU>> type, MenuScreens.ScreenConstructor<MENU, SCREEN> factory) {
private static <MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> void registerMenuScreen(Supplier<MenuType<? extends MENU>> type, RegisterMenuScreensEvent.ScreenConstructor<MENU, SCREEN> factory) {
MenuScreens.register(type.get(), factory);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.upcraft.sparkweave.neoforge.impl.registry;

import dev.upcraft.sparkweave.api.client.event.RegisterParticleFactoriesEvent;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
Expand All @@ -18,7 +17,7 @@ public <T extends ParticleOptions> void registerSpecial(Supplier<ParticleType<T>
}

@Override
public <T extends ParticleOptions> void registerSpriteSet(Supplier<ParticleType<T>> type, ParticleEngine.SpriteParticleRegistration<T> registration) {
public <T extends ParticleOptions> void registerSpriteSet(Supplier<ParticleType<T>> type, SpriteParticleRegistration<T> registration) {
event.registerSpriteSet(type.get(), registration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class RegisterMenuScreensEventImpl implements RegisterMenuScreensEvent {

@Override
public <MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> void register(Supplier<MenuType<? extends MENU>> menuType, MenuScreens.ScreenConstructor<MENU, SCREEN> screenFactory) {
public <MENU extends AbstractContainerMenu, SCREEN extends Screen & MenuAccess<MENU>> void register(Supplier<MenuType<? extends MENU>> menuType, ScreenConstructor<MENU, SCREEN> screenFactory) {
MenuScreens.register(menuType.get(), screenFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import dev.upcraft.sparkweave.api.client.event.RegisterParticleFactoriesEvent;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
Expand All @@ -17,7 +16,7 @@ public <T extends ParticleOptions> void registerSpecial(Supplier<ParticleType<T>
}

@Override
public <T extends ParticleOptions> void registerSpriteSet(Supplier<ParticleType<T>> type, ParticleEngine.SpriteParticleRegistration<T> registration) {
public <T extends ParticleOptions> void registerSpriteSet(Supplier<ParticleType<T>> type, SpriteParticleRegistration<T> registration) {
ParticleFactoryRegistry.getInstance().register(type.get(), registration::create);
}
}

0 comments on commit 4a81999

Please sign in to comment.