Skip to content

Commit

Permalink
screms at generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadows-of-Fire committed Dec 9, 2023
1 parent ca1df8a commit 96d346d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static <T> BlockCapability<T, Void> createVoid(ResourceLocation name, Cla
}

// INTERNAL
private static final CapabilityRegistry<BlockCapability<?, ?>> registry = new CapabilityRegistry(BlockCapability::new);
private static final CapabilityRegistry<BlockCapability<?, ?>> registry = new CapabilityRegistry<BlockCapability<?, ?>>(BlockCapability::new);

private BlockCapability(ResourceLocation name, Class<T> typeClass, Class<C> contextClass) {
super(name, typeClass, contextClass);
Expand All @@ -135,8 +135,7 @@ private BlockCapability(ResourceLocation name, Class<T> typeClass, Class<C> cont
final Map<Block, List<IBlockCapabilityProvider<T, C>>> providers = new IdentityHashMap<>();

@ApiStatus.Internal
@Nullable
public T getCapability(Level level, BlockPos pos, @Nullable BlockState state, @Nullable BlockEntity blockEntity, C context) {
public @Nullable T getCapability(Level level, BlockPos pos, @Nullable BlockState state, @Nullable BlockEntity blockEntity, C context) {
// Get block state and block entity if they were not provided
if (blockEntity == null) {
if (state == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static <T> EntityCapability<T, Void> createVoid(ResourceLocation name, Cl
}

// INTERNAL
private static final CapabilityRegistry<EntityCapability<?, ?>> registry = new CapabilityRegistry(EntityCapability::new);
private static final CapabilityRegistry<EntityCapability<?, ?>> registry = new CapabilityRegistry<EntityCapability<?, ?>>(EntityCapability::new);

private EntityCapability(ResourceLocation name, Class<T> typeClass, Class<C> contextClass) {
super(name, typeClass, contextClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static <T> ItemCapability<T, Void> createVoid(ResourceLocation name, Clas
}

// INTERNAL
private static final CapabilityRegistry<ItemCapability<?, ?>> registry = new CapabilityRegistry(ItemCapability::new);
private static final CapabilityRegistry<ItemCapability<?, ?>> registry = new CapabilityRegistry<ItemCapability<?, ?>>(ItemCapability::new);

private ItemCapability(ResourceLocation name, Class<T> typeClass, Class<C> contextClass) {
super(name, typeClass, contextClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public static DeferredRegister.Blocks createBlocks(String modid) {

private final ResourceKey<? extends Registry<T>> registryKey;
private final String namespace;
private final Map<DeferredHolder<T, ?>, Supplier<? extends T>> entries = new LinkedHashMap<>();
private final Set<DeferredHolder<T, ?>> entriesView = Collections.unmodifiableSet(entries.keySet());
private final Map<DeferredHolder<T, ? extends T>, Supplier<? extends T>> entries = new LinkedHashMap<>();
private final Set<DeferredHolder<T, ? extends T>> entriesView = Collections.unmodifiableSet(entries.keySet());
private final Map<ResourceLocation, ResourceLocation> aliases = new HashMap<>();

@Nullable
Expand Down Expand Up @@ -292,7 +292,7 @@ public void register(IEventBus bus) {
/**
* @return The unmodifiable view of registered entries. Useful for bulk operations on all values.
*/
public Collection<DeferredHolder<T, ?>> getEntries() {
public Collection<DeferredHolder<T, ? extends T>> getEntries() {
return entriesView;
}

Expand Down Expand Up @@ -340,7 +340,7 @@ private void addEntries(RegisterEvent event) {
this.seenRegisterEvent = true;
Registry<T> registry = event.getRegistry(this.registryKey);
this.aliases.forEach(registry::addAlias);
for (Entry<DeferredHolder<T, ?>, Supplier<? extends T>> e : entries.entrySet()) {
for (Entry<DeferredHolder<T, ? extends T>, Supplier<? extends T>> e : entries.entrySet()) {
event.register(this.registryKey, e.getKey().getId(), () -> e.getValue().get());
e.getKey().bind(false);
}
Expand Down

0 comments on commit 96d346d

Please sign in to comment.