Search in sources :

Example 26 with Inventory

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;
}
Also used : GenericContainerScreen(net.minecraft.client.gui.screen.ingame.GenericContainerScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) Inventory(net.minecraft.inventory.Inventory) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 27 with Inventory

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;
}
Also used : GenericContainerScreen(net.minecraft.client.gui.screen.ingame.GenericContainerScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) Inventory(net.minecraft.inventory.Inventory) EventHandler(meteordevelopment.orbit.EventHandler)

Example 28 with Inventory

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)));
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader) BrewingStandBlockEntity(net.minecraft.block.entity.BrewingStandBlockEntity) NbtCraftingClient(de.siphalor.nbtcrafting.client.NbtCraftingClient) Inject(org.spongepowered.asm.mixin.injection.Inject) Slot(net.minecraft.container.Slot) Inventory(net.minecraft.inventory.Inventory) Recipe(net.minecraft.recipe.Recipe) BrewingRecipe(de.siphalor.nbtcrafting.recipe.BrewingRecipe) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) RecipeManagerAccessor(de.siphalor.nbtcrafting.mixin.RecipeManagerAccessor) ItemStack(net.minecraft.item.ItemStack) BrewingRecipeRegistry(net.minecraft.recipe.BrewingRecipeRegistry) Mixin(org.spongepowered.asm.mixin.Mixin) Map(java.util.Map) EnvType(net.fabricmc.api.EnvType) Identifier(net.minecraft.util.Identifier) NbtCrafting(de.siphalor.nbtcrafting.NbtCrafting) At(org.spongepowered.asm.mixin.injection.At) RecipeManagerAccessor(de.siphalor.nbtcrafting.mixin.RecipeManagerAccessor) Identifier(net.minecraft.util.Identifier) Recipe(net.minecraft.recipe.Recipe) BrewingRecipe(de.siphalor.nbtcrafting.recipe.BrewingRecipe) BrewingStandBlockEntity(net.minecraft.block.entity.BrewingStandBlockEntity) BrewingRecipe(de.siphalor.nbtcrafting.recipe.BrewingRecipe) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 29 with Inventory

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);
}
Also used : Block(net.minecraft.block.Block) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ParticleType(net.minecraft.particle.ParticleType) LivingEntity(net.minecraft.entity.LivingEntity) Predicate(java.util.function.Predicate) ServerWorld(net.minecraft.server.world.ServerWorld) RitualFunction(moriyashiine.bewitchment.api.registry.RitualFunction) TranslatableText(net.minecraft.text.TranslatableText) BWUtil(moriyashiine.bewitchment.common.misc.BWUtil) Inventory(net.minecraft.inventory.Inventory) BlockPos(net.minecraft.util.math.BlockPos) Bewitchment(moriyashiine.bewitchment.common.Bewitchment) TranslatableText(net.minecraft.text.TranslatableText) Block(net.minecraft.block.Block) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 30 with Inventory

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;
    });
}
Also used : AbstractFurnaceBlockEntity(net.minecraft.block.entity.AbstractFurnaceBlockEntity) FurnaceRecipeData(top.theillusivec4.polymorph.common.component.FurnaceRecipeData) Slot(net.minecraft.screen.slot.Slot) PolymorphCommon(top.theillusivec4.polymorph.api.common.base.PolymorphCommon) Inventory(net.minecraft.inventory.Inventory) BlockEntity(net.minecraft.block.entity.BlockEntity) AbstractFurnaceBlockEntity(net.minecraft.block.entity.AbstractFurnaceBlockEntity)

Aggregations

Inventory (net.minecraft.inventory.Inventory)40 ItemStack (net.minecraft.item.ItemStack)24 IInventory (net.minecraft.inventory.IInventory)8 PlayerInventory (net.minecraft.entity.player.PlayerInventory)6 SimpleInventory (net.minecraft.inventory.SimpleInventory)6 BlockPos (net.minecraft.util.math.BlockPos)6 CampfireCookingRecipe (net.minecraft.item.crafting.CampfireCookingRecipe)5 GenericContainerScreenHandler (net.minecraft.screen.GenericContainerScreenHandler)5 List (java.util.List)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 Optional (java.util.Optional)3 BlockEntity (net.minecraft.block.entity.BlockEntity)3 Entity (net.minecraft.entity.Entity)3 Recipe (net.minecraft.recipe.Recipe)3 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)3 Identifier (net.minecraft.util.Identifier)3 World (net.minecraft.world.World)3 Map (java.util.Map)2 Set (java.util.Set)2