generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v2.4.1+1.20] re-integrate with quickshulker (#58)
* bump deps * re-integrate with quick shulker * bump version * re-add quickshulker deps
- Loading branch information
Showing
4 changed files
with
77 additions
and
7 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
52 changes: 52 additions & 0 deletions
52
src/main/java/atonkish/reinfshulker/integration/quickshulker/QuickShulker.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,52 @@ | ||
package atonkish.reinfshulker.integration.quickshulker; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import net.kyrptonaught.quickshulker.api.ItemStackInventory; | ||
import net.kyrptonaught.quickshulker.api.QuickOpenableRegistry; | ||
import net.kyrptonaught.quickshulker.api.RegisterQuickShulker; | ||
|
||
import net.minecraft.block.entity.BlockEntityType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.entity.player.PlayerInventory; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.screen.ScreenHandlerFactory; | ||
import net.minecraft.screen.SimpleNamedScreenHandlerFactory; | ||
import net.minecraft.text.Text; | ||
|
||
import atonkish.reinfcore.screen.ReinforcedStorageScreenHandler; | ||
import atonkish.reinfcore.util.ReinforcingMaterial; | ||
import atonkish.reinfshulker.block.ReinforcedShulkerBoxBlock; | ||
import atonkish.reinfshulker.block.entity.ModBlockEntityType; | ||
|
||
public class QuickShulker implements RegisterQuickShulker { | ||
private static BiConsumer<PlayerEntity, ItemStack> REINFORCED_SHULKER_BOX_CONSUMER; | ||
|
||
@Override | ||
public void registerProviders() { | ||
new QuickOpenableRegistry.Builder() | ||
.setItem(ReinforcedShulkerBoxBlock.class) | ||
.supportsBundleing(true) | ||
.setOpenAction(REINFORCED_SHULKER_BOX_CONSUMER) | ||
.register(); | ||
} | ||
|
||
static { | ||
REINFORCED_SHULKER_BOX_CONSUMER = (PlayerEntity player, ItemStack stack) -> { | ||
ReinforcedShulkerBoxBlock block = (ReinforcedShulkerBoxBlock) ((BlockItem) stack.getItem()).getBlock(); | ||
ReinforcingMaterial material = block.getMaterial(); | ||
ItemStackInventory inventory = new ItemStackInventory(stack, material.getSize()); | ||
String namespace = BlockEntityType.getId(ModBlockEntityType.REINFORCED_SHULKER_BOX_MAP.get(material)) | ||
.getNamespace(); | ||
|
||
ScreenHandlerFactory screenHandlerFactory = (int syncId, PlayerInventory playerInventory, | ||
PlayerEntity playerEntity) -> ReinforcedStorageScreenHandler.createShulkerBoxScreen(material, | ||
syncId, playerInventory, inventory); | ||
Text text = stack.hasCustomName() ? stack.getName() | ||
: Text.translatable("container." + namespace + "." + material.getName() + "ShulkerBox"); | ||
|
||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory(screenHandlerFactory, text)); | ||
}; | ||
} | ||
} |
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