Skip to content

Commit

Permalink
Change generics slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Nov 22, 2024
1 parent 7e492ad commit ccc2c45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface EntityRendererRegistry {
* @param condition Predicate to determine when to use this renderer.
* @param constructor The renderer factory
*/
<T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Predicate<T> condition, Function<EntityRendererFactory.Context, R> constructor);
<T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Predicate<? super T> condition, Function<EntityRendererFactory.Context, R> constructor);

/**
* Adds a custom block entity renderer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public final class PendingEntityRendererRegistry implements EntityRendererRegist
@SuppressWarnings("unchecked")
public final PendingRegistrations<
EntityType<?>,
Map.Entry<Either<Unit, Predicate<? extends Entity>>, Function<EntityRendererFactory.Context, ? extends EntityRenderer<?, ?>>>
Map.Entry<Either<Unit, Predicate<Entity>>, Function<EntityRendererFactory.Context, ? extends EntityRenderer<?, ?>>>
> entity = new PendingRegistrations<>(MsonImpl.id("renderers/entity"), (registry, key, entry) -> {
entry.getKey()
.ifLeft(unit -> registry.registerEntityRenderer(key, entry.getValue()))
.ifRight(condition -> registry.registerEntityRenderer((EntityType<Entity>)key, (Predicate<Entity>)condition, entry.getValue()));
.ifRight(condition -> registry.registerEntityRenderer((EntityType<Entity>)key, condition, entry.getValue()));
});
public final PendingRegistrations<
BlockEntityType<?>,
Expand All @@ -56,9 +56,10 @@ public <T extends PlayerEntityRenderer> void registerPlayerRenderer(Identifier s
entity.register(type, Map.entry(Either.left(Unit.INSTANCE), constructor));
}

@SuppressWarnings("unchecked")
@Override
public <T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Predicate<T> condition, Function<Context, R> constructor) {
entity.register(type, Map.entry(Either.right(condition), constructor));
public <T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Predicate<? super T> condition, Function<Context, R> constructor) {
entity.register(type, Map.entry(Either.right((Predicate<Entity>)condition), constructor));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public <R extends PlayerEntityRenderer> void registerPlayerRenderer(Identifier i

@SuppressWarnings("unchecked")
@Override
public <T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Predicate<T> condition, Function<Context, R> constructor) {
public <T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Predicate<? super T> condition, Function<Context, R> constructor) {
try {
if (customEntityRenderers == null) {
customEntityRenderers = new HashMap<>();
Expand Down

0 comments on commit ccc2c45

Please sign in to comment.