Skip to content

Commit

Permalink
more generics fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Feb 28, 2024
1 parent 45af240 commit ddbfa0e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public interface RegisterBlockEntityRenderersEvent {

<T extends BlockEntity> void registerRenderer(Supplier<BlockEntityType<? extends T>> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider);
<T extends BlockEntity> void registerRenderer(Supplier<BlockEntityType<T>> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider);

Event<Callback> EVENT = Event.create(Callback.class, callbacks -> event -> {
for (Callback callback : callbacks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public interface RegisterEntityRenderersEvent {

<T extends Entity> void registerRenderer(Supplier<EntityType<? extends T>> entityType, EntityRendererProvider<T> entityRendererProvider);
<T extends Entity> void registerRenderer(Supplier<EntityType<T>> entityType, EntityRendererProvider<T> entityRendererProvider);

Event<Callback> EVENT = Event.create(Callback.class, callbacks -> event -> {
for (Callback callback : callbacks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public interface RegisterParticleFactoriesEvent {
}
});

<T extends ParticleOptions> void registerSpecial(Supplier<ParticleType<T>> type, ParticleProvider<T> provider);
<OPT extends ParticleOptions, TYPE extends ParticleType<OPT>> void registerSpecial(Supplier<TYPE> type, ParticleProvider<OPT> provider);

// copying from ParticleEngine because fabric does not expose this method
default <T extends ParticleOptions> void registerSprite(Supplier<ParticleType<T>> type, ParticleProvider.Sprite<T> sprite) {
default <OPT extends ParticleOptions, TYPE extends ParticleType<OPT>> void registerSprite(Supplier<TYPE> type, ParticleProvider.Sprite<OPT> 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) {
Expand All @@ -30,7 +30,7 @@ default <T extends ParticleOptions> void registerSprite(Supplier<ParticleType<T>
});
}

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

@FunctionalInterface
interface Callback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public record RegisterParticleFactoriesEventImpl(
RegisterParticleProvidersEvent event) implements RegisterParticleFactoriesEvent {

@Override
public <T extends ParticleOptions> void registerSpecial(Supplier<ParticleType<T>> type, ParticleProvider<T> provider) {
public <OPT extends ParticleOptions, TYPE extends ParticleType<OPT>> void registerSpecial(Supplier<TYPE> type, ParticleProvider<OPT> provider) {
event.registerSpecial(type.get(), provider);
}

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

@Override
public <T extends ParticleOptions> void registerSprite(Supplier<ParticleType<T>> type, ParticleProvider.Sprite<T> sprite) {
public <OPT extends ParticleOptions, TYPE extends ParticleType<OPT>> void registerSprite(Supplier<TYPE> type, ParticleProvider.Sprite<OPT> sprite) {
event.registerSprite(type.get(), sprite);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public abstract class RegisterRenderersEventMixin implements RegisterEntityRende
@Shadow
public abstract <T extends Entity> void registerEntityRenderer(EntityType<? extends T> entityType, EntityRendererProvider<T> entityRendererProvider);

public <T extends BlockEntity> void registerBlockEntityRenderer$registerRenderer(Supplier<BlockEntityType<? extends T>> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider) {
public <T extends BlockEntity> void registerBlockEntityRenderer$registerRenderer(Supplier<BlockEntityType<T>> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider) {
this.registerBlockEntityRenderer(blockEntityType.get(), blockEntityRendererProvider);
}

public <T extends Entity> void registerEntityRenderers$registerRenderer(Supplier<EntityType<? extends T>> entityType, EntityRendererProvider<T> entityRendererProvider) {
public <T extends Entity> void registerEntityRenderers$registerRenderer(Supplier<EntityType<T>> entityType, EntityRendererProvider<T> entityRendererProvider) {
this.registerEntityRenderer(entityType.get(), entityRendererProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class RegisterBlockEntityRenderersEventImpl implements RegisterBlockEntityRenderersEvent {

@Override
public <T extends BlockEntity> void registerRenderer(Supplier<BlockEntityType<? extends T>> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider) {
public <T extends BlockEntity> void registerRenderer(Supplier<BlockEntityType<T>> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider) {
BlockEntityRenderers.register(blockEntityType.get(), blockEntityRendererProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class RegisterEntityRenderersEventImpl implements RegisterEntityRenderersEvent {

@Override
public <T extends Entity> void registerRenderer(Supplier<EntityType<? extends T>> entityType, EntityRendererProvider<T> entityRendererProvider) {
public <T extends Entity> void registerRenderer(Supplier<EntityType<T>> entityType, EntityRendererProvider<T> entityRendererProvider) {
EntityRendererRegistry.register(entityType.get(), entityRendererProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
public class RegisterParticleFactoriesEventImpl implements RegisterParticleFactoriesEvent {

@Override
public <T extends ParticleOptions> void registerSpecial(Supplier<ParticleType<T>> type, ParticleProvider<T> provider) {
public <OPT extends ParticleOptions, TYPE extends ParticleType<OPT>> void registerSpecial(Supplier<TYPE> type, ParticleProvider<OPT> provider) {
ParticleFactoryRegistry.getInstance().register(type.get(), provider);
}

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

0 comments on commit ddbfa0e

Please sign in to comment.