Search in sources :

Example 1 with SimpleInventory

use of net.minecraft.inventory.SimpleInventory in project MasaGadget by plusls.

the class MixinRenderUtils method modifyInv.

@ModifyVariable(method = "renderInventoryOverlay", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/util/GuiUtils;getScaledWindowWidth()I", ordinal = 0, remap = false), ordinal = 0)
private static Inventory modifyInv(Inventory inv) {
    Inventory ret = inv;
    Entity traceEntity = TraceUtil.getTraceEntity();
    if (Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_SHULKER_BOX_ITEM_ENTITY.getBooleanValue() && ret == null && traceEntity instanceof ItemEntity) {
        ItemStack itemStack = ((ItemEntity) traceEntity).getStack();
        Item item = itemStack.getItem();
        NbtCompound invNbt = itemStack.getSubNbt("BlockEntityTag");
        DefaultedList<ItemStack> stacks = DefaultedList.ofSize(27, ItemStack.EMPTY);
        if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof ShulkerBoxBlock) {
            ret = new SimpleInventory(27);
            if (invNbt != null) {
                Inventories.readNbt(invNbt, stacks);
            }
            for (int i = 0; i < 27; ++i) {
                ret.setStack(i, stacks.get(i));
            }
        }
    }
    return ret;
}
Also used : Entity(net.minecraft.entity.Entity) ItemEntity(net.minecraft.entity.ItemEntity) Item(net.minecraft.item.Item) BlockItem(net.minecraft.item.BlockItem) ItemEntity(net.minecraft.entity.ItemEntity) NbtCompound(net.minecraft.nbt.NbtCompound) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 2 with SimpleInventory

use of net.minecraft.inventory.SimpleInventory in project BleachHack by BleachDrinker420.

the class CmdPeek method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    ItemStack item = mc.player.getInventory().getMainHandStack();
    if (item.getItem() instanceof BlockItem) {
        Block block = ((BlockItem) item.getItem()).getBlock();
        if (!(block instanceof ShulkerBoxBlock || block instanceof ChestBlock || block instanceof DispenserBlock || block instanceof HopperBlock)) {
            BleachLogger.error("Must be holding a containter to peek.");
            return;
        }
    } else if (item.getItem() != Items.BUNDLE) {
        BleachLogger.error("Must be holding a containter to peek.");
        return;
    }
    List<ItemStack> items = ItemContentUtils.getItemsInContainer(item);
    SimpleInventory inv = new SimpleInventory(items.toArray(new ItemStack[27]));
    BleachQueue.add(() -> mc.setScreen(new PeekShulkerScreen(new ShulkerBoxScreenHandler(420, mc.player.getInventory(), inv), mc.player.getInventory(), item.getName())));
}
Also used : ShulkerBoxScreenHandler(net.minecraft.screen.ShulkerBoxScreenHandler) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Example 3 with SimpleInventory

use of net.minecraft.inventory.SimpleInventory in project KahzerxMod by otakucraft.

the class SpoofExtension method spoofInv.

public int spoofInv(ServerCommandSource source, String playerE) throws CommandSyntaxException {
    int invSize = 54;
    int hotBarSize = 9;
    int hotBarStartPos = 27;
    int invStartPos = 9;
    Inventory inventory = new SimpleInventory(invSize);
    ServerPlayerEntity player = source.getPlayer();
    ServerPlayerEntity player2 = source.getServer().getPlayerManager().getPlayer(playerE);
    assert player2 != null;
    for (int i = 0; i < player2.getInventory().main.size(); i++) {
        if (i < hotBarSize) {
            inventory.setStack(i + hotBarStartPos, player2.getInventory().main.get(i));
        } else {
            inventory.setStack(i - invStartPos, player2.getInventory().main.get(i));
        }
    }
    int armorSlotStartPos = 45;
    for (int j = 0; j < player2.getInventory().armor.size(); j++) {
        inventory.setStack(j + armorSlotStartPos, player2.getInventory().armor.get(j));
    }
    int offHandSlotPos = 36;
    inventory.setStack(offHandSlotPos, player2.getInventory().offHand.get(0));
    ScreenHandlerListener listener = new ScreenHandlerListener() {

        @Override
        public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) {
        // source.getServer().getPlayerManager().saveAllPlayerData();
        }

        @Override
        public void onPropertyUpdate(ScreenHandler handler, int property, int value) {
        }
    };
    player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> {
        GenericContainerScreenHandler invCont = GenericContainerScreenHandler.createGeneric9x6(i, playerInventory, inventory);
        invCont.addListener(listener);
        return invCont;
    }, new LiteralText(String.format("%s stop hax >:(", player.getName().getString()))));
    return 1;
}
Also used : ExtensionSettings(com.kahzerx.kahzerxmod.extensions.ExtensionSettings) LiteralText(net.minecraft.text.LiteralText) ScreenHandler(net.minecraft.screen.ScreenHandler) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) GenericExtension(com.kahzerx.kahzerxmod.extensions.GenericExtension) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) Extensions(com.kahzerx.kahzerxmod.Extensions) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ItemStack(net.minecraft.item.ItemStack) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ScreenHandler(net.minecraft.screen.ScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ItemStack(net.minecraft.item.ItemStack) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) LiteralText(net.minecraft.text.LiteralText)

