use of net.minecraft.inventory.Inventory in project KiwiClient by TangyKiwi.
the class EChestMemory method onOpenScreenEvent.
@Subscribe
@AllowConcurrentEvents
private static void onOpenScreenEvent(OpenScreenEvent event) {
if (echestOpenedState == 1 && event.getScreen() instanceof GenericContainerScreen) {
echestOpenedState = 2;
return;
}
if (echestOpenedState == 0)
return;
if (!(Utils.mc.currentScreen instanceof GenericContainerScreen))
return;
GenericContainerScreenHandler container = ((GenericContainerScreen) Utils.mc.currentScreen).getScreenHandler();
if (container == null)
return;
Inventory inv = container.getInventory();
for (int i = 0; i < 27; i++) {
ITEMS.set(i, inv.getStack(i));
}
echestOpenedState = 0;
}
use of net.minecraft.inventory.Inventory in project meteor-client by MeteorDevelopment.
the class EChestMemory method onOpenScreenEvent.
@EventHandler
private static void onOpenScreenEvent(OpenScreenEvent event) {
if (echestOpenedState == 1 && event.screen instanceof GenericContainerScreen) {
echestOpenedState = 2;
return;
}
if (echestOpenedState == 0)
return;
if (!(mc.currentScreen instanceof GenericContainerScreen))
return;
GenericContainerScreenHandler container = ((GenericContainerScreen) mc.currentScreen).getScreenHandler();
if (container == null)
return;
Inventory inv = container.getInventory();
for (int i = 0; i < 27; i++) {
ITEMS.set(i, inv.getStack(i));
}
echestOpenedState = 0;
}
use of net.minecraft.inventory.Inventory in project nbt-crafting by Siphalor.
the class MixinBrewingSlotIngredient method canInsert.
@Inject(method = "canInsert(Lnet/minecraft/item/ItemStack;)Z", at = @At("RETURN"), cancellable = true)
public void canInsert(ItemStack stack, CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
if (callbackInfoReturnable.getReturnValue() || BrewingRecipeRegistry.isValidIngredient(stack)) {
callbackInfoReturnable.setReturnValue(true);
return;
}
RecipeManagerAccessor recipeManager;
if (inventory instanceof BrewingStandBlockEntity) {
recipeManager = (RecipeManagerAccessor) ((BrewingStandBlockEntity) inventory).getWorld().getRecipeManager();
} else if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
recipeManager = (RecipeManagerAccessor) NbtCraftingClient.getClientRecipeManager();
} else {
NbtCrafting.logError("Failed to get recipe manager in brewing stand container class!");
return;
}
Map<Identifier, Recipe<Inventory>> recipes = recipeManager.callGetAllOfType(NbtCrafting.BREWING_RECIPE_TYPE);
callbackInfoReturnable.setReturnValue(recipes.values().stream().anyMatch(recipe -> recipe instanceof BrewingRecipe && ((BrewingRecipe) recipe).getIngredient().test(stack)));
}
use of net.minecraft.inventory.Inventory in project bewitchment by MoriyaShiine.
the class SearchBlocksRitualFunction method start.
@Override
public void start(ServerWorld world, BlockPos glyphPos, BlockPos effectivePos, Inventory inventory, boolean catFamiliar) {
PlayerEntity closestPlayer = world.getClosestPlayer(glyphPos.getX() + 0.5, glyphPos.getY() + 0.5, glyphPos.getZ() + 0.5, 8, false);
if (closestPlayer != null) {
Block block = world.getBlockState(glyphPos.down(2)).getBlock();
int blocks = BWUtil.getBlockPoses(effectivePos, catFamiliar ? 48 : 16, currentPos -> world.getBlockState(currentPos).getBlock() == block).size();
closestPlayer.sendMessage(new TranslatableText(Bewitchment.MODID + ".message.found_block" + (blocks == 1 ? "" : "s"), blocks, block.getName()), true);
}
super.start(world, glyphPos, effectivePos, inventory, catFamiliar);
}
use of net.minecraft.inventory.Inventory in project Polymorph by TheIllusiveC4.
the class PolymorphMod method onInitialize.
@Override
public void onInitialize() {
PolymorphNetwork.setup();
PolymorphCommands.setup();
CommonEventsListener.setup();
PolymorphIntegrations.init();
PolymorphIntegrations.setup();
PolymorphCommon commonApi = PolymorphApi.common();
commonApi.registerBlockEntity2RecipeData(AbstractFurnaceBlockEntity.class, blockEntity -> new FurnaceRecipeData((AbstractFurnaceBlockEntity) blockEntity));
commonApi.registerScreenHandler2BlockEntity(container -> {
for (Slot inventorySlot : container.slots) {
Inventory inventory = inventorySlot.inventory;
if (inventory instanceof BlockEntity) {
return (BlockEntity) inventory;
}
}
return null;
});
}
Aggregations