-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
478f78d
commit 266004e
Showing
43 changed files
with
381 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.refinedmods.refinedstorage.common.api; | ||
|
||
import com.refinedmods.refinedstorage.api.resource.ResourceAmount; | ||
import com.refinedmods.refinedstorage.api.resource.ResourceKey; | ||
import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; | ||
import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; | ||
import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.minecraft.world.item.Item; | ||
import org.apiguardian.api.API; | ||
|
||
@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.11") | ||
public interface RefinedStorageClientApi { | ||
RefinedStorageClientApi INSTANCE = new RefinedStorageClientApiProxy(); | ||
|
||
AbstractContainerScreen<AbstractContainerMenu> createStorageBlockScreen( | ||
AbstractContainerMenu menu, | ||
Inventory inventory, | ||
Component title, | ||
Class<? extends ResourceKey> resourceClass | ||
); | ||
|
||
void openAutocraftingPreview(List<ResourceAmount> requests, @Nullable Screen parentScreen); | ||
|
||
<T extends ResourceKey> void registerResourceRendering(Class<T> resourceClass, ResourceRendering rendering); | ||
|
||
<T extends ResourceKey> ResourceRendering getResourceRendering(Class<T> resourceClass); | ||
|
||
void addAlternativeGridInsertionHint(GridInsertionHint hint); | ||
|
||
GridInsertionHints getGridInsertionHints(); | ||
|
||
void registerDiskModel(Item item, ResourceLocation model); | ||
|
||
Set<ResourceLocation> getDiskModels(); | ||
|
||
Map<Item, ResourceLocation> getDiskModelsByItem(); | ||
} |
90 changes: 90 additions & 0 deletions
90
...src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApiProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.refinedmods.refinedstorage.common.api; | ||
|
||
import com.refinedmods.refinedstorage.api.resource.ResourceAmount; | ||
import com.refinedmods.refinedstorage.api.resource.ResourceKey; | ||
import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; | ||
import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; | ||
import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.minecraft.world.item.Item; | ||
|
||
public class RefinedStorageClientApiProxy implements RefinedStorageClientApi { | ||
@Nullable | ||
private RefinedStorageClientApi delegate; | ||
|
||
public void setDelegate(final RefinedStorageClientApi delegate) { | ||
if (this.delegate != null) { | ||
throw new IllegalStateException("Client API already injected"); | ||
} | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public AbstractContainerScreen<AbstractContainerMenu> createStorageBlockScreen( | ||
final AbstractContainerMenu menu, | ||
final Inventory inventory, | ||
final Component title, | ||
final Class<? extends ResourceKey> resourceClass | ||
) { | ||
return ensureLoaded().createStorageBlockScreen(menu, inventory, title, resourceClass); | ||
} | ||
|
||
@Override | ||
public void openAutocraftingPreview(final List<ResourceAmount> requests, @Nullable final Screen parentScreen) { | ||
ensureLoaded().openAutocraftingPreview(requests, parentScreen); | ||
} | ||
|
||
@Override | ||
public <T extends ResourceKey> void registerResourceRendering(final Class<T> resourceClass, | ||
final ResourceRendering rendering) { | ||
ensureLoaded().registerResourceRendering(resourceClass, rendering); | ||
} | ||
|
||
@Override | ||
public <T extends ResourceKey> ResourceRendering getResourceRendering(final Class<T> resourceClass) { | ||
return ensureLoaded().getResourceRendering(resourceClass); | ||
} | ||
|
||
@Override | ||
public void addAlternativeGridInsertionHint(final GridInsertionHint hint) { | ||
ensureLoaded().addAlternativeGridInsertionHint(hint); | ||
} | ||
|
||
@Override | ||
public GridInsertionHints getGridInsertionHints() { | ||
return ensureLoaded().getGridInsertionHints(); | ||
} | ||
|
||
@Override | ||
public void registerDiskModel(final Item item, final ResourceLocation model) { | ||
ensureLoaded().registerDiskModel(item, model); | ||
} | ||
|
||
@Override | ||
public Set<ResourceLocation> getDiskModels() { | ||
return ensureLoaded().getDiskModels(); | ||
} | ||
|
||
@Override | ||
public Map<Item, ResourceLocation> getDiskModelsByItem() { | ||
return ensureLoaded().getDiskModelsByItem(); | ||
} | ||
|
||
private RefinedStorageClientApi ensureLoaded() { | ||
if (delegate == null) { | ||
throw new IllegalStateException("API not loaded yet"); | ||
} | ||
return delegate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.