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;
}
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())));
}
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;
}
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;
}
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());
}
Aggregations