Example 4 with SimpleInventory

use of net.minecraft.inventory.SimpleInventory in project SinoCate by EverlastSino.

the class CuttingBoardBlockEntity method matchRecipe.

public void matchRecipe() {
    if (this.world == null || this.itemStack.isEmpty())
        return;
    Optional<CuttingRecipe> recipe = this.world.getRecipeManager().getFirstMatch(CateRecipes.Cutting_RecipeType, new SimpleInventory(this.itemStack), this.world);
    if (recipe.isEmpty())
        return;
    CuttingRecipe newRecipe = recipe.get();
    this.requireSteps = newRecipe.steps;
    this.result = newRecipe.result.copy();
    this.tool = newRecipe.tool.copy();
    this.damageTool = newRecipe.damageTool;
    this.step = 0;
    this.matchedRecipe = true;
}
Also used : CuttingRecipe(com.everlastsino.cate.recipe.recipes.CuttingRecipe) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Example 5 with SimpleInventory

use of net.minecraft.inventory.SimpleInventory in project Fabric-Course-118 by Kaupenjoe.

the class OrichalcumBlasterEntity method hasRecipe.

private static boolean hasRecipe(OrichalcumBlasterEntity entity) {
    World world = entity.world;
    SimpleInventory inventory = new SimpleInventory(entity.inventory.size());
    for (int i = 0; i < entity.inventory.size(); i++) {
        inventory.setStack(i, entity.getStack(i));
    }
    Optional<OrichalcumBlasterRecipe> match = world.getRecipeManager().getFirstMatch(OrichalcumBlasterRecipe.Type.INSTANCE, inventory, world);
    return match.isPresent() && canInsertAmountIntoOutputSlot(inventory) && canInsertItemIntoOutputSlot(inventory, match.get().getOutput());
}
Also used : OrichalcumBlasterRecipe(net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe) World(net.minecraft.world.World) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Aggregations

SimpleInventory (net.minecraft.inventory.SimpleInventory)10 ItemStack (net.minecraft.item.ItemStack)7 World (net.minecraft.world.World)4 OrichalcumBlasterRecipe (net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe)2 Entity (net.minecraft.entity.Entity)2 Inventory (net.minecraft.inventory.Inventory)2 BlockItem (net.minecraft.item.BlockItem)2 NbtCompound (net.minecraft.nbt.NbtCompound)2 ServerWorld (net.minecraft.server.world.ServerWorld)2 CuttingRecipe (com.everlastsino.cate.recipe.recipes.CuttingRecipe)1 Extensions (com.kahzerx.kahzerxmod.Extensions)1 ExtensionSettings (com.kahzerx.kahzerxmod.extensions.ExtensionSettings)1 GenericExtension (com.kahzerx.kahzerxmod.extensions.GenericExtension)1 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 InventoryOverlay (fi.dy.masa.malilib.render.InventoryOverlay)1 HashMap (java.util.HashMap)1 MeltingRecipe (net.cr24.primeval.recipe.MeltingRecipe)1 FluidVariant (net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant)1 ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)1